Struct miden_client::blocks::BlockHeader
source · pub struct BlockHeader { /* private fields */ }Expand description
The header of a block. It contains metadata about the block, commitments to the current state of the chain and the hash of the proof that attests to the integrity of the chain.
A block header includes the following fields:
versionspecifies the version of the protocol.prev_hashis the hash of the previous block header.block_numis a unique sequential number of the current block.chain_rootis a commitment to an MMR of the entire chain where each block is a leaf.account_rootis a commitment to account database.nullifier_rootis a commitment to the nullifier database.note_rootis a commitment to all notes created in the current block.tx_hashis a commitment to a set of IDs of transactions which affected accounts in the block.proof_hashis a hash of a STARK proof attesting to the correct state transition.timestampis the time when the block was created, in seconds since UNIX epoch. Current representation is sufficient to represent time up to year 2106.sub_hashis a sequential hash of all fields except the note_root.hashis a 2-to-1 hash of the sub_hash and the note_root.
Implementations§
source§impl BlockHeader
impl BlockHeader
sourcepub fn new(
version: u32,
prev_hash: RpoDigest,
block_num: u32,
chain_root: RpoDigest,
account_root: RpoDigest,
nullifier_root: RpoDigest,
note_root: RpoDigest,
tx_hash: RpoDigest,
proof_hash: RpoDigest,
timestamp: u32,
) -> BlockHeader
pub fn new( version: u32, prev_hash: RpoDigest, block_num: u32, chain_root: RpoDigest, account_root: RpoDigest, nullifier_root: RpoDigest, note_root: RpoDigest, tx_hash: RpoDigest, proof_hash: RpoDigest, timestamp: u32, ) -> BlockHeader
Creates a new block header.
sourcepub fn sub_hash(&self) -> RpoDigest
pub fn sub_hash(&self) -> RpoDigest
Returns the sub hash of the block header. The sub hash is a sequential hash of all block header fields except the note root. This is used in the block hash computation which is a 2-to-1 hash of the sub hash and the note root [hash(sub_hash, note_root)]. This procedure is used to make the note root easily accessible without having to unhash the entire header.
sourcepub fn chain_root(&self) -> RpoDigest
pub fn chain_root(&self) -> RpoDigest
Returns the chain root.
sourcepub fn account_root(&self) -> RpoDigest
pub fn account_root(&self) -> RpoDigest
Returns the account database root.
sourcepub fn nullifier_root(&self) -> RpoDigest
pub fn nullifier_root(&self) -> RpoDigest
Returns the nullifier database root.
sourcepub fn tx_hash(&self) -> RpoDigest
pub fn tx_hash(&self) -> RpoDigest
Returns the commitment to all transactions in this block.
The commitment is computed as sequential hash of (transaction_id, account_id) tuples. This
makes it possible for the verifier to link transaction IDs to the accounts which they were
executed against.
sourcepub fn proof_hash(&self) -> RpoDigest
pub fn proof_hash(&self) -> RpoDigest
Returns the proof hash.
Trait Implementations§
source§impl Clone for BlockHeader
impl Clone for BlockHeader
source§fn clone(&self) -> BlockHeader
fn clone(&self) -> BlockHeader
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for BlockHeader
impl Debug for BlockHeader
source§impl Deserializable for BlockHeader
impl Deserializable for BlockHeader
source§fn read_from<R>(source: &mut R) -> Result<BlockHeader, DeserializationError>where
R: ByteReader,
fn read_from<R>(source: &mut R) -> Result<BlockHeader, DeserializationError>where
R: ByteReader,
source, attempts to deserialize these bytes
into Self, and returns the result. Read moresource§fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>
fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>
source§impl<'de> Deserialize<'de> for BlockHeader
impl<'de> Deserialize<'de> for BlockHeader
source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<BlockHeader, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<BlockHeader, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
source§impl PartialEq for BlockHeader
impl PartialEq for BlockHeader
source§fn eq(&self, other: &BlockHeader) -> bool
fn eq(&self, other: &BlockHeader) -> bool
self and other values to be equal, and is used
by ==.source§impl Serializable for BlockHeader
impl Serializable for BlockHeader
source§fn write_into<W>(&self, target: &mut W)where
W: ByteWriter,
fn write_into<W>(&self, target: &mut W)where
W: ByteWriter,
self into bytes and writes these bytes into the target.source§fn get_size_hint(&self) -> usize
fn get_size_hint(&self) -> usize
source§impl Serialize for BlockHeader
impl Serialize for BlockHeader
source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Copy for BlockHeader
impl Eq for BlockHeader
impl StructuralPartialEq for BlockHeader
Auto Trait Implementations§
impl Freeze for BlockHeader
impl RefUnwindSafe for BlockHeader
impl Send for BlockHeader
impl Sync for BlockHeader
impl Unpin for BlockHeader
impl UnwindSafe for BlockHeader
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)