circomlib/circuits/smt/smthash_mimc.circom
circuits/smt/smthash_mimc.circomRaw
1/*
2 Copyright 2018 0KIMS association.
3
4 This file is part of circom (Zero Knowledge Circuit Compiler).
5
6 circom is a free software: you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 circom is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
14 License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with circom. If not, see <https://www.gnu.org/licenses/>.
18*/
19
20include "../mimc.circom";
21
22
23/*
24 Hash1 = H(1 | key | value)
25 */
26
27template SMTHash1() {
28 signal input key;
29 signal input value;
30 signal output out;
31
32 component h = MultiMiMC7(2, 91); // Constant
33 h.in[0] <== key;
34 h.in[1] <== value;
35 h.k <== 1;
36
37 out <== h.out;
38}
39
40/*
41 This component is used to create the 2 nodes.
42
43 Hash2 = H(Hl | Hr)
44 */
45
46template SMTHash2() {
47 signal input L;
48 signal input R;
49 signal output out;
50
51 component h = MultiMiMC7(2, 91); // Constant
52 h.in[0] <== L;
53 h.in[1] <== R;
54 h.k <== 0;
55
56 out <== h.out;
57}