aztec-nr - noir_aztec::utils::with_hash

Struct WithHash

pub struct WithHash<T, let M: u32>
{ /* private fields */ }

A struct that allows for efficient reading of value T from public storage in private.

The efficient reads are achieved by verifying large values through a single hash check and then proving inclusion only of the hash in public storage. This reduces the number of required tree inclusion proofs from M to 1.

Type Parameters

Implementations

impl<let M: u32, T> WithHash<T, M>

pub fn new(value: T) -> Self
where T: Packable<N = M>, T: Eq
pub fn get_value(self) -> T
where T: Packable<N = M>, T: Eq
pub fn get_hash(self) -> Field
where T: Packable<N = M>, T: Eq
pub fn public_storage_read(context: PublicContext, storage_slot: Field) -> T
where T: Packable<N = M>, T: Eq
pub unconstrained fn utility_public_storage_read( context: UtilityContext, storage_slot: Field, ) -> T
where T: Packable<N = M>, T: Eq
pub fn historical_public_storage_read( header: BlockHeader, address: AztecAddress, storage_slot: Field, ) -> T
where T: Packable<N = M>, T: Eq

Trait implementations

impl<let M: u32, T> Packable for WithHash<T, M>
where T: Packable<N = M>

pub fn pack(self) -> [Field; M + 1] pub fn unpack(packed: [Field; M + 1]) -> Self