Skip to main content

compute_leaf_hash

Function compute_leaf_hash 

Source
pub fn compute_leaf_hash(
    sequence: u64,
    timestamp_ms: f64,
    artifact_bytes: &[u8],
) -> Vec<u8> 
Expand description

Compute the Merkle leaf hash for an entry. The leaf hash is SHA-256(0x01 || entry_hash) where entry_hash is SHA-256(sequence_le_bytes || timestamp_micros_le_bytes || artifact_hash).

Callers who already know the leaf hash for a given sequence should pass that directly to verify_inclusion_with_head. This helper is for callers who only have the raw artifact + the sequence metadata published by the log.

§Arguments

  • sequence — monotonic sequence number assigned by the log.
  • timestamp_ms — Unix epoch milliseconds when the entry was appended (matches the entry’s timestamp in the log).
  • artifact_bytes — the raw artifact whose SHA-256 was anchored.

§Returns

32-byte leaf hash as Uint8Array.