Skip to main content

Crate merkrs

Crate merkrs 

Source
Expand description

§merkrs

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

§Features

  • StandardMerkleTree — ABI-encoded Solidity values with double leaf hashing
  • SimpleMerkleTree — raw [u8; 32] values with single leaf hashing
  • Single-leaf and multi-proof generation / verification
  • Serialisation compatible with the OZ JavaScript standard-v1 / simple-v1 formats
  • Keccak-256 hashing (Ethereum compatible)

§Quick start

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

let values: Vec<Bytes32> = vec![[1u8; 32], [2u8; 32], [3u8; 32], [4u8; 32]];
let tree = SimpleMerkleTree::new(&values, simple::Options::default())?;

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

Re-exports§

pub use bytes::Bytes32;
pub use error::Error;
pub use error::Result;
pub use hashes::NodeHashFn;
pub use hashes::NodeHashKind;
pub use hashes::keccak256;
pub use hashes::standard_leaf_hash;
pub use hashes::standard_node_hash;
pub use merkle::LeafHasher;
pub use merkle::MerkleTree;
pub use simple::SimpleMerkleTree;
pub use simple::SimpleMerkleTreeData;
pub use standard::StandardMerkleTree;
pub use standard::StandardMerkleTreeData;
pub use tree::MultiProof;
pub use tree::MultiProofJson;

Modules§

bytes
32-byte hash values and hex-string conversion utilities.
error
Error types and the crate-level Result alias.
hashes
Keccak-256 hashing primitives.
merkle
Generic Merkle tree core and the LeafHasher trait.
simple
SimpleMerkleTree — Merkle tree over raw [u8; 32] values.
standard
StandardMerkleTree — Merkle tree over ABI-encoded Solidity values.
tree
Flat-array Merkle tree primitives shared by simple and standard trees.