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 +----+
15PUB_address+--->+ != +<---+0
16 +----+
17
18
19
20*/
21
22include "../node_modules/circomlib/circuits/babyjub.circom";
23include "../node_modules/circomlib/circuits/comparators.circom";
24include "../node_modules/circomlib/circuits/poseidon.circom";
25include "../node_modules/circomlib/circuits/bitify.circom";
26include "../node_modules/circomlib/circuits/smt/smtverifier.circom";
27include "../node_modules/circomlib/circuits/smt/smtprocessor.circom";
28
29template Withdraw() {
30 signal input coinCode;
31 signal input amount;
32 signal input commitment;
33 signal private input secret;
34 signal input address;
35
36 component hash = Poseidon(3, 6, 8, 57);
37 hash.inputs[0] <== coinCode;
38 hash.inputs[1] <== amount;
39 hash.inputs[2] <== secret;
40
41 component eq = IsEqual();
42 eq.in[0] <== hash.out;
43 eq.in[1] <== commitment;
44 eq.out === 1;
45
46 component z = IsZero();
47 z.in <== address;
48 z.out === 0;
49}
50
51component main = Withdraw();