| Crates.io | zerokit_utils |
| lib.rs | zerokit_utils |
| version | 0.6.0 |
| created_at | 2023-07-28 10:26:32.414384+00 |
| updated_at | 2025-06-05 09:23:51.251897+00 |
| description | Various utilities for Zerokit |
| homepage | https://vac.dev |
| repository | https://github.com/vacp2p/zerokit |
| max_upload_size | |
| id | 928402 |
| size | 451,549 |
Zerokit Utils provides essential cryptographic primitives optimized for zero-knowledge applications. This crate features efficient Merkle tree implementations and a Poseidon hash function, designed to be robust and performant.
This crate provides core cryptographic components optimized for zero-knowledge proof systems:
Merkle trees are fundamental data structures for verifying data integrity and set membership. Zerokit Utils offers two interchangeable implementations:
To better understand the structure and parameters of our Merkle trees, here's a quick glossary:
depth): level of leaves if we count from root.
If the root is at level 0, leaves are at level depth.depth + 1.Example for a tree with depth: 3:
Visual representation of a Merkle tree with depth: 3:
flowchart TD
A[Root] --> N1
A[Root] --> N2
N1 --> N3
N1 --> N4
N2 --> N5
N2 --> N6
N3 -->|Leaf| L1
N3 -->|Leaf| L2
N4 -->|Leaf| L3
N4 -->|Leaf| L4
N5 -->|Leaf| L5
N5 -->|Leaf| L6
N6 -->|Leaf| L7
N6 -->|Leaf| L8
FullMerkleTree
OptimalMerkleTree
Both OptimalMerkleTree and FullMerkleTree internally utilize the Rayon crate
to accelerate computations through data parallelism.
This can lead to significant performance improvements, particularly during updates to large Merkle trees.
This crate provides an implementation for computing Poseidon hash round constants and MDS matrices. Key characteristics include:
The MDS matrices used in the Poseidon hash function are generated iteratively using the Grain LFSR (Linear Feedback Shift Register) algorithm until specific cryptographic criteria are met.
skip_matrices parameter to the find_poseidon_ark_and_mds
function in this crate.Add zerokit-utils as a dependency to your Cargo.toml file:
[dependencies]
zerokit-utils = "0.6.0"
# Build the crate
cargo make build
# Run tests
cargo make test
# Run benchmarks
cargo make bench
To view the results of the benchmark, open the target/criterion/report/index.html file generated after the bench
The Merkle tree implementations are adapted from:
The Poseidon implementation references: