jmt::proof

Struct UpdateMerkleProof

Source
pub struct UpdateMerkleProof<H: SimpleHasher>(/* private fields */);

Implementations§

Source§

impl<H: SimpleHasher> UpdateMerkleProof<H>

Source

pub fn new(merkle_proofs: Vec<SparseMerkleProof<H>>) -> Self

Source

pub fn verify_update<V: AsRef<[u8]>>( self, old_root_hash: RootHash, new_root_hash: RootHash, updates: impl AsRef<[(KeyHash, Option<V>)]>, ) -> Result<()>

Verifies an update of the [JellyfishMerkleTree], proving the transition from an old_root_hash to a new_root_hash (RootHash) Multiple cases to handle:

  • Insert a tuple new_element_key, new_element_value
  • Update a tuple new_element_key, new_element_value
  • Delete the new_element_key This function does the following high level operations:
  1. Verify the Merkle path provided against the old_root_hash
  2. Use the provided Merkle path and the tuple (new_element_key, new_element_value) to compute the new Merkle path.
  3. Compare the new Merkle path against the new_root_hash If these steps are verified then the [JellyfishMerkleTree] has been soundly updated

This function consumes the Merkle proof to avoid uneccessary copying.

Trait Implementations§

Source§

impl<H> BorshDeserialize for UpdateMerkleProof<H>
where H: BorshDeserialize + SimpleHasher,

Source§

fn deserialize_reader<__R: Read>(reader: &mut __R) -> Result<Self, Error>

§

fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>

Deserializes this instance from a given slice of bytes. Updates the buffer to point at the remaining bytes.
§

fn try_from_slice(v: &[u8]) -> Result<Self, Error>

Deserialize this instance from a slice of bytes.
§

fn try_from_reader<R>(reader: &mut R) -> Result<Self, Error>
where R: Read,

Source§

impl<H> BorshSerialize for UpdateMerkleProof<H>
where H: BorshSerialize + SimpleHasher,

Source§

fn serialize<__W: Write>(&self, writer: &mut __W) -> Result<(), Error>

Source§

impl<H: Debug + SimpleHasher> Debug for UpdateMerkleProof<H>

Source§

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

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

impl<'de, H> Deserialize<'de> for UpdateMerkleProof<H>
where H: Deserialize<'de> + SimpleHasher,

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<H> Serialize for UpdateMerkleProof<H>

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

Auto Trait Implementations§

§

impl<H> Freeze for UpdateMerkleProof<H>

§

impl<H> RefUnwindSafe for UpdateMerkleProof<H>
where H: RefUnwindSafe,

§

impl<H> Send for UpdateMerkleProof<H>
where H: Send,

§

impl<H> Sync for UpdateMerkleProof<H>
where H: Sync,

§

impl<H> Unpin for UpdateMerkleProof<H>
where H: Unpin,

§

impl<H> UnwindSafe for UpdateMerkleProof<H>
where H: UnwindSafe,

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
Source§

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