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.

33 lines
788 B

6 years ago
  1. function pointAdd(x1,y1,x2,y2) {
  2. var a = 168700;
  3. var d = 168696;
  4. var res[2];
  5. res[0] = (x1*y2 + y1*x2) / (1 + d*x1*x2*y1*y2);
  6. res[1] = (y1*y2 - a*x1*x2) / (1 - d*x1*x2*y1*y2);
  7. return res;
  8. }
  9. template ExpW4Table(k) {
  10. signal output out[16][2];
  11. var i;
  12. var p[2];
  13. var g = [17777552123799933955779906779655732241715742912184938656739573121738514868268,
  14. 2626589144620713026669568689430873010625803728049924121243784502389097019475];
  15. var dbl = g;
  16. for (i=0; i<k*4; i++) {
  17. dbl = pointAdd(dbl[0], dbl[1], dbl[0], dbl[1]);
  18. }
  19. out[0][0] <== 0;
  20. out[0][1] <== 1;
  21. for (i=1; i<16; i++) {
  22. p = pointAdd(out[i-1][0], out[i-1][1], dbl[0], dbl[1]);
  23. out[i][0] <== p[0];
  24. out[i][1] <== p[1];
  25. }
  26. }