Struct miden_objects::block::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: Digest,
block_num: u32,
chain_root: Digest,
account_root: Digest,
nullifier_root: Digest,
note_root: Digest,
tx_hash: Digest,
proof_hash: Digest,
timestamp: u32,
) -> Self
pub fn new( version: u32, prev_hash: Digest, block_num: u32, chain_root: Digest, account_root: Digest, nullifier_root: Digest, note_root: Digest, tx_hash: Digest, proof_hash: Digest, timestamp: u32, ) -> Self
Creates a new block header.
sourcepub fn sub_hash(&self) -> Digest
pub fn sub_hash(&self) -> Digest
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) -> Digest
pub fn chain_root(&self) -> Digest
Returns the chain root.
sourcepub fn account_root(&self) -> Digest
pub fn account_root(&self) -> Digest
Returns the account database root.
sourcepub fn nullifier_root(&self) -> Digest
pub fn nullifier_root(&self) -> Digest
Returns the nullifier database root.
sourcepub fn tx_hash(&self) -> Digest
pub fn tx_hash(&self) -> Digest
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) -> Digest
pub fn proof_hash(&self) -> Digest
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: ByteReader>(
source: &mut R,
) -> Result<Self, DeserializationError>
fn read_from<R: ByteReader>( source: &mut R, ) -> Result<Self, DeserializationError>
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 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: ByteWriter>(&self, target: &mut W)
fn write_into<W: ByteWriter>(&self, target: &mut W)
self into bytes and writes these bytes into the target.source§fn get_size_hint(&self) -> usize
fn get_size_hint(&self) -> usize
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)