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.

67 lines
1.9 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. /*
  2. Copyright 2018 0KIMS association.
  3. This file is part of circom (Zero Knowledge Circuit Compiler).
  4. circom is a free software: you can redistribute it and/or modify it
  5. under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. circom is distributed in the hope that it will be useful, but WITHOUT
  9. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  10. or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  11. License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with circom. If not, see <https://www.gnu.org/licenses/>.
  14. */
  15. include "sha256compression.circom";
  16. include "../bitify.circom"
  17. template Sha256_2() {
  18. signal input a;
  19. signal input b;
  20. signal output out;
  21. component bits2num = Bits2Num(216);
  22. component num2bits[2];
  23. num2bits[0] = Num2Bits(216);
  24. num2bits[1] = Num2Bits(216);
  25. num2bits[0].in <== a;
  26. num2bits[1].in <== b;
  27. component sha256compression = Sha256compression() ;
  28. var i;
  29. for (i=0; i<216; i++) {
  30. sha256compression.inp[i] <== num2bits[0].out[215-i];
  31. sha256compression.inp[i+216] <== num2bits[1].out[215-i];
  32. }
  33. sha256compression.inp[432] <== 1;
  34. for (i=433; i<503; i++) {
  35. sha256compression.inp[i] <== 0;
  36. }
  37. sha256compression.inp[503] <== 1;
  38. sha256compression.inp[504] <== 1;
  39. sha256compression.inp[505] <== 0;
  40. sha256compression.inp[506] <== 1;
  41. sha256compression.inp[507] <== 1;
  42. sha256compression.inp[508] <== 0;
  43. sha256compression.inp[509] <== 0;
  44. sha256compression.inp[510] <== 0;
  45. sha256compression.inp[511] <== 0;
  46. for (i=0; i<216; i++) {
  47. bits2num.in[i] <== sha256compression.out[255-i];
  48. }
  49. out <== bits2num.out;
  50. }