Skip to main content

MerkleLog

Struct MerkleLog 

Source
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

Source

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).

Source

pub fn log_id(&self) -> &str

The log instantiation identifier.

Source

pub fn tree_size(&self) -> u64

The current tree size (number of leaves).

Source

pub fn leaf(&self, leaf_index: u64) -> Option<&LogLeaf>

The leaf at leaf_index, if present.

Source

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).

Source

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).

Source

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.

Source

pub fn root_hash(&self) -> String

The current root in wire form: "sha256:" + lowercase_hex(MTH).

Source

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).

Source

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.

Source

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”).

Source

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.

Source

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).

Source

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.

Trait Implementations§

Source§

impl Clone for MerkleLog

Source§

fn clone(&self) -> MerkleLog

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MerkleLog

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.