oa::cryptography

cryptography module in the OA Crypto public surface.

MdRust public API

Public Types

Public Functions

pub fn build_merkle_tree(leaves: &[Hash]) -> MerkleTree
pub fn hash(input: &[u8]) -> Hash
pub fn hash_combine(left: &Hash, right: &Hash) -> Hash
pub fn keccak_f1600(state: &mut [u64; 25])
pub fn kmac256( key: &[u8], data: &[u8], customization: &[u8], output_len: usize, ) -> Result<Vec<u8>>
pub fn merkle_proof(tree: &MerkleTree, leaf_index: usize) -> Result<MerkleProof>
pub fn merkle_root(leaves: &[Hash]) -> Hash
pub fn shake128(input: &[u8], output: &mut [u8])
pub fn shake256(input: &[u8], output: &mut [u8])
pub fn verify_merkle_proof( leaf: &Hash, proof: &MerkleProof, root: &Hash, ) -> bool

Function Documentation

pub fn build_merkle_tree( leaves: &[Hash] ) -> MerkleTree
Build a materialized Merkle tree.
pub fn hash( input: &[u8] ) -> Hash
Compute the canonical 32-byte SHAKE-256 digest.
pub fn hash_combine( left: &Hash, right: &Hash ) -> Hash
Combine two Merkle nodes as SHAKE-256(left || right).
pub fn keccak_f1600( state: &mut [u64; 25] )
Apply the 24-round Keccak-f[1600] permutation in place.
pub fn kmac256( key: &[u8], data: &[u8], customization: &[u8], output_len: usize ) -> Result<Vec<u8>>
Compute KMAC-256 according to NIST SP 800-185. Errors Returns an error when a bit length, encoded length, or allocation size overflows the platform or SP 800-185 u64 encoding.
pub fn merkle_proof( tree: &MerkleTree, leaf_index: usize ) -> Result<MerkleProof>
Construct the inclusion proof for one leaf. Errors Returns an error for an empty tree or an out-of-range leaf index.
pub fn merkle_root( leaves: &[Hash] ) -> Hash
Compute the Merkle root, duplicating the final node of each odd level.
pub fn shake128( input: &[u8], output: &mut [u8] )
Produce SHAKE-128 output of exactly output.len() bytes.
pub fn shake256( input: &[u8], output: &mut [u8] )
Produce SHAKE-256 output of exactly output.len() bytes.
pub fn verify_merkle_proof( leaf: &Hash, proof: &MerkleProof, root: &Hash ) -> bool
Verify one Merkle inclusion proof against root.