Realm

oa::crypto::merkle

Module published by the oa::crypto module.

MdRust public API

Public Types

Public Functions

pub fn build( leaves: &Matrix, algorithm: MerkleAlgorithm, ) -> Result<DeviceMerkleTree>
pub fn proofs(tree: &DeviceMerkleTree, indices: &Matrix) -> Result<Matrix>
pub fn subtree_roots( leaves: &Matrix, algorithm: MerkleAlgorithm, subtree_leaves: usize, ) -> Result<Matrix>
pub fn verify( leaves: &Matrix, frames: &Matrix, roots: &Matrix, algorithm: MerkleAlgorithm, leaf_count: u32, ) -> Result<Matrix>

Function Documentation

pub fn build( leaves: &Matrix, algorithm: MerkleAlgorithm ) -> Result<DeviceMerkleTree>
Build retained device tree levels using the selected parent hash. Leaves are prehashed U8/U32 rows with the algorithm’s exact digest extent. Poseidon2 nodes use OA’s versioned field framing, not NVIDIA wire semantics. Errors Rejects dtype, rank, extent, leaf count, allocation or recording failures.
pub fn proofs( tree: &DeviceMerkleTree, indices: &Matrix ) -> Result<Matrix>
Produce version-two inclusion frames for U32 [batch] leaf indices. Frames carry the original count, index, hash identity and validity flag. Out-of-range indices produce invalid, completely zero sibling paths. Errors Rejects dtype, rank, ownership, address limits, allocation or recording failures.
pub fn subtree_roots( leaves: &Matrix, algorithm: MerkleAlgorithm, subtree_leaves: usize ) -> Result<Matrix>
Compute roots of contiguous power-of-two subtrees for hierarchical construction. Records the first log2(subtree_leaves) tree levels. The returned rows can be passed to build to finish the tree; no leaf readback/repacking is involved. Errors Rejects dtype, rank, extent, partition sizes, allocation or recording failures.
pub fn verify( leaves: &Matrix, frames: &Matrix, roots: &Matrix, algorithm: MerkleAlgorithm, leaf_count: u32 ) -> Result<Matrix>
Verify inclusion frames against roots and an independently trusted leaf count. Roots may contain one shared digest or one digest per proof. Malformed headers, identity/count mismatches and changed sibling paths return zero. Errors Rejects metadata, ownership, address limits, allocation or recording failures.