arnaucube
arnaucube/miksi-corePublic Self-hosted repository
miksi-core/circuits/withdraw.circom
circuits/withdraw.circomRaw
 1/*
 2# withdraw.circom
 3
 4WARNING: WIP, very initial version of the miksi circuit
 5
 6                     +--------+
 7PUB_coinCode+------->+        |
 8                     |        |        +----+
 9PUB_amount+--------->+Poseidon+------->+ == +<-----+PUB_commitment
10                     |        |        +----+
11PRI_secret+--------->+        |
12                     +--------+
13
14
15
16*/
17
18include "../node_modules/circomlib/circuits/babyjub.circom";
19include "../node_modules/circomlib/circuits/comparators.circom";
20include "../node_modules/circomlib/circuits/poseidon.circom";
21include "../node_modules/circomlib/circuits/bitify.circom";
22include "../node_modules/circomlib/circuits/smt/smtverifier.circom";
23include "../node_modules/circomlib/circuits/smt/smtprocessor.circom";
24
25template Withdraw() {
26	signal input coinCode;
27	signal input amount;
28	signal input commitment;
29	signal private input secret;
30
31	component hash = Poseidon(3, 6, 8, 57);
32	hash.inputs[0] <== coinCode;
33	hash.inputs[1] <== amount;
34	hash.inputs[2] <== secret;
35
36	component eq = IsEqual();
37	eq.in[0] <== hash.out;
38	eq.in[1] <== commitment;
39	eq.out === 1;
40}
41
42component main = Withdraw();