Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat Nova incremental inclusion verification #153

Merged
merged 6 commits into from
Sep 13, 2023

Conversation

enricobottazzi
Copy link
Member

@enricobottazzi enricobottazzi commented Sep 8, 2023

This PR adds an example of how a full flow of Incremental Proof of Inclusion verification can be performed using Nova as a prover. A more detailed explanation can be found in Incremental Inclusion Verfication.

  • zk_prover/circom, contains the circuit implementation for the nova prover + some template circuits from circomlib
  • examples/nova_incremental_verifier.rs contains the script to run the example
  • examples/build contains the wasm and r1cs artifacts automatically generated by circom after the circuit compilation.

As you will see in the example script, I had to add different support functions related to the Merkle Sum Tree. The issue comes from the fact that the Poseidon Hasher used in circomlib behaves differently from our own implementation of the Poseidon Hasher so I couldn't use our MerkleSumTree struct. Luckily I found a rust library poseidon-rs that is compatible with circom's posiedon. Unfortunately, I meant recreating all the utils with this different hasher.

If we decide to move forward with this implementation, we need to find a way to create compatibility between the 2 hashers.

@enricobottazzi enricobottazzi marked this pull request as ready for review September 8, 2023 15:00
@enricobottazzi enricobottazzi changed the title Feat incremental inclusion verification Feat Nova incremental inclusion verification Sep 11, 2023
right_in_range[i] = Num2Bits(8*N_BYTES);

left_in_range[i].in <== left_balances[i];
right_in_range[i].in <== right_balances[i];
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it enough to just assign the inputs of Num2Bits without checking the output?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copying from internal discussion

"My understanding is that to perform range check on a number we don’t really have to consume the output, we just want to check that the number can be expressed in a specific bit range. So if the number doesn’t fit this assertion will fail => https://github.com/iden3/circomlib/blob/master/circuits/bitify.circom#L38"

You can also reproduce this on ZKREPL by following this gist.

Copy link
Member

@sifnoc sifnoc left a comment

Choose a reason for hiding this comment

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

Good alternative approach.
Perhaps we can move this outside of the examples folder in the future.

@alxkzmn alxkzmn merged commit bc63f43 into master Sep 13, 2023
4 checks passed
@enricobottazzi enricobottazzi deleted the feat-incremental-inclusion-verification branch November 21, 2023 14:32
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.

3 participants