mirror of
https://github.com/arnaucube/circomlib.git
synced 2026-02-06 18:56:43 +01:00
Convert constant components to functions
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
Copyright 2018 0KIMS association.
|
||||
|
||||
This file is part of circom (Zero Knowledge Circuit Compiler).
|
||||
@@ -71,7 +71,7 @@ template EscalarMulWindow(base, k) {
|
||||
signal input sel[4];
|
||||
signal output out[2];
|
||||
|
||||
component table;
|
||||
var table;
|
||||
component mux;
|
||||
component adder;
|
||||
|
||||
@@ -86,8 +86,8 @@ template EscalarMulWindow(base, k) {
|
||||
}
|
||||
|
||||
for (i=0; i<16; i++) {
|
||||
table.out[i][0] ==> mux.c[0][i];
|
||||
table.out[i][1] ==> mux.c[1][i];
|
||||
mux.c[0][i] <== table[i][0];
|
||||
mux.c[1][i] <== table[i][1];
|
||||
}
|
||||
|
||||
in[0] ==> adder.x1;
|
||||
|
||||
@@ -27,8 +27,8 @@ function pointAdd(x1,y1,x2,y2) {
|
||||
return res;
|
||||
}
|
||||
|
||||
template EscalarMulW4Table(base, k) {
|
||||
signal output out[16][2];
|
||||
function EscalarMulW4Table(base, k) {
|
||||
var out[16][2];
|
||||
|
||||
var i;
|
||||
var p[2];
|
||||
@@ -39,11 +39,13 @@ template EscalarMulW4Table(base, k) {
|
||||
dbl = pointAdd(dbl[0], dbl[1], dbl[0], dbl[1]);
|
||||
}
|
||||
|
||||
out[0][0] <== 0;
|
||||
out[0][1] <== 1;
|
||||
out[0][0] = 0;
|
||||
out[0][1] = 1;
|
||||
for (i=1; i<16; i++) {
|
||||
p = pointAdd(out[i-1][0], out[i-1][1], dbl[0], dbl[1]);
|
||||
out[i][0] <== p[0];
|
||||
out[i][1] <== p[1];
|
||||
out[i][0] = p[0];
|
||||
out[i][1] = p[1];
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -279,7 +279,7 @@ template MiMCFeistel(nrounds) {
|
||||
t4[i] <== t2[i]*t2[i];
|
||||
if (i<nrounds-1) {
|
||||
xL[i] <== ((i==0) ? xR_in : xR[i-1]) + t4[i]*t;
|
||||
xR[i] = (i==0) ? xL_in : xL[i-1];
|
||||
xR[i] <== (i==0) ? xL_in : xL[i-1];
|
||||
} else {
|
||||
xR_out <== xR[i-1] + t4[i]*t;
|
||||
xL_out <== xL[i-1];
|
||||
|
||||
Reference in New Issue
Block a user