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.1 KiB

6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
  1. include "sha256compression.circom";
  2. include "bitify.circom"
  3. template Sha256_2() {
  4. signal input a;
  5. signal input b;
  6. signal output out;
  7. component bits2num = Bits2Num(216);
  8. component num2bits[2];
  9. num2bits[0] = Num2Bits(216);
  10. num2bits[1] = Num2Bits(216);
  11. num2bits[0].in <== a;
  12. num2bits[1].in <== b;
  13. component sha256compression = Sha256compression() ;
  14. var i;
  15. for (i=0; i<216; i++) {
  16. sha256compression.inp[i] <== num2bits[0].out[215-i];
  17. sha256compression.inp[i+216] <== num2bits[1].out[215-i];
  18. }
  19. sha256compression.inp[432] <== 1;
  20. for (i=433; i<503; i++) {
  21. sha256compression.inp[i] <== 0;
  22. }
  23. sha256compression.inp[503] <== 1;
  24. sha256compression.inp[504] <== 1;
  25. sha256compression.inp[505] <== 0;
  26. sha256compression.inp[506] <== 1;
  27. sha256compression.inp[507] <== 1;
  28. sha256compression.inp[508] <== 0;
  29. sha256compression.inp[509] <== 0;
  30. sha256compression.inp[510] <== 0;
  31. sha256compression.inp[511] <== 0;
  32. for (i=0; i<216; i++) {
  33. bits2num.in[i] <== sha256compression.out[255-i];
  34. }
  35. out <== bits2num.out;
  36. }