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.

58 lines
1.3 KiB

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