Merge pull request #24 from peppersec/audit-6

Audit 6
This commit is contained in:
Roman Storm 2019-11-18 12:03:44 -08:00 committed by GitHub
commit d0e312eb80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 6 deletions

View File

@ -15,7 +15,7 @@ template HashLeftRight() {
// if s == 0 returns [in[0], in[1]] // if s == 0 returns [in[0], in[1]]
// if s == 1 returns [in[1], in[0]] // if s == 1 returns [in[1], in[0]]
template Mux() { template DualMux() {
signal input in[2]; signal input in[2];
signal input s; signal input s;
signal output out[2]; signal output out[2];
@ -36,7 +36,7 @@ template MerkleTree(levels) {
component hashers[levels]; component hashers[levels];
for (var i = 0; i < levels; i++) { for (var i = 0; i < levels; i++) {
selectors[i] = Mux(); selectors[i] = DualMux();
selectors[i].in[0] <== i == 0 ? leaf : hashers[i - 1].hash; selectors[i].in[0] <== i == 0 ? leaf : hashers[i - 1].hash;
selectors[i].in[1] <== pathElements[i]; selectors[i].in[1] <== pathElements[i];
selectors[i].s <== pathIndices[i]; selectors[i].s <== pathIndices[i];

View File

@ -17,7 +17,7 @@ library Hasher {
contract MerkleTreeWithHistory { contract MerkleTreeWithHistory {
uint256 public constant FIELD_SIZE = 21888242871839275222246405745257275088548364400416034343698204186575808495617; uint256 public constant FIELD_SIZE = 21888242871839275222246405745257275088548364400416034343698204186575808495617;
uint256 public constant ZERO_VALUE = 5702960885942360421128284892092891246826997279710054143430547229469817701242; // = MiMC("tornado") uint256 public constant ZERO_VALUE = 21663839004416932945382355908790599225266501822907911457504978515578255421292; // = keccak256("tornado") % FIELD_SIZE
uint32 public levels; uint32 public levels;

View File

@ -11,7 +11,7 @@ class MerkleTree {
this.zero_values = [] this.zero_values = []
this.totalElements = 0 this.totalElements = 0
let current_zero_value = '5702960885942360421128284892092891246826997279710054143430547229469817701242' let current_zero_value = '21663839004416932945382355908790599225266501822907911457504978515578255421292'
this.zero_values.push(current_zero_value) this.zero_values.push(current_zero_value)
for (let i = 0; i < n_levels; i++) { for (let i = 0; i < n_levels; i++) {
current_zero_value = this.hasher.hash(i, current_zero_value, current_zero_value) current_zero_value = this.hasher.hash(i, current_zero_value, current_zero_value)

View File

@ -321,14 +321,14 @@ contract('ETHMixer', accounts => {
await mixer.deposit(toFixedHex(deposit.commitment), { value, from: sender }) await mixer.deposit(toFixedHex(deposit.commitment), { value, from: sender })
const { root, path_elements, path_index } = await tree.path(0) const { root, path_elements, path_index } = await tree.path(0)
const oneEtherFee = bigInt(1e18) // 1 ether const largeFee = bigInt(value).add(bigInt(1))
const input = stringifyBigInts({ const input = stringifyBigInts({
root, root,
nullifierHash: pedersenHash(deposit.nullifier.leInt2Buff(31)), nullifierHash: pedersenHash(deposit.nullifier.leInt2Buff(31)),
nullifier: deposit.nullifier, nullifier: deposit.nullifier,
relayer: operator, relayer: operator,
recipient, recipient,
fee: oneEtherFee, fee: largeFee,
refund, refund,
secret: deposit.secret, secret: deposit.secret,
pathElements: path_elements, pathElements: path_elements,