| … | … | @@ -32,6 +32,28 @@ export async function attestDeviceChain ({ rootMnemonic, rootSeed, devicePublicK |
| 32 | 32 | return IdentityKey.bootstrap({ mnemonic: rootMnemonic, seed: rootSeed }, devicePublicKey) |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | // An ALREADY-ATTESTED device attests ANOTHER device, extending the chain: root → parent → child. |
| 36 | // keet's attestDevice signs { epoch, identity, device } with the PARENT's keypair and pushes |
| 37 | // { publicKey, signature } onto the parent's chain, so the result still resolves to the same root |
| 38 | // identity and the same epoch — a chained device passes the identical admission gate and the identical |
| 39 | // minimum-epoch receipt check as a root-attested one. |
| 40 | // |
| 41 | // WHY THIS MATTERS OPERATIONALLY: admitting a new device to a room needs a proof anchored at the room's |
| 42 | // root identity, and attestDeviceChain above needs the ROOT MNEMONIC — which is deliberately not stored |
| 43 | // on any node (config.js: a device "must never hold" it). Read alone, that makes adding a co-owner |
| 44 | // impossible without recovering a secret nobody kept. It is not: an existing attested device already has |
| 45 | // everything required to vouch for the next one. Only the root's PUBLIC key is needed to verify. |
| 46 | // |
| 47 | // parentKeyPair: the attesting device's Ed25519 identity keypair (deviceKeetKeyPair of its mnemonic). |
| 48 | // parentProof: that device's own proof (root-attested, or itself chained — chains nest). |
| 49 | export function attestDeviceViaDevice ({ parentKeyPair, parentProof, devicePublicKey }) { |
| 50 | if (!parentKeyPair || !parentProof || !devicePublicKey) throw new Error('attestDeviceViaDevice: parentKeyPair, parentProof, devicePublicKey required') |
| 51 | // Pass the proof as BYTES: keet decodes a fresh copy, so the caller's proof is never mutated by the |
| 52 | // chain.push inside attestDevice (it would otherwise grow the parent's own proof on every call). |
| 53 | const proof = b4a.isBuffer(parentProof) ? parentProof : b4a.from(parentProof) |
| 54 | return IdentityKey.attestDevice(b4a.from(devicePublicKey), parentKeyPair, proof) |
| 55 | } |
| 56 | |
| 35 | 57 | // The attested (leaf) device vouches for the atproto DID by signing it as attested data, |
| 36 | 58 | // extending the proof with `proof.data`. Result: root → device → vouches-for(did). |
| 37 | 59 | export function attestAtprotoBinding ({ deviceKeyPair, did, proof }) { |