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.

46 lines
931 B

  1. pragma circom 2.0.0;
  2. include "./utils.circom";
  3. template Pad(nBits) {
  4. signal input in[nBits];
  5. var blockSize=136*8;
  6. signal output out[blockSize];
  7. signal out2[blockSize];
  8. var i;
  9. for (i=0; i<nBits; i++) {
  10. out2[i] <== in[i];
  11. }
  12. var domain = 0x01;
  13. for (i=0; i<8; i++) {
  14. out2[nBits+i] <== (domain >> i) & 1;
  15. }
  16. for (i=nBits+8; i<blockSize; i++) {
  17. out2[i] <== 0;
  18. }
  19. component aux = OrArray(8);
  20. for (i=0; i<8; i++) {
  21. aux.a[i] <== out2[blockSize-8+i];
  22. aux.b[i] <== (0x80 >> i) & 1;
  23. }
  24. for (i=0; i<8; i++) {
  25. out[blockSize-8+i] <== aux.out[i];
  26. }
  27. for (i=0; i<blockSize-8; i++) {
  28. out[i]<==out2[i];
  29. }
  30. }
  31. template Keccak256(nBits) {
  32. signal input in[nBits];
  33. signal output out[256];
  34. var i;
  35. // pad
  36. component pad = Pad(nBits);
  37. for (i=0; i<nBits; i++) {
  38. pad.in[i] <== in[i];
  39. }
  40. }