mirror of
https://github.com/arnaucube/circomlib.git
synced 2026-02-06 18:56:43 +01:00
Pedersen2 and BitPoints MulFix and MulAny
This commit is contained in:
3
test/circuits/aliascheck_test.circom
Normal file
3
test/circuits/aliascheck_test.circom
Normal file
@@ -0,0 +1,3 @@
|
||||
include "../../circuit/aliascheck.circom";
|
||||
|
||||
component main = AliasCheck()
|
||||
3
test/circuits/babycheck_test.circom
Normal file
3
test/circuits/babycheck_test.circom
Normal file
@@ -0,0 +1,3 @@
|
||||
include "../../circuit/babyjub.circom";
|
||||
|
||||
component main = BabyCheck();
|
||||
3
test/circuits/edwards2montgomery.circom
Normal file
3
test/circuits/edwards2montgomery.circom
Normal file
@@ -0,0 +1,3 @@
|
||||
include "../../circuit/montgomery.circom";
|
||||
|
||||
component main = Edwards2Montgomery();
|
||||
28
test/circuits/escalarmulany_test.circom
Normal file
28
test/circuits/escalarmulany_test.circom
Normal file
@@ -0,0 +1,28 @@
|
||||
include "../../circuit/escalarmulany.circom";
|
||||
include "../../node_modules/circom/circuits/bitify.circom";
|
||||
|
||||
template Main() {
|
||||
signal input e;
|
||||
signal input p[2];
|
||||
signal output out[2];
|
||||
|
||||
component n2b = Num2Bits(253);
|
||||
component escalarMulAny = EscalarMulAny(253);
|
||||
|
||||
escalarMulAny.p[0] <== p[0];
|
||||
escalarMulAny.p[1] <== p[1];
|
||||
|
||||
var i;
|
||||
|
||||
e ==> n2b.in;
|
||||
|
||||
for (i=0; i<253; i++) {
|
||||
n2b.out[i] ==> escalarMulAny.e[i];
|
||||
}
|
||||
|
||||
escalarMulAny.out[0] ==> out[0];
|
||||
escalarMulAny.out[1] ==> out[1];
|
||||
}
|
||||
|
||||
component main = Main();
|
||||
|
||||
29
test/circuits/escalarmulfix_test.circom
Normal file
29
test/circuits/escalarmulfix_test.circom
Normal file
@@ -0,0 +1,29 @@
|
||||
include "../../circuit/escalarmulfix.circom";
|
||||
include "../../node_modules/circom/circuits/bitify.circom";
|
||||
|
||||
|
||||
template Main() {
|
||||
signal input e;
|
||||
signal output out[2];
|
||||
|
||||
var base = [17777552123799933955779906779655732241715742912184938656739573121738514868268,
|
||||
2626589144620713026669568689430873010625803728049924121243784502389097019475]
|
||||
|
||||
|
||||
component n2b = Num2Bits(253);
|
||||
component escalarMul = EscalarMulFix(253, base);
|
||||
|
||||
var i;
|
||||
|
||||
e ==> n2b.in;
|
||||
|
||||
for (i=0; i<253; i++) {
|
||||
n2b.out[i] ==> escalarMul.e[i];
|
||||
}
|
||||
|
||||
escalarMul.out[0] ==> out[0];
|
||||
escalarMul.out[1] ==> out[1];
|
||||
}
|
||||
|
||||
component main = Main();
|
||||
|
||||
3
test/circuits/montgomery2edwards.circom
Normal file
3
test/circuits/montgomery2edwards.circom
Normal file
@@ -0,0 +1,3 @@
|
||||
include "../../circuit/montgomery.circom";
|
||||
|
||||
component main = Montgomery2Edwards();
|
||||
3
test/circuits/montgomeryadd.circom
Normal file
3
test/circuits/montgomeryadd.circom
Normal file
@@ -0,0 +1,3 @@
|
||||
include "../../circuit/montgomery.circom";
|
||||
|
||||
component main = MontgomeryAdd();
|
||||
3
test/circuits/montgomerydouble.circom
Normal file
3
test/circuits/montgomerydouble.circom
Normal file
@@ -0,0 +1,3 @@
|
||||
include "../../circuit/montgomery.circom";
|
||||
|
||||
component main = MontgomeryDouble();
|
||||
39
test/circuits/mux3_1.circom
Normal file
39
test/circuits/mux3_1.circom
Normal file
@@ -0,0 +1,39 @@
|
||||
include "../../circuit/mux3.circom";
|
||||
include "../../node_modules/circom/circuits/bitify.circom";
|
||||
|
||||
|
||||
template Constants() {
|
||||
var i;
|
||||
signal output out[8];
|
||||
|
||||
out[0] <== 37;
|
||||
out[1] <== 47;
|
||||
out[2] <== 53;
|
||||
out[3] <== 71;
|
||||
out[4] <== 89;
|
||||
out[5] <== 107;
|
||||
out[6] <== 163;
|
||||
out[7] <== 191;
|
||||
}
|
||||
|
||||
template Main() {
|
||||
var i;
|
||||
signal private input selector;
|
||||
signal output out;
|
||||
|
||||
component mux = Mux3();
|
||||
component n2b = Num2Bits(3);
|
||||
component cst = Constants();
|
||||
|
||||
selector ==> n2b.in;
|
||||
for (i=0; i<3; i++) {
|
||||
n2b.out[i] ==> mux.s[i];
|
||||
}
|
||||
for (i=0; i<8; i++) {
|
||||
cst.out[i] ==> mux.c[i];
|
||||
}
|
||||
|
||||
mux.out ==> out;
|
||||
}
|
||||
|
||||
component main = Main();
|
||||
32
test/circuits/pedersen2_test.circom
Normal file
32
test/circuits/pedersen2_test.circom
Normal file
@@ -0,0 +1,32 @@
|
||||
include "../../circuit/pedersen2.circom";
|
||||
include "../../node_modules/circom/circuits/bitify.circom";
|
||||
|
||||
|
||||
template Main() {
|
||||
signal input in;
|
||||
signal output out[2];
|
||||
|
||||
component pedersen = Pedersen(256);
|
||||
|
||||
component n2b;
|
||||
n2b = Num2Bits(253);
|
||||
|
||||
var i;
|
||||
|
||||
in ==> n2b.in;
|
||||
|
||||
for (i=0; i<253; i++) {
|
||||
pedersen.in[i] <== n2b.out[i];
|
||||
}
|
||||
|
||||
for (i=253; i<256; i++) {
|
||||
pedersen.in[i] <== 0;
|
||||
}
|
||||
|
||||
pedersen.out[0] ==> out[0];
|
||||
pedersen.out[1] ==> out[1];
|
||||
}
|
||||
|
||||
component main = Main();
|
||||
|
||||
|
||||
@@ -6,20 +6,20 @@ template Main() {
|
||||
signal input in[2];
|
||||
signal output out[2];
|
||||
|
||||
component pedersen = Pedersen(253*2);
|
||||
component pedersen = Pedersen(250*2);
|
||||
|
||||
component n2b[2];
|
||||
n2b[0] = Num2Bits(253);
|
||||
n2b[1] = Num2Bits(253);
|
||||
n2b[0] = Num2Bits(250);
|
||||
n2b[1] = Num2Bits(250);
|
||||
|
||||
var i;
|
||||
|
||||
in[0] ==> n2b[0].in;
|
||||
in[1] ==> n2b[1].in;
|
||||
|
||||
for (i=0; i<253; i++) {
|
||||
for (i=0; i<250; i++) {
|
||||
n2b[0].out[i] ==> pedersen.in[i];
|
||||
n2b[1].out[i] ==> pedersen.in[253+i];
|
||||
n2b[1].out[i] ==> pedersen.in[250+i];
|
||||
}
|
||||
|
||||
pedersen.out[0] ==> out[0];
|
||||
|
||||
23
test/circuits/pointbits_loopback.circom
Normal file
23
test/circuits/pointbits_loopback.circom
Normal file
@@ -0,0 +1,23 @@
|
||||
include "../../circuit/pointbits.circom";
|
||||
|
||||
|
||||
template Main() {
|
||||
signal input in[2];
|
||||
|
||||
var i
|
||||
|
||||
component p2b = Point2Bits_Strict();
|
||||
component b2p = Bits2Point_Strict();
|
||||
|
||||
p2b.in[0] <== in[0];
|
||||
p2b.in[1] <== in[1];
|
||||
|
||||
for (i=0; i<256; i++) {
|
||||
b2p.in[i] <== p2b.out[i];
|
||||
}
|
||||
|
||||
b2p.out[0] === in[0];
|
||||
b2p.out[1] === in[1];
|
||||
}
|
||||
|
||||
component main = Main();
|
||||
3
test/circuits/sign_test.circom
Normal file
3
test/circuits/sign_test.circom
Normal file
@@ -0,0 +1,3 @@
|
||||
include "../../circuit/sign.circom";
|
||||
|
||||
component main = Sign();
|
||||
Reference in New Issue
Block a user