merkrs 0.1.1

Merkle tree library for Rust, compatible with OpenZeppelin's JavaScript implementation
Documentation

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());