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.

27 lines
565 B

  1. template Square() {
  2. signal input in;
  3. signal output out;
  4. out <== in**2;
  5. }
  6. template Main(n, nrounds) {
  7. signal input in[n];
  8. signal output out[n];
  9. component squares[n][nrounds];
  10. for (var i=0; i<n; i++) {
  11. for (var r=0; r<nrounds; r++) {
  12. squares[i][r] = Square();
  13. if (r==0) {
  14. squares[i][r].in <== in[i];
  15. } else {
  16. squares[i][r].in <== squares[i][r-1].out;
  17. }
  18. }
  19. squares[i][nrounds-1].out ==> out[i];
  20. }
  21. }
  22. component main = Main(2, 3);