Skip to content

Commit

Permalink
add correct version
Browse files Browse the repository at this point in the history
  • Loading branch information
yik8191 committed Jun 13, 2019
1 parent e1055e0 commit 7dd0ef2
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
11 changes: 11 additions & 0 deletions 5_comparator/bad_force_equal_if_enabled.circom
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

template BadForceEqualIfEnabled() {
signal input enabled;
signal input in[2];

if (enabled) {
in[1] === in[0]
}
}

component main = BadForceEqualIfEnabled()
14 changes: 14 additions & 0 deletions 5_comparator/force_equal_if_enabled.circom
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
include "iszero.circom";

template ForceEqualIfEnabled() {
signal input enabled;
signal input in[2];

component isz = IsZero();

in[1] - in[0] ==> isz.in;

(1 - isz.out)*enabled === 0;
}

component main = ForceEqualIfEnabled()
13 changes: 13 additions & 0 deletions 5_comparator/iszero.circom
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
template IsZero() {
signal input in;
signal output out;

signal inv;

inv <-- in!=0 ? 1/in : 0;

out <== -in*inv +1;
in*out === 0;
}


0 comments on commit 7dd0ef2

Please sign in to comment.