pub struct StatePath<N: Network> { /* private fields */ }Expand description
The state path proves existence of the transition leaf to either a global or local state root.
Implementations§
Source§impl<N: Network> StatePath<N>
 
impl<N: Network> StatePath<N>
Sourcepub fn verify(&self, is_global: bool, local_state_root: Field<N>) -> Result<()>
 
pub fn verify(&self, is_global: bool, local_state_root: Field<N>) -> Result<()>
Checks if the state path is valid.
§Parameters
- local_state_rootis the local transaction root for the current execution.
- is_globalis a boolean indicating whether this is a global or local state root.
§Diagram
The [[ ]] notation is used to denote public inputs.
 [[ global_state_root ]]
          |
     block_path
         |
    block_hash := Hash( previous_block_hash || header_root )
                                                    |
                                               header_path
                                                   |
                                              header_leaf
                                                  |
                                           transactions_path          [[ local_state_root ]]
                                                 |                               |
                                              (true) ------ is_global ------ (false)
                                                                |
                                                         transaction_id
                                                               |
                                                       transaction_path
                                                              |
                                                      transaction_leaf
                                                             |
                                                     transition_id := Hash( transition_root || tcm )
                                                                                 |
                                                                          transition_path
                                                                                |
                                                                         transition_leafSource§impl<N: Network> StatePath<N>
 
impl<N: Network> StatePath<N>
Sourcepub fn new_local(
    global_state_root: N::StateRoot,
    local_state_root: N::TransactionID,
    transaction_path: TransactionPath<N>,
    transaction_leaf: TransactionLeaf<N>,
    transition_root: Field<N>,
    tcm: Field<N>,
    transition_path: TransitionPath<N>,
    transition_leaf: TransitionLeaf<N>,
) -> Result<Self>
 
pub fn new_local( global_state_root: N::StateRoot, local_state_root: N::TransactionID, transaction_path: TransactionPath<N>, transaction_leaf: TransactionLeaf<N>, transition_root: Field<N>, tcm: Field<N>, transition_path: TransitionPath<N>, transition_leaf: TransitionLeaf<N>, ) -> Result<Self>
Initializes a new instance of StatePath.
Sourcepub fn from(
    global_state_root: N::StateRoot,
    block_path: BlockPath<N>,
    block_hash: N::BlockHash,
    previous_block_hash: N::BlockHash,
    header_root: Field<N>,
    header_path: HeaderPath<N>,
    header_leaf: HeaderLeaf<N>,
    transactions_path: TransactionsPath<N>,
    transaction_id: N::TransactionID,
    transaction_path: TransactionPath<N>,
    transaction_leaf: TransactionLeaf<N>,
    transition_root: Field<N>,
    tcm: Field<N>,
    transition_path: TransitionPath<N>,
    transition_leaf: TransitionLeaf<N>,
) -> Self
 
pub fn from( global_state_root: N::StateRoot, block_path: BlockPath<N>, block_hash: N::BlockHash, previous_block_hash: N::BlockHash, header_root: Field<N>, header_path: HeaderPath<N>, header_leaf: HeaderLeaf<N>, transactions_path: TransactionsPath<N>, transaction_id: N::TransactionID, transaction_path: TransactionPath<N>, transaction_leaf: TransactionLeaf<N>, transition_root: Field<N>, tcm: Field<N>, transition_path: TransitionPath<N>, transition_leaf: TransitionLeaf<N>, ) -> Self
Initializes a new instance of StatePath.
Sourcepub const fn global_state_root(&self) -> N::StateRoot
 
pub const fn global_state_root(&self) -> N::StateRoot
Returns the global state root.
Sourcepub const fn block_path(&self) -> &BlockPath<N>
 
pub const fn block_path(&self) -> &BlockPath<N>
Returns the block path.
Sourcepub const fn block_hash(&self) -> N::BlockHash
 
pub const fn block_hash(&self) -> N::BlockHash
Returns the block hash.
Sourcepub const fn previous_block_hash(&self) -> N::BlockHash
 
pub const fn previous_block_hash(&self) -> N::BlockHash
Returns the previous block hash.
Sourcepub const fn header_root(&self) -> &Field<N>
 
pub const fn header_root(&self) -> &Field<N>
Returns the block header root.
Sourcepub const fn header_path(&self) -> &HeaderPath<N>
 
pub const fn header_path(&self) -> &HeaderPath<N>
Returns the header path.
Sourcepub const fn header_leaf(&self) -> &HeaderLeaf<N>
 
pub const fn header_leaf(&self) -> &HeaderLeaf<N>
Returns the header leaf.
Sourcepub const fn transactions_path(&self) -> &TransactionsPath<N>
 
pub const fn transactions_path(&self) -> &TransactionsPath<N>
Returns the transactions path.
Sourcepub const fn transaction_id(&self) -> &N::TransactionID
 
pub const fn transaction_id(&self) -> &N::TransactionID
Returns the transaction ID.
Sourcepub const fn transaction_path(&self) -> &TransactionPath<N>
 
pub const fn transaction_path(&self) -> &TransactionPath<N>
Returns the Merkle path for the transaction leaf.
Sourcepub const fn transaction_leaf(&self) -> &TransactionLeaf<N>
 
pub const fn transaction_leaf(&self) -> &TransactionLeaf<N>
Returns the transaction leaf.
Sourcepub const fn transition_root(&self) -> &Field<N>
 
pub const fn transition_root(&self) -> &Field<N>
Returns the transition root.
Sourcepub const fn transition_path(&self) -> &TransitionPath<N>
 
pub const fn transition_path(&self) -> &TransitionPath<N>
Returns the Merkle path for the transition leaf.
Sourcepub const fn transition_leaf(&self) -> &TransitionLeaf<N>
 
pub const fn transition_leaf(&self) -> &TransitionLeaf<N>
Returns the transition leaf.
Trait Implementations§
Source§impl<'de, N: Network> Deserialize<'de> for StatePath<N>
 
impl<'de, N: Network> Deserialize<'de> for StatePath<N>
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
 
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserializes the state path from a string or bytes.
Source§impl<N: Network> FromBytes for StatePath<N>
 
impl<N: Network> FromBytes for StatePath<N>
Source§fn from_bytes_le(bytes: &[u8]) -> Result<Self, Error>where
    Self: Sized,
 
fn from_bytes_le(bytes: &[u8]) -> Result<Self, Error>where
    Self: Sized,
Self from a byte array in little-endian order.Source§fn from_bytes_le_unchecked(bytes: &[u8]) -> Result<Self, Error>where
    Self: Sized,
 
fn from_bytes_le_unchecked(bytes: &[u8]) -> Result<Self, Error>where
    Self: Sized,
Self::from_bytes_le but avoids costly checks.
This shall only be called when deserializing from a trusted source, such as local storage. Read moreSource§fn read_le_unchecked<R>(reader: R) -> Result<Self, Error>
 
fn read_le_unchecked<R>(reader: R) -> Result<Self, Error>
Self::read_le but avoids costly checks.
This shall only be called when deserializing from a trusted source, such as local storage. Read moreSource§impl<N: Network> Parser for StatePath<N>
 
impl<N: Network> Parser for StatePath<N>
Source§fn parse(string: &str) -> ParserResult<'_, Self>
 
fn parse(string: &str) -> ParserResult<'_, Self>
Parses a string into the state path.
impl<N: Eq + Network> Eq for StatePath<N>
impl<N: Network> StructuralPartialEq for StatePath<N>
Auto Trait Implementations§
impl<N> Freeze for StatePath<N>
impl<N> RefUnwindSafe for StatePath<N>where
    <N as Network>::StateRoot: RefUnwindSafe,
    <N as Network>::BlockHash: RefUnwindSafe,
    <N as Network>::TransactionID: RefUnwindSafe,
    <N as Environment>::Field: RefUnwindSafe,
    N: RefUnwindSafe,
impl<N> Send for StatePath<N>
impl<N> Sync for StatePath<N>
impl<N> Unpin for StatePath<N>
impl<N> UnwindSafe for StatePath<N>where
    <N as Network>::StateRoot: UnwindSafe,
    <N as Network>::BlockHash: UnwindSafe,
    <N as Network>::TransactionID: UnwindSafe,
    <N as Environment>::Field: UnwindSafe,
    N: UnwindSafe,
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§impl<'de, T> DeserializeExt<'de> for Twhere
    T: DeserializeOwned,
 
impl<'de, T> DeserializeExt<'de> for Twhere
    T: DeserializeOwned,
fn take_from_value<D>(
    value: &mut Value,
    field: &str,
) -> Result<T, <D as Deserializer<'de>>::Error>where
    D: Deserializer<'de>,
Source§impl<Q, K> Equivalent<K> for Q
 
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
 
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
 
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
 
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
 
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
 
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
 
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
 
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
 
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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