Skip to content

Commit

Permalink
Merge pull request privacy-scaling-explorations#1517 from privacy-sca…
Browse files Browse the repository at this point in the history
…ling-explorations/fix/circuits

fix(circuits): ensure we check index < numSignups
  • Loading branch information
0xmad authored May 30, 2024
2 parents ee28c20 + adeb6b8 commit 926282a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions circuits/circom/utils/non-qv/messageValidator.circom
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ template MessageValidatorNonQv() {
signal output isValid;

// Check (1) - The state leaf index must be valid.
// The check ensure that the stateTreeIndex <= numSignUps as first validation.
// Must be <= because the stateTreeIndex is 1-based. Zero is for blank state leaf
// while 1 is for the first actual user matching the numSignUps start.
var computedIsStateLeafIndexValid = SafeLessEqThan(252)([stateTreeIndex, numSignUps]);
// The check ensure that the stateTreeIndex < numSignUps as first validation.
// Must be < because the stateTreeIndex is 0-based. Zero is for blank state leaf
// while 1 is for the first actual user.
var computedIsStateLeafIndexValid = SafeLessThan(252)([stateTreeIndex, numSignUps]);

// Check (2) - The max vote option tree index must be correct.
var computedIsVoteOptionIndexValid = SafeLessThan(252)([voteOptionIndex, maxVoteOptions]);
Expand Down
8 changes: 4 additions & 4 deletions circuits/circom/utils/qv/messageValidator.circom
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ template MessageValidator() {
signal output isValid;

// Check (1) - The state leaf index must be valid.
// The check ensure that the stateTreeIndex <= numSignUps as first validation.
// Must be <= because the stateTreeIndex is 1-based. Zero is for blank state leaf
// while 1 is for the first actual user matching the numSignUps start.
var computedIsStateLeafIndexValid = SafeLessEqThan(252)([stateTreeIndex, numSignUps]);
// The check ensure that the stateTreeIndex < numSignUps as first validation.
// Must be < because the stateTreeIndex is 0-based. Zero is for blank state leaf
// while 1 is for the first actual user.
var computedIsStateLeafIndexValid = SafeLessThan(252)([stateTreeIndex, numSignUps]);

// Check (2) - The max vote option tree index must be correct.
var computedIsVoteOptionIndexValid = SafeLessThan(252)([voteOptionIndex, maxVoteOptions]);
Expand Down

0 comments on commit 926282a

Please sign in to comment.