chadtmiller.com/group-host
atmosphere group host
0
0
atproto: PLC operations, DID documents and service-auth tokens
Merged Approved
This adds the plc, did and service_auth modules to crates/atproto. I read all three source files in full. The diff against main also carries the whole repo pull this is stacked on, and I did not review that part. I found nothing that has to change.
plc.rs: The signed bytes leave outsigand writeprevas CID text, as the directory does.did()hashes the signed genesis, andcid()andsigned_by()are consistent with that. Your byte-for-byte comparison against@did-plc/libbacks this up.service_auth.rs:verifychecks thatalgmatches the key and verifies the signature before it checksexp.checkholdsaudandlxm, andaccount()takes the#fragmentoffiss. A token with extra or missing segments fails the signature check, so thersplit_oncefallback is safe.did.rs: Lookup by the end of the id is the same as in knotless, as you say.
Small things, none worth holding the pull for:
Signed::from_jsonreads aprevthat is neither null nor a string as a genesis, with no error. That is lenient for input from outside.Signed::did()does not check that the operation is a genesis, so it will give a DID for an operation that has aprev. The doc comment says what it is for, but callers need to know.
Approved
This round, I read the diff from my last reviewed head (6fe7ef9) to 275f34b. It has three changes besides the docs. I found nothing that has to change.
mst.rs:read_nodenow refuses a node reached twice, using aseenset. A valid MST never reaches one node from two places, andTree::readchecks the root against the tree the keys make. So this refuses nothing valid and closes the exponential walk. The new test covers it.commit.rs:map.len() != 6rejects extra fields, so a commit written back still comes to its CID. It is tested.Cargo.toml:bs58is no longer a dev-dependency, andsha2moved. Nothing in the diff's tests usesbs58.
The two small points from my last review are unchanged and still not worth holding the pull for. Signed::from_json reads a non-string prev as a genesis. Signed::did() does not check that the operation is a genesis.
Merged as 275f34b
What changes
crates/atprotogets identity, the last of step 2's parts:plc: PLC operations made and signed (genesis, update, tombstone), the DID a genesis makes, each operation's CID, which rotation key signed one, and operations read from and written as the directory's JSON. Aprevis a CID written as text, inside the signed bytes too, as the directory has it.did: DID documents read as knotless reads them (services and keys found by the end of their id,#atproto_pds,#atproto, the space alpha's#atproto_kem, the claimed handle), and the document of a service's owndid:web, which the host serves for itself.service_auth: service-auth JWTs signed, read and checked:algmust be the key's, the signature low-S,expafter the time given;checkholdsaudandlxmand answers the account asking, a service's#fragmenttaken offiss.Why
The host mints its groups'
did:plcs and rotates their keys, serves its owndid:web, and checks the service token on nearly every call it answers. These follow knotless's conventions where knotless already does the same thing (itscrypto,identityandauth), so the two read documents and tokens alike.How it was checked
Against the reference implementations, with fixed keys (
tests/reference/identity.json, fromidentity.mjs): every operation @did-plc/lib makes, for a secp256k1 rotation key and for a P-256 one beside a second key, is byte for byte the same here (genesis, handle update, PDS update, tombstone), signatures included, as both sign by RFC 6979; so are the DID and CIDs. The directory's DID document reads here, and a JWT @atproto/xrpc-server signs checks.Against knotless, with a scratch crate linking both (not kept, as CI has no knotless checkout): 505 DRISL records encoded and read back the same;
did:keys from the same secrets; P-256 signatures identical, each checking the other's; every signature vector judged alike; 5,000 TIDs; all handle vectors. knotless'sverify_jwttakes this crate's tokens on both curves, and a token knotless signs is kept astests/reference/knotless.jsonand checks here. The one difference: a float like123.0encodes here, as the interop vectors call it valid, and knotless refuses it.Locally,
cargo llvm-covat 100% of lines and functions, clippy clean.Shortcomings
Stacked on the repo pull. Reading a DID's whole operation log, as the directory's audit log has it, with nullification, is not here: the host only ever writes its own groups' operations and reads documents. Nothing in the host uses these yet.
Review
src/plc.rs(fields,did,signed_by) andsrc/service_auth.rs(verify).