-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Improve IN and other operators' calculation security * Move safe calculation of signal with value one to separate template. Added empty assignments for unused signals to remove compiler warnings. Removed one unused template. * Update comments with number of constraints
- Loading branch information
1 parent
9c71a2c
commit 160917f
Showing
9 changed files
with
127 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
pragma circom 2.1.1; | ||
|
||
include "../../../node_modules/circomlib/circuits/comparators.circom"; | ||
include "../../../node_modules/circomlib/circuits/gates.circom"; | ||
|
||
///////////////////////////////////////////////////////////////// | ||
// SafeZeroOne calculates safe one signals from any signal coming from outside of circuit | ||
// It is needed because linear constraints are not giving real security guarantees and circom is | ||
// removing them during optimization pass. | ||
// Because of this `===` without multiplications gives 0 constraints!!! | ||
// ForceEqualIfEnabled(1, [x, y]) gives 0 too. | ||
// Only ForceEqualIfEnabled(enabled, [x, y]) with `enabled` from input signal or signal safely derived | ||
// from input signal generates constraints. | ||
// That's why we need to calculate safe zero and one signals from input signal. | ||
///////////////////////////////////////////////////////////////// | ||
template SafeOne() { | ||
signal input inputSignal; | ||
signal tmp <== IsZero()(inputSignal); | ||
signal tmp2 <== NOT()(tmp); | ||
signal zero <== IsEqual()([tmp, tmp2]); | ||
signal output one <== IsZero()(zero); | ||
zero * one === 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.