anonymity-mining/circuits/Utils.circom

26 lines
892 B
Plaintext
Raw Permalink Normal View History

include "../node_modules/@tornado/circomlib/circuits/bitify.circom";
include "../node_modules/@tornado/circomlib/circuits/pedersen.circom";
2020-12-15 18:08:37 +03:00
// 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];
}