mirror of
https://github.com/tornadocash/tornado-anonymity-mining.git
synced 2024-11-22 17:50:21 +01:00
26 lines
874 B
Plaintext
26 lines
874 B
Plaintext
|
include "../node_modules/circomlib/circuits/bitify.circom";
|
||
|
include "../node_modules/circomlib/circuits/pedersen.circom";
|
||
|
|
||
|
// computes Pedersen(nullifier + secret)
|
||
|
template TornadoCommitmentHasher() {
|
||
|
signal input nullifier;
|
||
|
signal input secret;
|
||
|
signal output commitment;
|
||
|
signal output nullifierHash;
|
||
|
|
||
|
component commitmentHasher = Pedersen(496);
|
||
|
component nullifierHasher = Pedersen(248);
|
||
|
component nullifierBits = Num2Bits(248);
|
||
|
component secretBits = Num2Bits(248);
|
||
|
nullifierBits.in <== nullifier;
|
||
|
secretBits.in <== secret;
|
||
|
for (var i = 0; i < 248; i++) {
|
||
|
nullifierHasher.in[i] <== nullifierBits.out[i];
|
||
|
commitmentHasher.in[i] <== nullifierBits.out[i];
|
||
|
commitmentHasher.in[i + 248] <== secretBits.out[i];
|
||
|
}
|
||
|
|
||
|
commitment <== commitmentHasher.out[0];
|
||
|
nullifierHash <== nullifierHasher.out[0];
|
||
|
}
|