FRAME supports cryptographic attestations for cross-instance verification and state proof.
File: ui/runtime/replay.js
Attestations are cryptographic proofs of state root and receipt chain commitment, signed by identity. They enable:
- Cross-instance verification — Compare state roots across instances
- State proof — Prove current state without sharing full chain
- Federation sync — Detect divergence and sync
Function: exportAttestation(identity)
Structure:
{
version: 1,
protocolVersion: "2.2.0",
receiptVersion: 2,
capabilityVersion: 2,
stateRootVersion: 3,
identityPublicKey: "hex...",
stateRoot: "hex...",
receiptChainCommitment: "hex...",
receiptCount: 100,
timestamp: 1234567890,
signature: "hex..."
}Fields:
version— Attestation format version (1)protocolVersion— FRAME protocol versionreceiptVersion— Receipt schema versioncapabilityVersion— Capability schema versionstateRootVersion— State root schema versionidentityPublicKey— Ed25519 public key (hex)stateRoot— Current state rootreceiptChainCommitment— Hash of latest receiptreceiptCount— Number of receipts in chaintimestamp— Attestation timestampsignature— Ed25519 signature of attestation hash
Verification: verifyAttestation(attestation, publicKeyHex)
Function: exportStateAttestation()
Structure:
{
identityPublicKey: "hex...",
stateRoot: "hex...",
chainHash: "hex...",
protocolVersion: "2.2.0",
receiptVersion: 2,
capabilityVersion: 2,
timestamp: 1234567890,
signature: "hex..."
}Fields:
identityPublicKey— Ed25519 public key (hex)stateRoot— Current state rootchainHash— SHA-256 of canonicalized receipt chainprotocolVersion— FRAME protocol versionreceiptVersion— Receipt schema versioncapabilityVersion— Capability schema versiontimestamp— Attestation timestampsignature— Ed25519 signature of payload hash
Verification: verifyStateAttestation(attestation, publicKeyHex)
Function: exportGenesis()
Structure:
{
identityPublicKey: "hex...",
protocolVersion: "2.2.0",
receiptVersion: 2,
capabilityVersion: 2,
stateRootVersion: 3,
timestamp: 1234567890,
signature: "hex..."
}Purpose: Initial attestation for new identity (no state root or chain yet).
-
Gather state:
- Current identity
- Public key
- State root (via
computeStateRoot()) - Receipt chain commitment
-
Build payload:
var payload = canonicalize({ identityPublicKey: publicKey, stateRoot: stateRoot, chainHash: chainHash, protocolVersion: protocolVersion, receiptVersion: receiptVersion, capabilityVersion: capabilityVersion, timestamp: timestamp });
-
Hash payload:
var payloadHash = await sha256(JSON.stringify(payload));
-
Sign:
var signature = await __FRAME_INVOKE__('sign_data', { data: payloadHash });
-
Return attestation:
return Object.freeze({ ...payload, signature: signature });
Process:
-
Extract payload (exclude signature)
-
Canonicalize payload
-
Hash payload
-
Verify signature:
var keyBuf = hexDecode(publicKeyHex); var sigBuf = hexDecode(attestation.signature); var msgBuf = hexDecode(payloadHash); var key = await crypto.subtle.importKey('raw', keyBuf, { name: 'Ed25519' }, false, ['verify']); var valid = await crypto.subtle.verify({ name: 'Ed25519' }, key, sigBuf, msgBuf);
-
Verify protocol versions match
-
Return:
{ valid: true }or{ valid: false, reason: "..." }
Function: compareStateRoots(localAttestation, remoteAttestation)
Process:
-
Verify both attestations (signatures valid)
-
Compare state roots:
- If match → Instances synchronized
- If differ → Divergence detected
-
Compare receipt counts:
- If local < remote → Local behind
- If local > remote → Local ahead
- If equal but roots differ → Divergence
Result:
{
synchronized: true | false,
localAhead: boolean,
remoteAhead: boolean,
divergence: boolean,
reason?: string
}Attestations are:
- Public — No private data included
- Verifiable — Can be verified without trust
- Deterministic — Same state produces same attestation
- Signed — Ed25519 signature proves authenticity
Attestations do NOT:
- Include private keys
- Include full receipt chains
- Include storage data
- Mutate state
- Export attestation from local instance
- Send to peer via network
- Receive peer attestation
- Compare state roots — If differ, sync receipts
- Export state attestation
- Share with verifier
- Verifier checks signature and protocol versions
- Verifier trusts state root without full chain
- Compare attestations from multiple instances
- Detect divergence if state roots differ
- Investigate receipt chains to find divergence point
Attestation functions must:
- Use
canonicalize()for payload - Use
sha256()for hashing - Use
sign_datafor signing - Use
get_identity_public_keyfor public key - Use
computeStateRoot()for state root - NOT write to storage
- NOT append receipts
- NOT mutate state
- Replay and Verification - Attestation functions
- Federation and Sync - Cross-instance sync
- State Root - State root computation
- Receipt Chain - Receipt chain commitment