merkrs 0.2.0

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

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::{SimpleMerkleTree, simple::Options, Bytes32};

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

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