-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #195 from 0xPolygonMiden/hacka-partial-mmr2
mmr: added partial mmr
- Loading branch information
Showing
13 changed files
with
1,129 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use super::super::{RpoDigest, Vec}; | ||
|
||
/// Container for the update data of a [PartialMmr] | ||
#[derive(Debug)] | ||
pub struct MmrDelta { | ||
/// The new version of the [Mmr] | ||
pub forest: usize, | ||
|
||
/// Update data. | ||
/// | ||
/// The data is packed as follows: | ||
/// 1. All the elements needed to perform authentication path updates. These are the right | ||
/// siblings required to perform tree merges on the [PartialMmr]. | ||
/// 2. The new peaks. | ||
pub data: Vec<RpoDigest>, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use crate::merkle::MerkleError; | ||
use core::fmt::{Display, Formatter}; | ||
|
||
#[cfg(feature = "std")] | ||
use std::error::Error; | ||
|
||
#[derive(Debug, PartialEq, Eq, Clone)] | ||
pub enum MmrError { | ||
InvalidPosition(usize), | ||
InvalidPeaks, | ||
InvalidPeak, | ||
InvalidUpdate, | ||
UnknownPeak, | ||
MerkleError(MerkleError), | ||
} | ||
|
||
impl Display for MmrError { | ||
fn fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), core::fmt::Error> { | ||
match self { | ||
MmrError::InvalidPosition(pos) => write!(fmt, "Mmr does not contain position {pos}"), | ||
MmrError::InvalidPeaks => write!(fmt, "Invalid peaks count"), | ||
MmrError::InvalidPeak => { | ||
write!(fmt, "Peak values does not match merkle path computed root") | ||
} | ||
MmrError::InvalidUpdate => write!(fmt, "Invalid mmr update"), | ||
MmrError::UnknownPeak => { | ||
write!(fmt, "Peak not in Mmr") | ||
} | ||
MmrError::MerkleError(err) => write!(fmt, "{}", err), | ||
} | ||
} | ||
} | ||
|
||
#[cfg(feature = "std")] | ||
impl Error for MmrError {} |
Oops, something went wrong.