tornado-nova/circuits/utils.circom

48 lines
1.1 KiB
Plaintext
Raw Normal View History

2020-04-08 11:41:12 +02:00
include "../node_modules/circomlib/circuits/pointbits.circom";
include "../node_modules/circomlib/circuits/compconstant.circom";
include "../node_modules/circomlib/circuits/mimcsponge.circom";
template Keypair() {
signal input privateKey;
signal output publicKey;
2020-04-09 20:38:10 +02:00
component hasher = MiMCSponge(1, 1);
hasher.ins[0] <== privateKey;
hasher.k <== 0;
publicKey <== hasher.outs[0];
2020-04-08 11:41:12 +02:00
}
template TransactionHasher() {
signal input amount;
signal input blinding;
signal input publicKey;
signal output commitment;
2020-04-09 11:04:06 +02:00
component hasher = MiMCSponge(3, 1);
2020-04-08 11:41:12 +02:00
hasher.ins[0] <== amount;
hasher.ins[1] <== blinding;
hasher.ins[2] <== publicKey;
hasher.k <== 0;
commitment <== hasher.outs[0];
}
template NullifierHasher() {
signal input privateKey;
signal input merklePath;
signal input commitment;
signal output nullifier;
2020-04-09 11:04:06 +02:00
component hasher = MiMCSponge(3, 1);
2020-04-08 11:41:12 +02:00
hasher.ins[0] <== commitment;
hasher.ins[1] <== merklePath;
hasher.ins[2] <== privateKey;
hasher.k <== 0;
nullifier <== hasher.outs[0];
}