-
Notifications
You must be signed in to change notification settings - Fork 287
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added new errors for bus typing and new test files.
- Loading branch information
Sacul231
committed
Apr 20, 2024
1 parent
499923f
commit 6349570
Showing
5 changed files
with
128 additions
and
26 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 was deleted.
Oops, something went wrong.
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,17 @@ | ||
pragma circom 2.0.0; | ||
|
||
bus Point (n) { | ||
signal {binary} x[n], y[n]; | ||
} | ||
|
||
template Pipe (n) { | ||
Point(n) input {babyedwards} pin; | ||
Point(n) output {babyedwards} pout; | ||
|
||
for (var i=0; i<n; i++) { | ||
pout.x[i] <== pin.x[i]; | ||
pout.y[i] <== pin.y[i]; | ||
} | ||
} | ||
|
||
component main = Pipe(3); |
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,82 @@ | ||
pragma circom 2.0.0; | ||
|
||
include "bitify.circom"; | ||
include "escalarmulfix.circom"; | ||
|
||
bus Point () { | ||
signal x, y; | ||
} | ||
|
||
bus Parameters () { | ||
signal beta, gamma, delta, tau; | ||
} | ||
|
||
template BabyAdd() { | ||
Point input p1, p2; | ||
Point output pout; | ||
|
||
Parameters params; | ||
|
||
var a = 168700; | ||
var d = 168696; | ||
|
||
params.beta <== p1.x*p2.y; | ||
params.gamma <== p1.y*p2.x; | ||
params.delta <== (-a*p1.x+p1.y)*(p2.x + p2.y); | ||
params.tau <== params.beta * params.gamma; | ||
|
||
pout.x <-- (params.beta + params.gamma) / (1+ d*params.tau); | ||
(1 + d*params.tau) * pout.x === (params.beta + params.gamma); | ||
|
||
pout.y <-- (params.delta + a*params.beta - params.gamma) / (1-d*params.tau); | ||
(1-d*params.tau)*pout.y === (params.delta + a*params.beta - params.gamma); | ||
} | ||
|
||
template BabyDbl() { | ||
Point() input pin; | ||
Point output pout; | ||
|
||
component adder = BabyAdd(); | ||
adder.p1 <== pin; | ||
adder.p2 <== pin; | ||
|
||
adder.pout ==> pout; | ||
} | ||
|
||
|
||
template BabyCheck() { | ||
Point input p; | ||
|
||
Point q; | ||
|
||
var a = 168700; | ||
var d = 168696; | ||
|
||
q.x <== p.x*p.x; | ||
q.y <== p.y*p.y; | ||
|
||
a*q.x + q.y === 1 + d*q.x*q.y; | ||
} | ||
|
||
// Extracts the public key from private key | ||
template BabyPbk() { | ||
signal input in; | ||
Point output A; | ||
|
||
var BASE8[2] = [ | ||
5299619240641551281634865583518297030282874472190772894086521144482721001553, | ||
16950150798460657717958625567821834550301663161624707787222815936182638968203 | ||
]; | ||
|
||
component pvkBits = Num2Bits(253); | ||
pvkBits.in <== in; | ||
|
||
component mulFix = EscalarMulFix(253, BASE8); | ||
|
||
var i; | ||
for (i=0; i<253; i++) { | ||
mulFix.e[i] <== pvkBits.out[i]; | ||
} | ||
A.x <== mulFix.out[0]; | ||
A.y <== mulFix.out[1]; | ||
} |
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.0.0; | ||
|
||
bus Correct { | ||
signal {binary} correct; | ||
} | ||
|
||
bus RecursiveArray (N) { | ||
Correct array[N]; | ||
RecursiveArray(N-1) rec; | ||
} | ||
|
||
template Create (N) { | ||
RecursiveArray(N) output out; | ||
|
||
component create_rec = Create(N-1); | ||
|
||
for (var i=0; i<n; i++) { | ||
out.array[i].correct <== 1; | ||
} | ||
out.rec <== create_rec.out; | ||
} | ||
|
||
component main = Create(2); |