part 1 ended on a claim: anyone holding a commit and my did document can check the signature without asking my server whether it's telling the truth. this week i tested it. i pulled my whole repo off my own server, closed the connection, and tried to prove from the raw bytes alone that the history is mine.
$ downlink · the tapestry
panel 2 of 5. every new page i write is sealed together with all the pages before it. change one word anywhere and the seal breaks.
devarno.com 1 · the map
2 · this part
? ? ? 3 · not yet woven
4 · not yet woven
app.bsky sh.tangled 5 · not yet woven
export it
one request returns the entire repo as a single file:
GET pds.
did = did:web:devarno.com
- content-type
- application/vnd.ipld.car
- bytes
- 11402
- time
- 0.19s
published response · run it to compare with what the server says now
the file is a car: a content-addressed archive. a short header names one root, then blocks follow, each tagged with the hash of its own bytes. there are 17 blocks in mine. the first thing my checker does is rehash every one and compare it to its tag. all 17 match, so nothing in the file was altered after the server hashed it, and the file is the whole account: 9 posts, one profile, one follow, one chat setting, one tangled profile.
eleven kilobytes is the cost of carrying my whole presence on the network around. a backup is one curl.
read one commit
the header's root points at the commit. decoded, it has six fields:
did did:web:devarno.com
version 3
rev 3mwq6576bv22j
prev null
data bafyreifrgcthpkiivmdjw3h7ag7pu4wqarzhrj4rg6msjzhf2vcmdsjv3q
sig 64 bytesdid says whose repo this is. rev is a timestamp-shaped counter that only moves forward; in part 1 it read 3mour3bhkkk2p, and every post since has pushed it on. data is the hash of the root of a tree that holds every record. sig is a signature over the other five fields.
prev surprised me. it's empty. a version 3 commit doesn't point at the commit before it, so the repo isn't a chain i can walk backwards. each commit stands alone: a signed snapshot of everything, stamped with a rev.
walk the tree
data leads into a merkle search tree. mine is small enough to draw whole:
three nodes, two levels, 13 records. the path to profile/self is two hops: commit, root node, record. the record's block decodes to a display name of null0.
what decides that the profile sits on the top level and eight posts sit one level down? not the order i wrote them. each key is hashed, and the number of leading zero pairs in that hash sets its layer. i computed it for all 13 keys: the three on the top level have one leading zero pair, the ten below have none. no exceptions.
that rule is the point. the shape of the tree comes from the keys alone, so two repos holding the same records build the same tree and the same root hash, whatever order the records arrived in. two copies of my account can be compared by one hash.
check it without my server
this is the part i care about. with the file on disk and the network off, the check needs one more thing: the public key, which part 1 found in my did document under #atproto:
publicKeyMultibase zQ3shMXqrJnBeMigS2nCw1KbM9avnEp1vUpgK3wiAaPqAFqbjthe zQ3s prefix marks a key. the checker takes the commit, drops sig, re-encodes the remaining five fields canonically, hashes them, and verifies the 64-byte signature against that key.
SIGNATURE VALID (0.012s)then i flipped one bit in the last byte of the encoded commit and ran it again:
SIGNATURE INVALIDone bit is enough. and because the commit carries data, the hash of the tree root, which carries the hashes of every node and record under it, the one signature covers all 11 kilobytes. change a letter in any post and its block hash changes, the node above it changes, the root changes, and the signature no longer fits.
what this does and doesn't prove
it proves this: the holder of the key named in my did document signed a snapshot of exactly these 13 records, at rev 3mwq6576bv22j. a mirror, a relay or a stranger with a copy can check that without trusting .devarno.com, and can't edit a byte without being caught.
it doesn't prove four things.
- that the snapshot is current. a server could hand you an older signed commit. the rev only helps if you remember a higher one.
- what came before. with
prevempty, deleted records leave no trace in the repo. history lives with whoever kept old copies. - who holds the key. the pds generated it and holds it. the signature proves the key signed, not that i pressed anything. on a server i run, that's the same thing. on someone else's, it isn't.
- that the key is the right key. the check is only as good as the did document i fetched, and that document is a file on my domain. whoever controls devarno.com controls which key counts. part 3 is about that: two keys and a domain.