Crate merkrs

Crate merkrs 

Source
Expand description

§merkrs

A Rust implementation of Merkle tree library, compatible with OpenZeppelin’s JavaScript implementation.

§Features

  • StandardMerkleTree: For structured data with ABI encoding (Solidity compatible)
  • SimpleMerkleTree: For simple bytes32 values
  • Full proof generation and verification
  • Multi-proof support
  • Serialization/deserialization with serde
  • Keccak256 hashing (Ethereum compatible)

§Example

use merkrs::{SimpleMerkleTree, SimpleMerkleTreeOptions, Bytes32};

let values: Vec<Bytes32> = vec![[1u8; 32], [2u8; 32], [3u8; 32], [4u8; 32]];
let tree = SimpleMerkleTree::of(&values, SimpleMerkleTreeOptions::default()).unwrap();

let proof = tree.get_proof(&values[0]).unwrap();
assert!(tree.verify_proof(&values[0], &proof).unwrap());

Re-exports§

pub use bytes::Bytes32;
pub use bytes::HexString;
pub use bytes::ToBytes32;
pub use core::MultiProof;
pub use error::MerkleTreeError;
pub use error::Result;
pub use hashes::NodeHashFn;
pub use hashes::keccak256;
pub use hashes::standard_leaf_hash;
pub use hashes::standard_node_hash;
pub use options::MerkleTreeOptions;
pub use simple::SimpleMerkleTree;
pub use simple::SimpleMerkleTreeData;
pub use simple::SimpleMerkleTreeOptions;
pub use standard::StandardMerkleTree;
pub use standard::StandardMerkleTreeData;

Modules§

bytes
core
error
hashes
options
simple
standard