vacp2p / zerokit

A set of Zero Knowledge modules, written in Rust and designed to be used in other system programming environments.
Apache License 2.0
130 stars 7 forks source link

feat: add functions for calculating witness that accepts merkle proof #233

Closed adklempner closed 5 months ago

github-actions[bot] commented 5 months ago

Benchmark for 27db555

Click to view benchmark | Test | Base | PR | % | |------|--------------|------------------|---| | Pmtree::compute_root | 0.0±0.00ns | 0.0±0.00ns | NaN% | | Pmtree::get | 321.8±10.34ns | 317.9±5.14ns | -1.21% | | Pmtree::override_range | **229.5±3.47µs** | 235.9±7.24µs | **+2.79%** | | Pmtree::set | 54.3±0.95µs | 54.4±1.89µs | +0.18% | | Pmtree:delete | 54.3±0.64µs | 54.4±1.66µs | +0.18% |
github-actions[bot] commented 5 months ago

Benchmark for 27db555

Click to view benchmark | Test | Base | PR | % | |------|--------------|------------------|---| | FullMerkleTree::compute_root | 0.0±0.00ns | 0.0±0.00ns | NaN% | | FullMerkleTree::delete | 873.7±11.76ns | 885.3±11.87ns | +1.33% | | FullMerkleTree::get | **3.4±0.04ns** | 3.5±0.08ns | **+2.94%** | | FullMerkleTree::override_range | 2.2±0.03µs | 2.2±0.03µs | 0.00% | | FullMerkleTree::set | **874.3±8.12ns** | 907.3±46.69ns | **+3.77%** | | OptimalMerkleTree::compute_root | 1030.6±14.14ns | 1037.8±11.37ns | +0.70% | | OptimalMerkleTree::delete | 1034.0±13.06ns | 1026.6±14.70ns | -0.72% | | OptimalMerkleTree::get | 22.9±0.33ns | 23.2±0.72ns | +1.31% | | OptimalMerkleTree::override_range | **5.2±0.08µs** | 5.3±0.16µs | **+1.92%** | | OptimalMerkleTree::set | 1040.8±60.76ns | 1036.9±39.69ns | -0.37% |
adklempner commented 5 months ago
  • afaik v0.4.x only supports RLNv2 and v0.3.x is for RLNv1. Since The Waku Network (and Waku in general) is not yet using RLNv2, I would say we need to use the latest v0.3.6 (RLN v1) as the baseline. I assume in js-waku you still point to that one?

Yes, this was my mistake.

  • Perhapswasm_get_serialized_rln_witness_with_proof is not needed?. I mean, you can generate the witness yourself without using zerokit (example using go) and then directly use generate_rln_proof_with_witness with your witness constructed in js-waku. Nothing against exposing it though, but feels more complex (requires modifying zerokit, extra call to wasm, some ugly serde, etc)

I think this makes more sense, I will try it.

  • So unless I'm missing something, I would say there is no need to modify zerokit for the PoC you are developing in js-waku. One interesting abstraction could be to have a generate_rln_proof_with_merkle_proof that gets everything: merkle proof, message hash, epoch, secret, etc. So instead of requiring to i) generate witness and ii) generate rln proof with witness, you can do everything in just 1 function call. But again, a mere nice to have.

In case that helps, here is how I did it in go.

I agree, that would be ideal. If we move forward with this beyond PoC, I think it's worth considering.

adklempner commented 5 months ago

Closing this as it was not necessary for the PoC