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.

41 lines
1.1 KiB

  1. pragma circom 2.0.0;
  2. include "./utils.circom";
  3. template RC(r) {
  4. signal output out[64];
  5. var rc[24] = [
  6. 0x0000000000000001, 0x0000000000008082, 0x800000000000808A,
  7. 0x8000000080008000, 0x000000000000808B, 0x0000000080000001,
  8. 0x8000000080008081, 0x8000000000008009, 0x000000000000008A,
  9. 0x0000000000000088, 0x0000000080008009, 0x000000008000000A,
  10. 0x000000008000808B, 0x800000000000008B, 0x8000000000008089,
  11. 0x8000000000008003, 0x8000000000008002, 0x8000000000000080,
  12. 0x000000000000800A, 0x800000008000000A, 0x8000000080008081,
  13. 0x8000000000008080, 0x0000000080000001, 0x8000000080008008
  14. ];
  15. for (var i=0; i<64; i++) {
  16. out[i] <== (rc[r] >> i) & 1;
  17. }
  18. }
  19. template Iota(r) {
  20. signal input in[25*64];
  21. signal output out[25*64];
  22. var i;
  23. component rc = RC(r);
  24. component iota = XorArray(64);
  25. for (var i=0; i<64; i++) {
  26. iota.a[i] <== in[i];
  27. iota.b[i] <== rc.out[i];
  28. }
  29. for (i=0; i<64; i++) {
  30. out[i] <== iota.out[i];
  31. }
  32. for (i=64; i<25*64; i++) {
  33. out[i] <== in[i];
  34. }
  35. }