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.

57 lines
1.3 KiB

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 "../mimc.circom";
  16. /*
  17. Hash1 = H(1 | key | value)
  18. */
  19. template SMTHash1() {
  20. signal input key;
  21. signal input value;
  22. signal output out;
  23. component h = MultiMiMC7(2, 91); // Constant
  24. h.in[0] <== key;
  25. h.in[1] <== value;
  26. h.k <== 1;
  27. out <== h.out;
  28. }
  29. /*
  30. This component is used to create the 2 nodes.
  31. Hash2 = H(Hl | Hr)
  32. */
  33. template SMTHash2() {
  34. signal input L;
  35. signal input R;
  36. signal output out;
  37. component h = MultiMiMC7(2, 91); // Constant
  38. h.in[0] <== L;
  39. h.in[1] <== R;
  40. h.k <== 0;
  41. out <== h.out;
  42. }