2020-04-08 11:41:12 +02:00
|
|
|
include "../node_modules/circomlib/circuits/pointbits.circom";
|
|
|
|
include "../node_modules/circomlib/circuits/compconstant.circom";
|
2021-06-06 19:31:32 +02:00
|
|
|
include "../node_modules/circomlib/circuits/poseidon.circom";
|
2020-04-08 11:41:12 +02:00
|
|
|
|
|
|
|
|
|
|
|
template Keypair() {
|
|
|
|
signal input privateKey;
|
|
|
|
signal output publicKey;
|
|
|
|
|
2021-06-06 19:31:32 +02:00
|
|
|
component hasher = Poseidon(1);
|
|
|
|
hasher.inputs[0] <== privateKey;
|
|
|
|
publicKey <== hasher.out;
|
2020-04-08 11:41:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template TransactionHasher() {
|
|
|
|
signal input amount;
|
|
|
|
signal input blinding;
|
|
|
|
signal input publicKey;
|
|
|
|
|
|
|
|
signal output commitment;
|
|
|
|
|
2021-06-06 19:31:32 +02:00
|
|
|
component hasher = Poseidon(3);
|
|
|
|
hasher.inputs[0] <== amount;
|
|
|
|
hasher.inputs[1] <== blinding;
|
|
|
|
hasher.inputs[2] <== publicKey;
|
|
|
|
commitment <== hasher.out;
|
2020-04-08 11:41:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template NullifierHasher() {
|
|
|
|
signal input privateKey;
|
|
|
|
signal input merklePath;
|
|
|
|
signal input commitment;
|
|
|
|
|
|
|
|
signal output nullifier;
|
2020-04-09 11:04:06 +02:00
|
|
|
|
2021-06-06 19:31:32 +02:00
|
|
|
component hasher = Poseidon(3);
|
|
|
|
hasher.inputs[0] <== commitment;
|
|
|
|
hasher.inputs[1] <== merklePath;
|
|
|
|
hasher.inputs[2] <== privateKey;
|
|
|
|
nullifier <== hasher.out;
|
2020-04-08 11:41:12 +02:00
|
|
|
}
|