pub struct BuiltCommitment { /* private fields */ }Expand description
A fully-built commitment: signed wire blob, cached hash, Merkle tree
for inclusion proofs, and a sorted leaf-index lookup for the auditor’s
leaf_index field.
Held inside an Arc so audit responders can grab a reference and
build a reply without holding the ResponderCommitmentState read
lock for the duration of the response.
Implementations§
Source§impl BuiltCommitment
impl BuiltCommitment
Sourcepub fn build(
entries: Vec<(XorName, [u8; 32])>,
sender_peer_id: &[u8; 32],
secret_key: &MlDsaSecretKey,
sender_public_key: &[u8],
) -> Result<Self, CommitmentError>
pub fn build( entries: Vec<(XorName, [u8; 32])>, sender_peer_id: &[u8; 32], secret_key: &MlDsaSecretKey, sender_public_key: &[u8], ) -> Result<Self, CommitmentError>
Build a commitment over entries = [(key, bytes_hash), ...] and
sign it with secret_key.
entries does not need to be sorted (the inner MerkleTree
sorts internally); sender_peer_id is bound into the signature
and the commitment.
§Errors
Returns the wrapped CommitmentError on empty key sets,
over-cap key counts, duplicates, or signing failures.
Sourcepub fn build_from_tree(
tree: MerkleTree,
sender_peer_id: &[u8; 32],
secret_key: &MlDsaSecretKey,
sender_public_key: &[u8],
) -> Result<Self, CommitmentError>
pub fn build_from_tree( tree: MerkleTree, sender_peer_id: &[u8; 32], secret_key: &MlDsaSecretKey, sender_public_key: &[u8], ) -> Result<Self, CommitmentError>
Sign and wrap an ALREADY-BUILT Merkle tree. Lets callers that already
built the tree (e.g. the rotation no-op-root check, §11) avoid rebuilding
it inside Self::build.
§Errors
Propagates signing / serialization failures, identical to Self::build.
Sourcepub fn commitment(&self) -> &StorageCommitment
pub fn commitment(&self) -> &StorageCommitment
The signed wire blob.
Sourcepub fn hash(&self) -> [u8; 32]
pub fn hash(&self) -> [u8; 32]
The cached commitment hash. Equal to
crate::replication::commitment::commitment_hash
(self.commitment()).
Sourcepub fn tree(&self) -> &MerkleTree
pub fn tree(&self) -> &MerkleTree
The Merkle tree behind this commitment.
Used by the subtree-audit responder to plan a proof (select the nonce-determined branch and read its sibling cut-hashes).
Sourcepub fn proof_for(&self, key: &XorName) -> Option<(Vec<[u8; 32]>, u32)>
pub fn proof_for(&self, key: &XorName) -> Option<(Vec<[u8; 32]>, u32)>
Inclusion path + leaf index for key, if it is in this
commitment. Returns None if key is not committed.
Sourcepub fn contains_key(&self, key: &XorName) -> bool
pub fn contains_key(&self, key: &XorName) -> bool
Whether key is committed in this tree. Allocation-free membership
check (binary search over the sorted leaf keys) — equivalent to
proof_for(key).is_some() but without building the inclusion path, for
hot callers (e.g. the pruner’s is_held veto) that only need the
boolean.
Auto Trait Implementations§
impl Freeze for BuiltCommitment
impl RefUnwindSafe for BuiltCommitment
impl Send for BuiltCommitment
impl Sync for BuiltCommitment
impl Unpin for BuiltCommitment
impl UnsafeUnpin for BuiltCommitment
impl UnwindSafe for BuiltCommitment
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more