Struct MerkleBlock

Source
pub struct MerkleBlock { /* private fields */ }
Expand description

Partially-concealed merkle tree data.

Implementations§

Source§

impl MerkleBlock

Source

pub fn method(&self) -> Method

Method returning copy of MerkleBlock::method field. Method used to construct MPC proof (hash function, merklization).

Source

pub fn depth(&self) -> u5

Method returning copy of MerkleBlock::depth field. Tree depth (up to 16).

Source

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

Source

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

Source

pub fn with( proof: &MerkleProof, protocol_id: ProtocolId, message: Message, ) -> Result<Self, InvalidProof>

Constructs merkle block from a merkle proof

Source

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.

Source

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

Source

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.

Source

pub fn merge_reveal(&mut self, other: &MerkleBlock) -> Result<u16, MergeError>

Merges two merkle blocks together, joining revealed information from each one of them.

Source

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.

Source

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.

Source

pub fn protocol_id_pos(&self, protocol_id: ProtocolId) -> u32

Computes position for a given protocol_id within the tree leaves.

Source

pub fn width_limit(&self) -> u32

Computes the maximum possible width of the merkle tree.

Source

pub fn factored_width(&self) -> u32

Computes the factored width of the merkle tree according to the formula 2 ^ depth - cofactor.

Source

pub fn known_protocol_ids(&self) -> impl Iterator<Item = ProtocolId> + '_

Get an iterator over the known protocol ids present in the MPC Merkle block.

Source

pub fn to_known_message_map(&self) -> MessageMap

Constructs MessageMap for revealed protocols and messages.

Source

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

Source§

fn clone(&self) -> MerkleBlock

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl CommitEncode for MerkleBlock

Source§

type CommitmentId = Commitment

Type of the resulting commitment.
Source§

fn commit_encode(&self, engine: &mut CommitEngine)

Encodes the data for the commitment by writing them directly into a std::io::Write writer instance
Source§

impl Conceal for MerkleBlock

Source§

fn conceal(&self) -> Self::Concealed

Reduces merkle tree into merkle tree root.

Source§

type Concealed = MerkleConcealed

The resulting confidential type concealing original data.
Source§

impl Debug for MerkleBlock

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for MerkleBlock

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl From<&MerkleTree> for MerkleBlock

Source§

fn from(tree: &MerkleTree) -> Self

Converts to this type from the input type.
Source§

impl From<MerkleTree> for MerkleBlock

Source§

fn from(tree: MerkleTree) -> Self

Converts to this type from the input type.
Source§

impl Hash for MerkleBlock

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for MerkleBlock

Source§

fn eq(&self, other: &MerkleBlock) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Proof for MerkleBlock

Source§

fn matches(&self, other: &Self) -> bool

Verifies whether one MPC proof matches another MPC proof. Read more
Source§

impl Serialize for MerkleBlock

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StrictDecode for MerkleBlock

Source§

fn strict_decode(reader: &mut impl TypedRead) -> Result<Self, DecodeError>

Source§

fn strict_read(reader: impl ReadRaw) -> Result<Self, DecodeError>

Source§

impl StrictDeserialize for MerkleBlock

Source§

fn from_strict_serialized<const MAX: usize>( ast_data: Confined<Vec<u8>, 0, MAX>, ) -> Result<Self, DeserializeError>

Source§

fn strict_deserialize<const MAX: usize>( read: impl Read, ) -> Result<Self, DeserializeError>

Source§

fn strict_deserialize_from_file<const MAX: usize>( path: impl AsRef<Path>, ) -> Result<Self, DeserializeError>

Source§

impl StrictDumb for MerkleBlock

Source§

fn strict_dumb() -> Self

Source§

impl StrictEncode for MerkleBlock

Source§

fn strict_encode<W: TypedWrite>(&self, writer: W) -> Result<W>

Source§

fn strict_write(&self, writer: impl WriteRaw) -> Result<(), Error>

Source§

impl StrictSerialize for MerkleBlock

Source§

fn strict_serialized_len<const MAX: usize>(&self) -> Result<usize, Error>

Source§

fn to_strict_serialized<const MAX: usize>( &self, ) -> Result<Confined<Vec<u8>, 0, MAX>, SerializeError>

Source§

fn strict_serialize<const MAX: usize>( &self, write: impl Write, ) -> Result<(), Error>

Source§

fn strict_serialize_to_file<const MAX: usize>( &self, path: impl AsRef<Path>, ) -> Result<(), SerializeError>

Source§

impl StrictStruct for MerkleBlock

Source§

impl StrictType for MerkleBlock

Source§

const STRICT_LIB_NAME: &'static str = LIB_NAME_COMMIT_VERIFY

Source§

fn strict_name() -> Option<TypeName>

Source§

impl Eq for MerkleBlock

Source§

impl StrictProduct for MerkleBlock

Source§

impl StructuralPartialEq for MerkleBlock

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> CommitId for T
where T: CommitEncode,

Source§

fn commit(&self) -> CommitEngine

Source§

fn commit_id(&self) -> <T as CommitEncode>::CommitmentId

Performs commitment to client-side-validated data
Source§

impl<T> CommitmentLayout for T

Source§

fn commitment_layout() -> CommitLayout

Generate a descriptive commitment layout, which includes a description of each encoded field and the used hashing strategies.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> VerifyEq for T
where T: Eq,

Source§

fn verify_eq(&self, other: &T) -> bool

Verifies commit-equivalence of two instances of the same type.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,