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.

64 lines
1.0 KiB

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