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.

49 lines
1.0 KiB

6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
  1. include "xor3.circom";
  2. include "rotate.circom";
  3. include "shift.circom";
  4. template SmallSigma(ra, rb, rc) {
  5. signal input in[32];
  6. signal output out[32];
  7. component xor3 = Xor3(32);
  8. component rota = RotR(32, ra);
  9. component rotb = RotR(32, rb);
  10. component shrc = ShR(32, rc);
  11. for (var k=0; k<32; k++) {
  12. rota.in[k] <== in[k];
  13. rotb.in[k] <== in[k];
  14. shrc.in[k] <== in[k];
  15. xor3.a[k] <== rota.out[k];
  16. xor3.b[k] <== rotb.out[k];
  17. xor3.c[k] <== shrc.out[k];
  18. out[k] <== xor3.out[k];
  19. }
  20. }
  21. template BigSigma(ra, rb, rc) {
  22. signal input in[32];
  23. signal output out[32];
  24. component xor3 = Xor3(32);
  25. component rota = RotR(32, ra);
  26. component rotb = RotR(32, rb);
  27. component rotc = RotR(32, rc);
  28. for (var k=0; k<32; k++) {
  29. rota.in[k] <== in[k];
  30. rotb.in[k] <== in[k];
  31. rotc.in[k] <== in[k];
  32. xor3.a[k] <== rota.out[k];
  33. xor3.b[k] <== rotb.out[k];
  34. xor3.c[k] <== rotc.out[k];
  35. out[k] <== xor3.out[k];
  36. }
  37. }