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§
- Attestation
Report - Result of checking one memory’s attestation.
- Record
Attestation - 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_KEYthe 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 anchorsorts 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), orNoneon 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 iswm/record-attestation/v1. - verify_
attestation - Verify an attestation’s signature against its recorded pubkey.