CryptoStableHasher

Struct CryptoStableHasher 

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

Based on https://crypto.stackexchange.com/a/54546

The idea here is to use the FieldAddress to unambiguously identify each field as within it’s own database cell, and use an online order-independent aggregator of the cells to produce a final result.

Within this framework a huge struct can be hashed incrementally or even in parallel as long as field addresses are deterministically produced to uniquely identify parts within the struct. Conveniently, the FieldAddress::skip method can be used to jump to parts of a vec or struct efficiently.

Trait Implementations§

Source§

impl Clone for CryptoStableHasher

Source§

fn clone(&self) -> CryptoStableHasher

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 Debug for CryptoStableHasher

Source§

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

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

impl Default for CryptoStableHasher

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for CryptoStableHasher

Source§

fn eq(&self, other: &CryptoStableHasher) -> 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 StableHasher for CryptoStableHasher

Source§

fn from_bytes(bytes: Vec<u8>) -> Self

Panics if the bytes are not in a valid format. The only valid values are values returned from to_bytes()

Source§

type Out = [u8; 32]

The type of value returned when finishing
Source§

type Addr = CryptoAddress

The type used when identifying where a value is located in a struct
Source§

type Bytes = Vec<u8>

Used when serializing
Source§

fn new() -> Self

Create an empty hasher
Source§

fn write(&mut self, field_address: Self::Addr, bytes: &[u8])

Add a single field to the hash
Source§

fn mixin(&mut self, other: &Self)

Adds all fields from another hasher
Source§

fn unmix(&mut self, other: &Self)

Removes all fields from another hasher
Source§

fn finish(&self) -> Self::Out

Finalize the digest
Source§

fn to_bytes(&self) -> Self::Bytes

Serialize
Source§

impl Eq for CryptoStableHasher

Source§

impl StructuralPartialEq for CryptoStableHasher

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