pub struct StateRoot {
pub hash: [u8; 32],
pub parent: Option<[u8; 32]>,
pub hlc: Hlc,
pub device_id: Uuid,
pub signature: [u8; 64],
pub seq: u64,
}Expand description
A state root representing a Merkle commitment to the entire cognitive state.
Each update to the knowledge graph produces a new state root, forming a chain of cryptographically verifiable state transitions.
Fields§
§hash: [u8; 32]BLAKE3 hash of the Merkle tree root
parent: Option<[u8; 32]>Hash of the previous state root (None for genesis)
hlc: HlcHLC timestamp when this root was created
device_id: UuidDevice ID that produced this state
signature: [u8; 64]Ed25519 signature over (hash || parent || hlc || device_id || seq)
seq: u64Sequence number for ordering (increments per device)
Implementations§
Source§impl StateRoot
impl StateRoot
Sourcepub fn new(
hash: [u8; 32],
parent: Option<[u8; 32]>,
hlc: Hlc,
device_id: Uuid,
seq: u64,
) -> Self
pub fn new( hash: [u8; 32], parent: Option<[u8; 32]>, hlc: Hlc, device_id: Uuid, seq: u64, ) -> Self
Create a new unsigned state root
Sourcepub fn signing_bytes(&self) -> Vec<u8> ⓘ
pub fn signing_bytes(&self) -> Vec<u8> ⓘ
Get the bytes to be signed.
Layout: hash (32) || parent (32, zeroed if None) || hlc (26) || device_id (16) || seq (8)
Total: 114 bytes
Sourcepub fn is_genesis(&self) -> bool
pub fn is_genesis(&self) -> bool
Check if this is the genesis (first) state root
Sourcepub fn short_hash(&self) -> String
pub fn short_hash(&self) -> String
Get the short hash (first 8 chars) for display
Sourcepub fn sign(&mut self, signing_key: &SigningKey)
pub fn sign(&mut self, signing_key: &SigningKey)
Sign the state root with the given key.
Sourcepub fn verify(&self, verifying_key: &VerifyingKey) -> Result<(), SignatureError>
pub fn verify(&self, verifying_key: &VerifyingKey) -> Result<(), SignatureError>
Verify the state root signature.