Skip to main content

Module attestation

Module attestation 

Source
Expand description

Record attestations (Track F Slice A, D5 opening move) — tamper-evident provenance for created memories.

Every memory.create with a node key available appends one attestation to the attestations DBI, keyed att:{galaxy}:{memory_id}. The entry binds the memory’s content hash to the creating agent and node via an Ed25519 signature — the same algorithm as the Sangha mesh identity and its own HKDF-SHA256 purpose subkey (wm/record-attestation/v1) derived from the same canonical 64-hex root (wm_core::kdf::root_bytes; S9 §2.1 / Q39 §2), so identity and attestation keys never cross.

Payload domain separation: the signed bytes begin with ATTESTATION_DOMAIN (wm-record-attestation/v1), so a record attestation can never verify as a mesh heartbeat/chat payload or vice versa, even though both subkeys share one root. The 9.1.8 KDF split (S9 §2.1) rules new attestations onto the derived subkey; pre-9.1.8 rows keep verifying against their recorded pubkey, so no re-key of history is needed.

Why the sign/verify helper lives here instead of reusing wm_sangha::crypto: wm-memory must stay free of wm-sangha (mesh is a transport over stores, never a store dependency — otherwise future mesh↔store wiring cycles). The scheme is identical (Ed25519 over the domain-prefixed payload, lowercase hex); only the call site differs.

Merkle convention for wm anchor: merkle_root_hex uses the same Bitcoin-convention loop as the karma anchor (duplicate-last on odd layers, sha256(left || right) upward, sha256("") for the empty set), so anchor roots are comparable across subsystems. (Follow-up: factor the shared loop out of KarmaLedger::compute_merkle_root.)

Structs§

AttestationReport
Result of checking one memory’s attestation.
RecordAttestation
One attestation: a node’s signed claim “I created this record with this content hash at this time as this agent”.

Constants§

ATTESTATIONS_DB
Name of the LMDB sub-database holding attestations.
ATTESTATION_DOMAIN
Domain prefix for every signed attestation payload. Cross-protocol confusion is impossible by construction: no other WhiteMagic protocol signs bytes beginning with this string.
ATTESTATION_KEY_ENV
Environment variable carrying the node signing key (hex, 32 bytes) — the same WM_MESH_KEY the Sangha mesh uses for peer identity.

Functions§

anchor_leaf_input
Anchor leaf input for one attestation: binds the record hash to the attestation signature. wm anchor sorts leaves before hashing.
attestation_key
LMDB key for one memory’s attestation: att:{galaxy}:{memory_id}.
attestation_payload
Canonical signed payload. Pipe-delimited fixed-order fields — no canonical-JSON dependency, byte-stable by construction.
attestation_prefix
Key prefix covering the whole attestation DBI (for full scans).
derive_attestation_key_hex
Derive the record-attestation signing key (hex) from node root material.
merkle_root_hex
Merkle root over leaf-hash strings.
sha256_hex
SHA-256 of a string, lowercase hex.
sign_attestation
Sign an attestation payload with a 32-byte secret key (hex). Returns (public_key_hex, signature_hex), or None on bad key material. Pure function — env handling lives at the call site.
sign_attestation_from_root
Sign an attestation payload with the HKDF-derived attestation subkey from root material. Returns (public_key_hex, signature_hex); the lineage of the returned key is wm/record-attestation/v1.
verify_attestation
Verify an attestation’s signature against its recorded pubkey.