grapevine-sonobe/circom/node_modules/circomlib/circuits/smt/smthash_mimc.circom
circom/node_modules/circomlib/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*/
19pragma circom 2.0.0;
20
21include "../mimc.circom";
22
23
24/*
25 Hash1 = H(1 | key | value)
26 */
27
28template SMTHash1() {
29 signal input key;
30 signal input value;
31 signal output out;
32
33 component h = MultiMiMC7(2, 91); // Constant
34 h.in[0] <== key;
35 h.in[1] <== value;
36 h.k <== 1;
37
38 out <== h.out;
39}
40
41/*
42 This component is used to create the 2 nodes.
43
44 Hash2 = H(Hl | Hr)
45 */
46
47template SMTHash2() {
48 signal input L;
49 signal input R;
50 signal output out;
51
52 component h = MultiMiMC7(2, 91); // Constant
53 h.in[0] <== L;
54 h.in[1] <== R;
55 h.k <== 0;
56
57 out <== h.out;
58}