|
|
|
|
template BabyAdd() {
|
|
signal input x1;
|
|
signal input y1;
|
|
signal input x2;
|
|
signal input y2;
|
|
signal output xout;
|
|
signal output yout;
|
|
|
|
signal beta;
|
|
signal gamma;
|
|
signal delta;
|
|
signal tau;
|
|
|
|
var a = 168700;
|
|
var d = 168696;
|
|
|
|
beta <== x1*y2;
|
|
gamma <== y1*x2;
|
|
delta <== (-a*x1+y1)*(x2 + y2);
|
|
tau <== beta * gamma;
|
|
|
|
xout <-- (beta + gamma) / (1+ d*tau);
|
|
(1+ d*tau) * xout === (beta + gamma);
|
|
|
|
yout <-- (delta + a*beta - gamma) / (1-d*tau);
|
|
(1-d*tau)*yout === (delta + a*beta - gamma);
|
|
}
|
|
|
|
template BabyDbl() {
|
|
signal input x;
|
|
signal input y;
|
|
signal output xout;
|
|
signal output yout;
|
|
|
|
component adder = BabyAdd();
|
|
adder.x1 <== x;
|
|
adder.y1 <== y;
|
|
adder.x2 <== x;
|
|
adder.y2 <== y;
|
|
|
|
adder.xout ==> xout;
|
|
adder.yout ==> yout;
|
|
}
|
|
|
|
|
|
template BabyCheck() {
|
|
signal input x;
|
|
signal input y;
|
|
|
|
signal x2;
|
|
signal y2;
|
|
|
|
var a = 168700;
|
|
var d = 168696;
|
|
|
|
x2 <== x*x;
|
|
y2 <== y*y;
|
|
|
|
a*x2 + y2 === 1 + d*x2*y2;
|
|
}
|