-
Notifications
You must be signed in to change notification settings - Fork 16
Add Value Commitment operator #125
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
base: develop
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| pragma circom 2.1.1; | ||
|
|
||
| include "../../../node_modules/circomlib/circuits/mux1.circom"; | ||
| include "../../../node_modules/circomlib/circuits/comparators.circom"; | ||
| include "../../../node_modules/circomlib/circuits/poseidon.circom"; | ||
|
|
||
| /** | ||
| Value commitment circuit allows to commit to a specific value and then | ||
| reveal it later or use such a commitment in another circuits to prove that | ||
| multiple circuits work with the same value without revealing it. | ||
| */ | ||
|
|
||
| template ValueCommitment() { | ||
| signal input value; | ||
| signal input commitNonce; // private random nonce to make the commitment unique and secure | ||
|
|
||
| signal output out; | ||
|
|
||
| signal isNonceZero <== IsZero()(commitNonce); | ||
|
|
||
| signal commit <== Poseidon(2)([value, commitNonce]); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like I can receive the same commitment if I have another field with the same value and provide the same commitment outside. (I want to prove that I have the same date of birth in the different creds, but I can hack and prove that some another date that I have in other credential is equal to expected, but it is not the same meaning.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not a hack. Maybe user wants to prove to verifier that on his day of birth there was a sun eclipse. It's ok. |
||
|
|
||
| out <== Mux1()( | ||
| [commit, 0], | ||
| isNonceZero | ||
| ); | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.