Skip to content

refactor(PR 13): clean generic hash for all zerokit's module (prepare for future PoseidonHash2)#424

Merged
vinhtc27 merged 6 commits into
develop/v3.0.0from
refactor/pr13-generic-hash
Jul 9, 2026
Merged

refactor(PR 13): clean generic hash for all zerokit's module (prepare for future PoseidonHash2)#424
vinhtc27 merged 6 commits into
develop/v3.0.0from
refactor/pr13-generic-hash

Conversation

@vinhtc27

@vinhtc27 vinhtc27 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Changes:

  • replaced legacy Hasher/RLNHasher with generic ZerokitHasher
  • refactored RLN hashing into generic Hasher facade
  • made Groth16 backend and ZK proof generic over hashers
  • simplified identity key API and add canonical serialization
  • updated Merkle tree, PM tree, FFI, WASM and CLI to new hashing API
  • removed legacy hash helpers and obsolete APIs
  • aligned core, wasm and ffi to allow future PoseidonHash2 extend

@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown

Benchmark for 7a3cd66

Click to view benchmark
Test Base PR %
FullMerkleProof::compute_root_from 9.6±0.13µs 9.5±0.44µs -1.04%
FullMerkleTree::delete 20.6±0.54µs 21.3±0.22µs +3.40%
FullMerkleTree::get 0.9±0.01ns 0.9±0.03ns 0.00%
FullMerkleTree::get_empty_leaves_indices 1571.9±32.37µs 1579.5±33.88µs +0.48%
FullMerkleTree::get_subtree_root 10.9±0.10ns 10.8±0.17ns -0.92%
FullMerkleTree::override_range 2.1±0.02ms 2.1±0.02ms 0.00%
FullMerkleTree::proof 91.9±3.43ns 121.0±6.61ns +31.66%
FullMerkleTree::set 10.1±0.17µs 10.5±0.20µs +3.96%
FullMerkleTree::set_range 2.1±0.02ms 2.0±0.02ms -4.76%
FullMerkleTree::update_next 10.2±0.46µs 10.6±0.27µs +3.92%
FullMerkleTree::verify 9.6±0.23µs 9.5±0.18µs -1.04%
OptimalMerkleProof::compute_root_from 9.6±0.15µs 9.6±0.32µs 0.00%
OptimalMerkleTree::delete 23.7±0.83µs 23.8±0.75µs +0.42%
OptimalMerkleTree::get 38.2±2.41ns 37.7±2.57ns -1.31%
OptimalMerkleTree::get_empty_leaves_indices 1110.1±9.94µs 1111.9±21.79µs +0.16%
OptimalMerkleTree::get_subtree_root 25.8±0.76ns 25.4±0.30ns -1.55%
OptimalMerkleTree::override_range 4.9±0.14ms 4.8±0.08ms -2.04%
OptimalMerkleTree::proof 583.6±57.97ns 628.8±51.36ns +7.75%
OptimalMerkleTree::set 12.2±0.90µs 12.1±0.51µs -0.82%
OptimalMerkleTree::set_range 4.6±0.19ms 4.9±0.20ms +6.52%
OptimalMerkleTree::update_next 12.1±0.47µs 12.4±0.75µs +2.48%
OptimalMerkleTree::verify 9.6±0.13µs 9.7±0.43µs +1.04%
Poseidon::hash/10 151.8±1.74µs 64.3 KElem/sec N/A N/A
Poseidon::hash/100 1583.7±18.51µs 61.7 KElem/sec N/A N/A
Poseidon::hash/1000 16.8±0.24ms 58.2 KElem/sec N/A N/A
Poseidon::hash/single 15.2±0.18µs 62.8 MElem/sec N/A N/A

@vinhtc27
vinhtc27 requested a review from sydhds July 6, 2026 14:39
@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown

Benchmark for 7a3cd66

Click to view benchmark
Test Base PR %
PmTree::delete 1533.0±40.67µs 1554.6±17.28µs +1.41%
PmTree::get 513.5±12.44ns 584.7±44.81ns +13.87%
PmTree::get_empty_leaves_indices 61.4±0.82µs 61.6±1.03µs +0.33%
PmTree::get_subtree_root 388.6±5.56ns 383.1±6.43ns -1.42%
PmTree::override_range 131.5±3.64ms 134.5±3.87ms +2.28%
PmTree::proof 9.4±0.23µs 9.2±0.27µs -2.13%
PmTree::set 760.0±32.61µs 769.3±12.00µs +1.22%
PmTree::set_range 124.8±3.91ms 126.5±3.86ms +1.36%
PmTree::update_next 6.8±3.68ms 6.9±3.74ms +1.47%
PmTree::verify 505.8±7.08µs 517.5±3.90µs +2.31%
PmTreeProof::compute_root_from 504.5±2.88µs 516.8±3.66µs +2.44%
RLN::finish_proof 68.8±0.97ms 69.1±2.48ms +0.44%
RLN::generate_partial_proof 128.8±1.54ms 128.4±3.39ms -0.31%
RLN::generate_proof 186.7±1.64ms 186.4±1.83ms -0.16%

Comment thread utils/src/hasher.rs Outdated
Comment thread utils/src/hasher.rs Outdated
/// Defines the interface for a hash function over a prime field, used by all zerokit modules.
pub trait ZerokitHasher {
/// Type of the hashed elements, also used as the Merkle tree node type.
type Fr: Clone + Copy + Eq + Default + Debug + Display + FromStr + Send + Sync;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please find another name because the name "Fr" conflicts with the ark type Fr here.
I don't think we need so many trait bounds no?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a particular need to the trait bounds here? You restricted the set but it still seems to me that we don't need any no?

@vinhtc27 vinhtc27 Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, each one has its use, you can check by removing any of them, the compiler will tell you to put it back

  • Copy: tree nodes are passed around by value everywhere (root(), sibling reads, H::hash(&[left, right]))
  • PartialEq: verify() compares the recomputed root with the stored one
  • Default: ZerokitMerkleTree::default(depth) uses Scalar::default() as the empty-leaf value
  • Debug: the tree and proof types derive Debug
  • Send + Sync: the rayon parallel hashing path sends nodes across threads

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So at the end, you need those trait bounds because you are defining MerkleTree<H: ZerokitHasher> but this would not be the case if you would defined MerkleTree<T, H> where T: Copy, ... , H: Hasher wdyt?

@vinhtc27 vinhtc27 Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if you make the type T separate, you still need T to match the Scalar type in in fn hash():

pub trait ZerokitHasher {
    type Scalar;
    fn hash(input: &[Self::Scalar]) -> Self::Scalar;
}

And this would make the call site look like this:

let tree = FullMerkleTree::<Fr, PoseidonHash>::default(20)?;

So I'd say the current implementation is much cleaner for the call site.

let tree = FullMerkleTree::<PoseidonHash>::default(20)?;

@sydhds sydhds Jul 8, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is let tree = FullMerkleTree::<PoseidonHash>::default(20)?; cleaner than let tree = FullMerkleTree::<Fr, PoseidonHash>::default(20)?;

The later shows, I want a MerkleTree storing Fr types and with PoseidonHash so it clearly states the intent of the dev. Also adding trait bounds for the trait Hasher makes no sense because the trait is meant for dev to impl it.

Also another problem of those trait bounds, is that you cannot impl Hasher for SecretFr and that should not be the case no?

@vinhtc27 vinhtc27 Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok so to resolve this:

  • I removed all the bounds from ZerokitHasher (type Scalar; is now just bare). The tree types add the bounds they actually need with where H::Scalar: ..., you right about this one, cleaner split.
  • Scalar = SecretFr still isn't allowed as a tree node, but that's intentional. Tree nodes are public commitments, while SecretFr is deliberately !Copy so secrets can't accidentally make their way into the generic tree/hash code.
  • For <T, H>, each hasher already determines exactly one scalar type, so adding a separate T would just duplicate information the compiler already knows. I'd keep the single-parameter API.

@sydhds sydhds Jul 8, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't understand why you don't want to add the generic T? Any particular reason for this? It does improve the intent as already mentioned but you rejected it without any reason...

@vinhtc27 vinhtc27 Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason I prefer the single-parameter API is that Scalar isn't an independent choice, it's determined by H through the associated type. Any <T, H> design would still need H: ZerokitHasher<Scalar = T>, so T is always duplicate information that H already carries.

One consequence is that a two-parameter API allows expressing combinations that are invalid like:

let tree = FullMerkleTree::<WrongFr, PoseidonHash>::default(20)?;

But PoseidonHash already defines its scalar type:

impl ZerokitHasher for PoseidonHash {
    type Scalar = Fr;
}

We can definitely make PoseidonHash generic over any field element type as well, but that's outside the scope of this refactor, since entire codebase is still use arkworks types (Fr, and SecretFr wrapper).

Comment thread rln/src/hashers.rs Outdated
Comment thread rln/src/hashers.rs Outdated
Comment thread rln/src/hashers.rs
@vinhtc27
vinhtc27 requested a review from sydhds July 7, 2026 07:14
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown

Benchmark for 0975ccd

Click to view benchmark
Test Base PR %
FullMerkleProof::compute_root_from 8.5±0.06µs 8.4±0.11µs -1.18%
FullMerkleTree::delete 18.3±0.31µs 18.2±0.68µs -0.55%
FullMerkleTree::get 0.8±0.00ns 0.8±0.01ns 0.00%
FullMerkleTree::get_empty_leaves_indices 1320.8±24.24µs 1407.8±86.30µs +6.59%
FullMerkleTree::get_subtree_root 9.9±0.08ns 10.0±0.25ns +1.01%
FullMerkleTree::override_range 1914.5±40.12µs 1894.2±49.61µs -1.06%
FullMerkleTree::proof 87.5±1.58ns 89.0±2.31ns +1.71%
FullMerkleTree::set 9.1±0.11µs 9.0±0.20µs -1.10%
FullMerkleTree::set_range 1895.1±48.29µs 1863.8±43.31µs -1.65%
FullMerkleTree::update_next 9.1±0.14µs 8.9±0.18µs -2.20%
FullMerkleTree::verify 8.5±0.07µs 8.4±0.26µs -1.18%
OptimalMerkleProof::compute_root_from 8.5±0.17µs 8.4±0.12µs -1.18%
OptimalMerkleTree::delete 21.3±0.34µs 21.2±0.38µs -0.47%
OptimalMerkleTree::get 53.1±0.89ns 53.2±1.05ns +0.19%
OptimalMerkleTree::get_empty_leaves_indices 983.9±7.49µs 984.0±6.00µs +0.01%
OptimalMerkleTree::get_subtree_root 26.3±0.36ns 26.4±1.02ns +0.38%
OptimalMerkleTree::override_range 4.6±0.29ms 4.6±0.30ms 0.00%
OptimalMerkleTree::proof 698.0±45.27ns 680.1±21.90ns -2.56%
OptimalMerkleTree::set 10.8±0.20µs 10.7±0.21µs -0.93%
OptimalMerkleTree::set_range 5.2±0.34ms 5.0±0.27ms -3.85%
OptimalMerkleTree::update_next 11.0±0.64µs 10.9±0.61µs -0.91%
OptimalMerkleTree::verify 8.6±0.07µs 8.4±0.08µs -2.33%
Poseidon::hash/10 139.5±0.14µs 70.0 KElem/sec N/A N/A
Poseidon::hash/100 1498.1±7.91µs 65.2 KElem/sec N/A N/A
Poseidon::hash/1000 15.1±0.01ms 64.7 KElem/sec N/A N/A
Poseidon::hash/single 13.8±0.01µs 68.9 MElem/sec N/A N/A

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown

Benchmark for 0975ccd

Click to view benchmark
Test Base PR %
PmTree::delete 1522.5±12.89µs 1531.6±14.22µs +0.60%
PmTree::get 520.7±8.61ns 503.0±9.40ns -3.40%
PmTree::get_empty_leaves_indices 61.4±0.85µs 61.4±1.00µs 0.00%
PmTree::get_subtree_root 387.5±5.60ns 394.3±8.04ns +1.75%
PmTree::override_range 128.2±3.32ms 127.0±3.18ms -0.94%
PmTree::proof 9.3±0.19µs 8.9±0.17µs -4.30%
PmTree::set 749.0±6.44µs 766.1±7.95µs +2.28%
PmTree::set_range 120.4±3.14ms 121.0±3.33ms +0.50%
PmTree::update_next 6.8±3.67ms 6.7±3.65ms -1.47%
PmTree::verify 501.0±5.45µs 516.2±4.80µs +3.03%
PmTreeProof::compute_root_from 502.7±5.23µs 517.4±3.96µs +2.92%
RLN::finish_proof 68.6±2.25ms 68.6±0.96ms 0.00%
RLN::generate_partial_proof 128.6±1.25ms 128.2±2.82ms -0.31%
RLN::generate_proof 187.0±1.88ms 186.1±1.85ms -0.48%

Comment thread rln/src/hashers.rs
Comment thread rln/src/hashers.rs
Comment thread rln/src/protocol/zk.rs
Comment thread rln/src/protocol/witness.rs
Comment thread rln/src/protocol/secret.rs
Comment thread rln/src/protocol/secret.rs
Comment thread rln/src/protocol/keygen.rs Outdated
Comment thread rln/src/protocol/keygen.rs Outdated
@vinhtc27
vinhtc27 requested a review from sydhds July 7, 2026 13:01
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown

Benchmark for 150fe1c

Click to view benchmark
Test Base PR %
FullMerkleProof::compute_root_from 9.6±0.11µs 9.5±0.07µs -1.04%
FullMerkleTree::delete 20.8±0.43µs 20.6±0.34µs -0.96%
FullMerkleTree::get 0.9±0.01ns 0.9±0.01ns 0.00%
FullMerkleTree::get_empty_leaves_indices 1569.4±21.58µs 1569.9±22.65µs +0.03%
FullMerkleTree::get_subtree_root 10.9±0.07ns 10.8±0.18ns -0.92%
FullMerkleTree::override_range 2.1±0.02ms 2.1±0.02ms 0.00%
FullMerkleTree::proof 89.0±0.99ns 90.6±0.91ns +1.80%
FullMerkleTree::set 10.2±0.15µs 10.2±0.16µs 0.00%
FullMerkleTree::set_range 2.1±0.04ms 2.1±0.01ms 0.00%
FullMerkleTree::update_next 10.3±0.23µs 10.2±0.33µs -0.97%
FullMerkleTree::verify 9.6±0.23µs 9.5±0.25µs -1.04%
OptimalMerkleProof::compute_root_from 9.6±0.19µs 9.5±0.23µs -1.04%
OptimalMerkleTree::delete 23.9±0.42µs 23.6±0.34µs -1.26%
OptimalMerkleTree::get 36.5±0.54ns 36.5±0.83ns 0.00%
OptimalMerkleTree::get_empty_leaves_indices 1111.3±11.32µs 1111.6±11.82µs +0.03%
OptimalMerkleTree::get_subtree_root 25.6±0.50ns 25.3±0.38ns -1.17%
OptimalMerkleTree::override_range 4.2±0.20ms 4.5±0.14ms +7.14%
OptimalMerkleTree::proof 573.1±17.98ns 580.2±33.89ns +1.24%
OptimalMerkleTree::set 12.0±0.21µs 12.2±0.71µs +1.67%
OptimalMerkleTree::set_range 4.2±0.18ms 4.0±0.16ms -4.76%
OptimalMerkleTree::update_next 12.2±0.52µs 12.2±0.47µs 0.00%
OptimalMerkleTree::verify 9.6±0.11µs 9.5±0.07µs -1.04%
Poseidon::hash/10 151.0±0.17µs 64.7 KElem/sec N/A N/A
Poseidon::hash/100 1585.8±14.56µs 61.6 KElem/sec N/A N/A
Poseidon::hash/1000 16.7±0.09ms 58.6 KElem/sec N/A N/A
Poseidon::hash/single 15.1±0.02µs 63.0 MElem/sec N/A N/A

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown

Benchmark for 150fe1c

Click to view benchmark
Test Base PR %
PmTree::delete 1522.0±13.02µs 1539.6±13.97µs +1.16%
PmTree::get 515.9±19.83ns 501.5±15.94ns -2.79%
PmTree::get_empty_leaves_indices 61.4±0.86µs 61.4±0.86µs 0.00%
PmTree::get_subtree_root 396.5±10.89ns 387.1±4.88ns -2.37%
PmTree::override_range 127.4±3.58ms 127.5±3.70ms +0.08%
PmTree::proof 9.3±0.25µs 9.1±0.16µs -2.15%
PmTree::set 749.0±6.99µs 764.6±16.07µs +2.08%
PmTree::set_range 120.6±4.10ms 120.0±3.85ms -0.50%
PmTree::update_next 6.7±3.67ms 6.8±3.68ms +1.49%
PmTree::verify 496.5±4.61µs 521.3±12.69µs +4.99%
PmTreeProof::compute_root_from 498.0±7.74µs 518.7±5.59µs +4.16%
RLN::finish_proof 68.2±0.88ms 68.6±1.07ms +0.59%
RLN::generate_partial_proof 129.0±1.36ms 128.3±2.72ms -0.54%
RLN::generate_proof 187.8±7.49ms 186.6±2.54ms -0.64%

@vinhtc27
vinhtc27 force-pushed the refactor/pr13-generic-hash branch from 1db3048 to 428454e Compare July 7, 2026 16:08
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown

Benchmark for 99e8499

Click to view benchmark
Test Base PR %
FullMerkleProof::compute_root_from 9.5±0.24µs 9.5±0.15µs 0.00%
FullMerkleTree::delete 20.6±0.55µs 21.2±0.23µs +2.91%
FullMerkleTree::get 0.9±0.01ns 0.9±0.02ns 0.00%
FullMerkleTree::get_empty_leaves_indices 1570.0±20.15µs 1570.4±15.03µs +0.03%
FullMerkleTree::get_subtree_root 10.9±0.18ns 10.8±0.18ns -0.92%
FullMerkleTree::override_range 2.1±0.03ms 2.1±0.03ms 0.00%
FullMerkleTree::proof 90.4±0.93ns 90.0±0.94ns -0.44%
FullMerkleTree::set 10.1±0.16µs 10.5±0.07µs +3.96%
FullMerkleTree::set_range 2.1±0.03ms 2.1±0.02ms 0.00%
FullMerkleTree::update_next 10.2±0.19µs 10.5±0.13µs +2.94%
FullMerkleTree::verify 9.6±0.22µs 9.5±0.12µs -1.04%
OptimalMerkleProof::compute_root_from 9.5±0.15µs 9.5±0.13µs 0.00%
OptimalMerkleTree::delete 23.5±0.27µs 23.6±0.60µs +0.43%
OptimalMerkleTree::get 36.4±0.85ns 37.7±2.54ns +3.57%
OptimalMerkleTree::get_empty_leaves_indices 1115.6±37.03µs 1113.9±35.35µs -0.15%
OptimalMerkleTree::get_subtree_root 24.8±0.43ns 26.4±2.40ns +6.45%
OptimalMerkleTree::override_range 4.1±0.15ms 4.6±0.16ms +12.20%
OptimalMerkleTree::proof 566.5±5.84ns 568.6±10.28ns +0.37%
OptimalMerkleTree::set 11.8±0.35µs 11.8±0.31µs 0.00%
OptimalMerkleTree::set_range 4.3±0.23ms 4.0±0.13ms -6.98%
OptimalMerkleTree::update_next 12.1±0.47µs 12.2±0.51µs +0.83%
OptimalMerkleTree::verify 9.6±0.24µs 9.6±0.28µs 0.00%
Poseidon::hash/10 153.0±1.42µs 63.8 KElem/sec N/A N/A
Poseidon::hash/100 1596.7±13.33µs 61.2 KElem/sec N/A N/A
Poseidon::hash/1000 16.8±0.08ms 58.0 KElem/sec N/A N/A
Poseidon::hash/single 15.4±0.81µs 61.7 MElem/sec N/A N/A

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown

Benchmark for 99e8499

Click to view benchmark
Test Base PR %
PmTree::delete 1546.4±11.40µs 1558.8±12.14µs +0.80%
PmTree::get 537.9±20.54ns 502.4±11.87ns -6.60%
PmTree::get_empty_leaves_indices 61.5±1.69µs 61.9±3.24µs +0.65%
PmTree::get_subtree_root 389.2±4.68ns 393.9±5.07ns +1.21%
PmTree::override_range 133.6±4.04ms 132.2±3.84ms -1.05%
PmTree::proof 9.9±0.49µs 9.2±0.23µs -7.07%
PmTree::set 764.2±9.96µs 774.5±12.00µs +1.35%
PmTree::set_range 128.2±3.52ms 126.2±3.42ms -1.56%
PmTree::update_next 6.9±3.82ms 6.8±3.72ms -1.45%
PmTree::verify 516.5±9.66µs 517.6±4.80µs +0.21%
PmTreeProof::compute_root_from 514.3±6.83µs 523.6±25.70µs +1.81%
RLN::finish_proof 68.8±0.77ms 68.7±0.90ms -0.15%
RLN::generate_partial_proof 129.2±1.42ms 128.5±4.16ms -0.54%
RLN::generate_proof 188.1±3.06ms 187.9±7.49ms -0.11%

@vinhtc27
vinhtc27 requested review from sydhds and removed request for sydhds July 8, 2026 08:04
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

Benchmark for e8e38f0

Click to view benchmark
Test Base PR %
FullMerkleProof::compute_root_from 5.3±0.03µs 5.3±0.11µs 0.00%
FullMerkleTree::delete 11.5±0.35µs 11.4±0.15µs -0.87%
FullMerkleTree::get 0.4±0.00ns 0.4±0.01ns 0.00%
FullMerkleTree::get_empty_leaves_indices 1025.9±56.34µs 1020.6±15.42µs -0.52%
FullMerkleTree::get_subtree_root 6.2±0.10ns 6.1±0.40ns -1.61%
FullMerkleTree::override_range 1158.8±37.75µs 1147.9±33.88µs -0.94%
FullMerkleTree::proof 69.8±1.07ns 67.8±0.63ns -2.87%
FullMerkleTree::set 5.7±0.05µs 5.7±0.10µs 0.00%
FullMerkleTree::set_range 1116.4±37.84µs 1157.4±43.17µs +3.67%
FullMerkleTree::update_next 6.1±4.25µs 6.1±3.94µs 0.00%
FullMerkleTree::verify 5.3±0.08µs 5.3±0.05µs 0.00%
OptimalMerkleProof::compute_root_from 5.5±0.19µs 5.3±0.04µs -3.64%
OptimalMerkleTree::delete 13.2±0.39µs 13.3±0.55µs +0.76%
OptimalMerkleTree::get 20.0±0.31ns 19.7±0.43ns -1.50%
OptimalMerkleTree::get_empty_leaves_indices 800.5±13.62µs 799.4±7.74µs -0.14%
OptimalMerkleTree::get_subtree_root 13.5±0.17ns 13.5±0.19ns 0.00%
OptimalMerkleTree::override_range 3.0±0.25ms 2.8±0.20ms -6.67%
OptimalMerkleTree::proof 293.8±7.79ns 296.4±8.13ns +0.88%
OptimalMerkleTree::set 6.7±0.19µs 6.5±0.14µs -2.99%
OptimalMerkleTree::set_range 3.0±0.18ms 2.7±0.10ms -10.00%
OptimalMerkleTree::update_next 6.9±0.32µs 7.0±0.41µs +1.45%
OptimalMerkleTree::verify 5.5±0.18µs 5.3±0.04µs -3.64%
Poseidon::hash/10 81.1±5.22µs 120.5 KElem/sec N/A N/A
Poseidon::hash/100 842.2±7.19µs 116.0 KElem/sec N/A N/A
Poseidon::hash/1000 8.7±0.07ms 112.1 KElem/sec N/A N/A
Poseidon::hash/single 8.0±0.37µs 119.2 MElem/sec N/A N/A

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

Benchmark for e8e38f0

Click to view benchmark
Test Base PR %
PmTree::delete 1542.2±13.14µs 1531.3±12.24µs -0.71%
PmTree::get 521.6±17.14ns 495.4±30.66ns -5.02%
PmTree::get_empty_leaves_indices 61.5±1.63µs 61.6±1.20µs +0.16%
PmTree::get_subtree_root 395.0±35.70ns 390.6±8.17ns -1.11%
PmTree::override_range 129.0±3.54ms 126.4±3.27ms -2.02%
PmTree::proof 9.2±0.35µs 9.0±0.20µs -2.17%
PmTree::set 764.5±7.55µs 764.0±7.82µs -0.07%
PmTree::set_range 122.1±3.79ms 120.5±3.44ms -1.31%
PmTree::update_next 6.8±3.72ms 6.7±3.63ms -1.47%
PmTree::verify 513.2±4.95µs 518.6±4.88µs +1.05%
PmTreeProof::compute_root_from 518.9±16.97µs 519.5±6.89µs +0.12%
RLN::finish_proof 68.6±0.92ms 69.5±0.84ms +1.31%
RLN::generate_partial_proof 129.7±1.96ms 130.4±2.79ms +0.54%
RLN::generate_proof 188.0±1.67ms 190.1±3.13ms +1.12%

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

Benchmark for 004d4a6

Click to view benchmark
Test Base PR %
FullMerkleProof::compute_root_from 8.4±0.12µs 8.4±0.15µs 0.00%
FullMerkleTree::delete 18.1±0.46µs 18.1±0.26µs 0.00%
FullMerkleTree::get 0.8±0.02ns 0.8±0.01ns 0.00%
FullMerkleTree::get_empty_leaves_indices 1315.7±9.02µs 1393.0±19.23µs +5.88%
FullMerkleTree::get_subtree_root 9.9±0.11ns 9.9±0.19ns 0.00%
FullMerkleTree::override_range 1886.0±27.21µs 1894.7±45.97µs +0.46%
FullMerkleTree::proof 88.5±0.87ns 90.5±1.91ns +2.26%
FullMerkleTree::set 8.9±0.07µs 9.0±0.23µs +1.12%
FullMerkleTree::set_range 1884.1±75.25µs 1869.1±85.16µs -0.80%
FullMerkleTree::update_next 8.9±0.20µs 9.0±0.23µs +1.12%
FullMerkleTree::verify 8.5±0.08µs 8.4±0.31µs -1.18%
OptimalMerkleProof::compute_root_from 8.4±0.10µs 8.4±0.15µs 0.00%
OptimalMerkleTree::delete 21.4±0.61µs 21.0±0.52µs -1.87%
OptimalMerkleTree::get 53.5±1.06ns 52.0±0.43ns -2.80%
OptimalMerkleTree::get_empty_leaves_indices 984.6±8.70µs 983.7±5.03µs -0.09%
OptimalMerkleTree::get_subtree_root 26.3±0.49ns 26.3±0.68ns 0.00%
OptimalMerkleTree::override_range 5.5±0.32ms 5.1±0.26ms -7.27%
OptimalMerkleTree::proof 874.0±158.11ns 709.1±56.08ns -18.87%
OptimalMerkleTree::set 10.7±0.21µs 10.6±0.19µs -0.93%
OptimalMerkleTree::set_range 5.5±0.28ms 5.0±0.34ms -9.09%
OptimalMerkleTree::update_next 11.1±0.70µs 10.9±0.68µs -1.80%
OptimalMerkleTree::verify 8.5±0.28µs 8.4±0.21µs -1.18%
Poseidon::hash/10 141.6±0.74µs 69.0 KElem/sec N/A N/A
Poseidon::hash/100 1511.9±3.42µs 64.6 KElem/sec N/A N/A
Poseidon::hash/1000 15.2±0.02ms 64.2 KElem/sec N/A N/A
Poseidon::hash/single 13.9±0.07µs 68.5 MElem/sec N/A N/A

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

Benchmark for 004d4a6

Click to view benchmark
Test Base PR %
PmTree::delete 1516.0±17.36µs 1506.0±17.03µs -0.66%
PmTree::get 519.9±15.34ns 496.2±12.85ns -4.56%
PmTree::get_empty_leaves_indices 61.4±0.83µs 61.4±1.11µs 0.00%
PmTree::get_subtree_root 388.9±10.64ns 388.8±4.31ns -0.03%
PmTree::override_range 125.1±3.48ms 128.8±3.33ms +2.96%
PmTree::proof 9.4±0.43µs 8.8±0.16µs -6.38%
PmTree::set 753.9±9.62µs 755.9±11.68µs +0.27%
PmTree::set_range 118.6±3.61ms 119.0±3.55ms +0.34%
PmTree::update_next 6.8±3.68ms 6.7±3.67ms -1.47%
PmTree::verify 514.8±7.52µs 518.4±4.63µs +0.70%
PmTreeProof::compute_root_from 512.9±3.33µs 520.8±24.04µs +1.54%
RLN::finish_proof 68.7±0.93ms 69.3±0.95ms +0.87%
RLN::generate_partial_proof 129.5±2.47ms 129.9±2.73ms +0.31%
RLN::generate_proof 188.7±7.94ms 188.8±3.08ms +0.05%

@vinhtc27
vinhtc27 merged commit 3138589 into develop/v3.0.0 Jul 9, 2026
15 checks passed
@vinhtc27
vinhtc27 deleted the refactor/pr13-generic-hash branch July 9, 2026 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants