You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1.0 KiB

6 years ago
6 years ago
6 years ago
  1. template BabyAdd() {
  2. signal input x1;
  3. signal input y1;
  4. signal input x2;
  5. signal input y2;
  6. signal output xout;
  7. signal output yout;
  8. signal beta;
  9. signal gamma;
  10. signal delta;
  11. signal tau;
  12. var a = 168700;
  13. var d = 168696;
  14. beta <== x1*y2;
  15. gamma <== y1*x2;
  16. delta <== (-a*x1+y1)*(x2 + y2);
  17. tau <== beta * gamma;
  18. xout <-- (beta + gamma) / (1+ d*tau);
  19. (1+ d*tau) * xout === (beta + gamma);
  20. yout <-- (delta + a*beta - gamma) / (1-d*tau);
  21. (1-d*tau)*yout === (delta + a*beta - gamma);
  22. }
  23. template BabyDbl() {
  24. signal input x;
  25. signal input y;
  26. signal output xout;
  27. signal output yout;
  28. component adder = BabyAdd();
  29. adder.x1 <== x;
  30. adder.y1 <== y;
  31. adder.x2 <== x;
  32. adder.y2 <== y;
  33. adder.xout ==> xout;
  34. adder.yout ==> yout;
  35. }
  36. template BabyCheck() {
  37. signal input x;
  38. signal input y;
  39. signal x2;
  40. signal y2;
  41. var a = 168700;
  42. var d = 168696;
  43. x2 <== x*x;
  44. y2 <== y*y;
  45. a*x2 + y2 === 1 + d*x2*y2;
  46. }