pub struct MerkleLog { /* private fields */ }Expand description
An append-only, in-memory RFC 6962-style Merkle tree over transparency-log leaves (RFC-ACDP-0012 §5).
Implementations§
Source§impl MerkleLog
impl MerkleLog
Sourcepub fn new(log_id: impl Into<String>) -> Result<Self, AcdpError>
pub fn new(log_id: impl Into<String>) -> Result<Self, AcdpError>
Create an empty log for log_id
("<registry_did>/log/<instance>", validated per RFC-ACDP-0012
§6).
Sourcepub fn leaf_hash_hex(&self, leaf_index: u64) -> Option<String>
pub fn leaf_hash_hex(&self, leaf_index: u64) -> Option<String>
The §5.1 leaf hash at leaf_index, wire form
("sha256:<hex>") — what GET /log/entries serves for every
entry regardless of visibility (§8.3).
Sourcepub fn append(&mut self, leaf: LogLeaf) -> Result<u64, AcdpError>
pub fn append(&mut self, leaf: LogLeaf) -> Result<u64, AcdpError>
Append a leaf, returning its assigned leaf_index
(consecutive from 0 in acceptance order, §5.3 / §7.1 rule 2).
Enforces the §4 leaf invariants at the door: exact
leaf_version (via the closed reparse), one leaf per ctx_id,
and origin_registry equal to both the ctx_id authority and
the log’s registry DID authority. Rejected publishes MUST NOT be
logged — append only what has a receipt (§4).
Sourcepub fn root(&self) -> [u8; 32]
pub fn root(&self) -> [u8; 32]
MTH(D[tree_size]) — the current root, raw digest (§5.2). The
empty tree’s root is SHA-256 of the empty string.
Sourcepub fn root_hash(&self) -> String
pub fn root_hash(&self) -> String
The current root in wire form: "sha256:" + lowercase_hex(MTH).
Sourcepub fn root_at(&self, tree_size: u64) -> Result<[u8; 32], AcdpError>
pub fn root_at(&self, tree_size: u64) -> Result<[u8; 32], AcdpError>
The root at a historical tree_size (MTH(D[0:tree_size])) —
every prefix root remains committed by consistency (§8.2).
Sourcepub fn checkpoint(
&self,
signer: &ReceiptSigner,
timestamp: DateTime<Utc>,
) -> Result<LogCheckpoint, AcdpError>
pub fn checkpoint( &self, signer: &ReceiptSigner, timestamp: DateTime<Utc>, ) -> Result<LogCheckpoint, AcdpError>
Sign a checkpoint over the current tree (§6): the §7.2
serve-on-demand head. timestamp is the registry-clock
evaluation time (truncated to milliseconds by the minter).
The signer is the RFC-ACDP-0010 receipt signer — the log
introduces no new key role — and its registry_did MUST match
the DID embedded in this log’s log_id.
Sourcepub fn checkpoint_at(
&self,
signer: &ReceiptSigner,
tree_size: u64,
timestamp: DateTime<Utc>,
) -> Result<LogCheckpoint, AcdpError>
pub fn checkpoint_at( &self, signer: &ReceiptSigner, tree_size: u64, timestamp: DateTime<Utc>, ) -> Result<LogCheckpoint, AcdpError>
Sign a checkpoint at a historical tree_size (§8.2: “for a
historical tree_size the registry serves a checkpoint it signed
at that size, or signs one on demand — both roots are equally
committed by consistency”).
Sourcepub fn inclusion_proof(
&self,
leaf_index: u64,
checkpoint: &LogCheckpoint,
) -> Result<LogInclusion, AcdpError>
pub fn inclusion_proof( &self, leaf_index: u64, checkpoint: &LogCheckpoint, ) -> Result<LogInclusion, AcdpError>
Build the §8.2 inclusion-mode proof object for leaf_index
against checkpoint (which MUST be a checkpoint of this log at
leaf_index < tree_size ≤ current size — pass a
Self::checkpoint/Self::checkpoint_at product).
The leaf echo is left absent; per §8.2 it is echoed only to
requesters authorized to retrieve the context, which is the
caller’s visibility decision — use Self::leaf and
LogInclusion::leaf to attach it.
Sourcepub fn consistency_proof(
&self,
first: u64,
second: u64,
) -> Result<Vec<String>, AcdpError>
pub fn consistency_proof( &self, first: u64, second: u64, ) -> Result<Vec<String>, AcdpError>
The RFC 6962 §2.1.2 consistency path PROOF(first, D[second])
between two tree sizes of this log, wire form (§8.2 consistency
mode; 0 < first ≤ second ≤ current size; empty when
first == second).
Sourcepub fn consistency_proof_response(
&self,
first: u64,
checkpoint: &LogCheckpoint,
) -> Result<LogConsistencyProof, AcdpError>
pub fn consistency_proof_response( &self, first: u64, checkpoint: &LogCheckpoint, ) -> Result<LogConsistencyProof, AcdpError>
Build the full §8.2 consistency-mode response object:
PROOF(first, D[checkpoint.tree_size]) packaged with the
checkpoint at the second size.