33 releases (19 breaking)

0.23.0 May 19, 2023
0.22.1 Sep 16, 2022
0.22.0 Jun 21, 2022
0.21.0 Jul 17, 2020
0.7.1 Jul 1, 2019

#288 in Cryptography

Download history 1230/week @ 2023-12-13 764/week @ 2023-12-20 641/week @ 2023-12-27 1526/week @ 2024-01-03 1805/week @ 2024-01-10 2353/week @ 2024-01-17 2307/week @ 2024-01-24 1659/week @ 2024-01-31 1570/week @ 2024-02-07 2384/week @ 2024-02-14 2319/week @ 2024-02-21 2447/week @ 2024-02-28 1886/week @ 2024-03-06 3007/week @ 2024-03-13 2432/week @ 2024-03-20 1289/week @ 2024-03-27

9,259 downloads per month
Used in 45 crates (11 directly)

BSD-3-Clause

255KB
5.5K SLoC

merkle

Build Status Issues License

merkle is a lightweight Rust implementation of a Merkle tree.

Features

  • external dependency agnostic
  • std::hash::Hasher compatibility
  • standard types hasher implementations
  • #[derive(Hashable)] support for simple struct
  • customizable merkle leaf/node hashing algorithm
  • support for custom hash types (e.g. [u8; 16], [u64; 4], [u128; 2], struct)
  • customizable hashing algorithm
  • linear memory layout, no nodes on heap
  • buildable from iterator, objects or hashes
  • certificate transparency style merkle hashing support
  • SPV support included (via proof type)
  • supports power of 2 arity merkletrees (only)
  • supports compound merkletrees (a tree of merkletrees)
  • supports compound-compound merkletrees (a tree of compound merkletrees)

Documentation

Documentation is available.

Examples

The most relevant examples are located in the following files:

  • test_common.rs: custom hash example xor128, misc shared utils
  • test_xor128.rs: most comprehensive tests for library features
  • proof.rs: contains impl and tests for proofs across pow2 arity trees

Building and testing

# Run tests in release mode
cargo test --release --all

# Run ignored tests in release mode
cargo test --release --all -- --ignored

Bug Reporting

Please report bugs either as pull requests or as issues in the issue tracker. merkle has a full disclosure vulnerability policy. Please do NOT attempt to report any security vulnerability in this code privately to anybody.

License

See LICENSE.

Dependencies

~4–14MB
~175K SLoC