pub struct MmrPeaks { /* private fields */ }
Implementations§
source§impl MmrPeaks
impl MmrPeaks
sourcepub fn num_leaves(&self) -> usize
pub fn num_leaves(&self) -> usize
Returns a count of leaves in the underlying MMR.
sourcepub fn get_peak(&self, peak_idx: usize) -> Result<&RpoDigest, MmrError>
pub fn get_peak(&self, peak_idx: usize) -> Result<&RpoDigest, MmrError>
Returns the peak by the provided index.
§Errors
Returns an error if the provided peak index is greater or equal to the current number of peaks in the Mmr.
sourcepub fn into_parts(self) -> (usize, Vec<RpoDigest>)
pub fn into_parts(self) -> (usize, Vec<RpoDigest>)
Converts this MmrPeaks into its components: number of leaves and a vector of peaks of the underlying MMR.
sourcepub fn hash_peaks(&self) -> RpoDigest
pub fn hash_peaks(&self) -> RpoDigest
Hashes the peaks.
The procedure will:
- Flatten and pad the peaks to a vector of Felts.
- Hash the vector of Felts.
sourcepub fn verify(
&self,
value: RpoDigest,
opening: MmrProof,
) -> Result<(), MmrError>
pub fn verify( &self, value: RpoDigest, opening: MmrProof, ) -> Result<(), MmrError>
Verifies the Merkle opening proof.
§Errors
Returns an error if:
- provided opening proof is invalid.
- Mmr root value computed using the provided leaf value differs from the actual one.
sourcepub fn flatten_and_pad_peaks(&self) -> Vec<Felt>
pub fn flatten_and_pad_peaks(&self) -> Vec<Felt>
Flattens and pads the peaks to make hashing inside of the Miden VM easier.
The procedure will:
- Flatten the vector of Words into a vector of Felts.
- Pad the peaks with ZERO to an even number of words, this removes the need to handle RPO padding.
- Pad the peaks to a minimum length of 16 words, which reduces the constant cost of hashing.
Trait Implementations§
source§impl From<&MmrPeaks> for PartialMmr
impl From<&MmrPeaks> for PartialMmr
source§impl From<&PartialMmr> for MmrPeaks
impl From<&PartialMmr> for MmrPeaks
source§fn from(partial_mmr: &PartialMmr) -> Self
fn from(partial_mmr: &PartialMmr) -> Self
Converts to this type from the input type.
source§impl From<MmrPeaks> for PartialMmr
impl From<MmrPeaks> for PartialMmr
source§impl From<PartialMmr> for MmrPeaks
impl From<PartialMmr> for MmrPeaks
source§fn from(partial_mmr: PartialMmr) -> Self
fn from(partial_mmr: PartialMmr) -> Self
Converts to this type from the input type.
impl Eq for MmrPeaks
impl StructuralPartialEq for MmrPeaks
Auto Trait Implementations§
impl Freeze for MmrPeaks
impl RefUnwindSafe for MmrPeaks
impl Send for MmrPeaks
impl Sync for MmrPeaks
impl Unpin for MmrPeaks
impl UnwindSafe for MmrPeaks
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
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)