pub struct MerkleBlock { /* private fields */ }
Expand description
Partially-concealed merkle tree data.
Implementations§
Source§impl MerkleBlock
impl MerkleBlock
Sourcepub fn method(&self) -> Method
pub fn method(&self) -> Method
Method returning copy of MerkleBlock::method
field.
Method used to construct MPC proof (hash function, merklization).
Sourcepub fn depth(&self) -> u5
pub fn depth(&self) -> u5
Method returning copy of MerkleBlock::depth
field.
Tree depth (up to 16).
Sourcepub fn cofactor(&self) -> u16
pub fn cofactor(&self) -> u16
Method returning copy of MerkleBlock::cofactor
field.
Cofactor is used as an additive to the modulo divisor to improve packing
Sourcepub fn entropy(&self) -> Option<u64>
pub fn entropy(&self) -> Option<u64>
Method returning copy of MerkleBlock::entropy
field.
Entropy used for placeholders. May be unknown if the message is provided
Source§impl MerkleBlock
impl MerkleBlock
Sourcepub fn with(
proof: &MerkleProof,
protocol_id: ProtocolId,
message: Message,
) -> Result<Self, InvalidProof>
pub fn with( proof: &MerkleProof, protocol_id: ProtocolId, message: Message, ) -> Result<Self, InvalidProof>
Constructs merkle block from a merkle proof
Sourcepub fn conceal_other(
&mut self,
protocol: ProtocolId,
) -> Result<(), LeafNotKnown>
pub fn conceal_other( &mut self, protocol: ProtocolId, ) -> Result<(), LeafNotKnown>
Conceals all commitments in the block except for the commitment under
given protocol_id
. Also removes information about the entropy value
used.
§Error
If leaf with the given protocol_id
is not found (absent or already
concealed), errors with LeafNotKnown
error.
Sourcepub fn conceal_except(
&mut self,
protocols: impl AsRef<[ProtocolId]>,
) -> Result<usize, LeafNotKnown>
pub fn conceal_except( &mut self, protocols: impl AsRef<[ProtocolId]>, ) -> Result<usize, LeafNotKnown>
Conceals all commitments in the block except for the commitment under
given protocol_id
s. Also removes information about the entropy value
used.
§Returns
Number of concealed nodes.
§Error
If leaf with the given protocol_id
is not found (absent or already
concealed), errors with LeafNotKnown
error.
Sourcepub fn merge_reveal_path(
&mut self,
proof: &MerkleProof,
protocol_id: ProtocolId,
message: Message,
) -> Result<u16, MergeError>
pub fn merge_reveal_path( &mut self, proof: &MerkleProof, protocol_id: ProtocolId, message: Message, ) -> Result<u16, MergeError>
Merges information from the given proof
to the merkle block, revealing
the path related to te commitment
to the message under the given
protocol_id
.
Sourcepub fn merge_reveal(&mut self, other: &MerkleBlock) -> Result<u16, MergeError>
pub fn merge_reveal(&mut self, other: &MerkleBlock) -> Result<u16, MergeError>
Merges two merkle blocks together, joining revealed information from each one of them.
Sourcepub fn into_merkle_proof(
self,
protocol_id: ProtocolId,
) -> Result<MerkleProof, LeafNotKnown>
pub fn into_merkle_proof( self, protocol_id: ProtocolId, ) -> Result<MerkleProof, LeafNotKnown>
Converts the merkle block into a merkle proof for the inclusion of a
commitment under given protocol_id
.
Sourcepub fn to_merkle_proof(
&self,
protocol_id: ProtocolId,
) -> Result<MerkleProof, LeafNotKnown>
pub fn to_merkle_proof( &self, protocol_id: ProtocolId, ) -> Result<MerkleProof, LeafNotKnown>
Constructs merkle proof for the inclusion of a commitment under the
given protocol_id
for the current Merkle block.
Sourcepub fn protocol_id_pos(&self, protocol_id: ProtocolId) -> u32
pub fn protocol_id_pos(&self, protocol_id: ProtocolId) -> u32
Computes position for a given protocol_id
within the tree leaves.
Sourcepub fn width_limit(&self) -> u32
pub fn width_limit(&self) -> u32
Computes the maximum possible width of the merkle tree.
Sourcepub fn factored_width(&self) -> u32
pub fn factored_width(&self) -> u32
Computes the factored width of the merkle tree according to the formula
2 ^ depth - cofactor
.
Sourcepub fn known_protocol_ids(&self) -> impl Iterator<Item = ProtocolId> + '_
pub fn known_protocol_ids(&self) -> impl Iterator<Item = ProtocolId> + '_
Get an iterator over the known protocol ids present in the MPC Merkle block.
Sourcepub fn to_known_message_map(&self) -> MessageMap
pub fn to_known_message_map(&self) -> MessageMap
Constructs MessageMap
for revealed protocols and messages.
Sourcepub fn into_known_proofs(
self,
) -> impl Iterator<Item = (ProtocolId, MerkleProof)>
pub fn into_known_proofs( self, ) -> impl Iterator<Item = (ProtocolId, MerkleProof)>
Convert this MPC Merkle block into an iterator over items and proofs of their inclusion.
Trait Implementations§
Source§impl Clone for MerkleBlock
impl Clone for MerkleBlock
Source§fn clone(&self) -> MerkleBlock
fn clone(&self) -> MerkleBlock
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl CommitEncode for MerkleBlock
impl CommitEncode for MerkleBlock
Source§type CommitmentId = Commitment
type CommitmentId = Commitment
Source§fn commit_encode(&self, engine: &mut CommitEngine)
fn commit_encode(&self, engine: &mut CommitEngine)
std::io::Write
writer instanceSource§impl Conceal for MerkleBlock
impl Conceal for MerkleBlock
Source§impl Debug for MerkleBlock
impl Debug for MerkleBlock
Source§impl<'de> Deserialize<'de> for MerkleBlock
impl<'de> Deserialize<'de> for MerkleBlock
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl From<&MerkleTree> for MerkleBlock
impl From<&MerkleTree> for MerkleBlock
Source§fn from(tree: &MerkleTree) -> Self
fn from(tree: &MerkleTree) -> Self
Source§impl From<MerkleTree> for MerkleBlock
impl From<MerkleTree> for MerkleBlock
Source§fn from(tree: MerkleTree) -> Self
fn from(tree: MerkleTree) -> Self
Source§impl Hash for MerkleBlock
impl Hash for MerkleBlock
Source§impl PartialEq for MerkleBlock
impl PartialEq for MerkleBlock
Source§impl Proof for MerkleBlock
impl Proof for MerkleBlock
Source§impl Serialize for MerkleBlock
impl Serialize for MerkleBlock
Source§impl StrictDecode for MerkleBlock
impl StrictDecode for MerkleBlock
fn strict_decode(reader: &mut impl TypedRead) -> Result<Self, DecodeError>
fn strict_read(reader: impl ReadRaw) -> Result<Self, DecodeError>
Source§impl StrictDeserialize for MerkleBlock
impl StrictDeserialize for MerkleBlock
fn from_strict_serialized<const MAX: usize>( ast_data: Confined<Vec<u8>, 0, MAX>, ) -> Result<Self, DeserializeError>
fn strict_deserialize<const MAX: usize>( read: impl Read, ) -> Result<Self, DeserializeError>
fn strict_deserialize_from_file<const MAX: usize>( path: impl AsRef<Path>, ) -> Result<Self, DeserializeError>
Source§impl StrictDumb for MerkleBlock
impl StrictDumb for MerkleBlock
fn strict_dumb() -> Self
Source§impl StrictEncode for MerkleBlock
impl StrictEncode for MerkleBlock
fn strict_encode<W: TypedWrite>(&self, writer: W) -> Result<W>
fn strict_write(&self, writer: impl WriteRaw) -> Result<(), Error>
Source§impl StrictSerialize for MerkleBlock
impl StrictSerialize for MerkleBlock
fn strict_serialized_len<const MAX: usize>(&self) -> Result<usize, Error>
fn to_strict_serialized<const MAX: usize>( &self, ) -> Result<Confined<Vec<u8>, 0, MAX>, SerializeError>
fn strict_serialize<const MAX: usize>( &self, write: impl Write, ) -> Result<(), Error>
fn strict_serialize_to_file<const MAX: usize>( &self, path: impl AsRef<Path>, ) -> Result<(), SerializeError>
Source§impl StrictStruct for MerkleBlock
impl StrictStruct for MerkleBlock
const ALL_FIELDS: &'static [&'static str]
fn strict_check_fields()
fn strict_type_info() -> TypeInfo<Self>
Source§impl StrictType for MerkleBlock
impl StrictType for MerkleBlock
const STRICT_LIB_NAME: &'static str = LIB_NAME_COMMIT_VERIFY
fn strict_name() -> Option<TypeName>
impl Eq for MerkleBlock
impl StrictProduct for MerkleBlock
impl StructuralPartialEq for MerkleBlock
Auto Trait Implementations§
impl Freeze for MerkleBlock
impl RefUnwindSafe for MerkleBlock
impl Send for MerkleBlock
impl Sync for MerkleBlock
impl Unpin for MerkleBlock
impl UnwindSafe for MerkleBlock
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> CommitId for Twhere
T: CommitEncode,
impl<T> CommitId for Twhere
T: CommitEncode,
fn commit(&self) -> CommitEngine
Source§fn commit_id(&self) -> <T as CommitEncode>::CommitmentId
fn commit_id(&self) -> <T as CommitEncode>::CommitmentId
Source§impl<T> CommitmentLayout for Twhere
T: CommitEncode + StrictDumb,
impl<T> CommitmentLayout for Twhere
T: CommitEncode + StrictDumb,
Source§fn commitment_layout() -> CommitLayout
fn commitment_layout() -> CommitLayout
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.