From c5e4b37fc3e3f11688df0c8ecf5ef18644e2ed62 Mon Sep 17 00:00:00 2001 From: Kobi Gurkan Date: Sat, 11 May 2019 22:00:29 +0300 Subject: [PATCH] fix: fixes tests to use bigInts in multiHash --- semaphorejs/test/circuit/circuit.js | 4 ++-- semaphorejs/test/contracts/semaphore.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/semaphorejs/test/circuit/circuit.js b/semaphorejs/test/circuit/circuit.js index 06ee7f7d..9086b075 100644 --- a/semaphorejs/test/circuit/circuit.js +++ b/semaphorejs/test/circuit/circuit.js @@ -56,14 +56,14 @@ describe('circuit test', function () { const signal_hash = bigInt('5'); const broadcaster_address = bigInt('0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413'); - const msg = mimc7.multiHash([external_nullifier, signal_hash, broadcaster_address]); + const msg = mimc7.multiHash([bigInt(external_nullifier), bigInt(signal_hash), bigInt(broadcaster_address)]); const signature = eddsa.signMiMC(prvKey, msg); assert(eddsa.verifyMiMC(msg, signature, pubKey)); const identity_nullifier = bigInt('230'); const identity_r = bigInt('12311'); - const tree = build_merkle_tree_example(20, mimc7.multiHash([pubKey[0], pubKey[1], identity_nullifier, identity_r])); + const tree = build_merkle_tree_example(20, mimc7.multiHash([bigInt(pubKey[0]), bigInt(pubKey[1]), bigInt(identity_nullifier), bigInt(identity_r)])); const identity_path_elements = tree[1]; const identity_path_index = tree[2]; diff --git a/semaphorejs/test/contracts/semaphore.js b/semaphorejs/test/contracts/semaphore.js index 3978412e..07bbda06 100644 --- a/semaphorejs/test/contracts/semaphore.js +++ b/semaphorejs/test/contracts/semaphore.js @@ -74,7 +74,7 @@ contract('Semaphore', function () { const signal_to_contract = web3.utils.asciiToHex(signal_str); const broadcaster_address = bigInt('0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413'); - const msg = mimc7.multiHash([external_nullifier, signal_hash, broadcaster_address]); + const msg = mimc7.multiHash([bigInt(external_nullifier), bigInt(signal_hash), bigInt(broadcaster_address)]); const signature = eddsa.signMiMC(prvKey, msg); assert(eddsa.verifyMiMC(msg, signature, pubKey)); @@ -98,7 +98,7 @@ contract('Semaphore', function () { default_value, ); - const identity_commitment = mimc7.multiHash([pubKey[0], pubKey[1], identity_nullifier, identity_r]); + const identity_commitment = mimc7.multiHash([bigInt(pubKey[0]), bigInt(pubKey[1]), bigInt(identity_nullifier), bigInt(identity_r)]); await tree.update(0, identity_commitment.toString()); const identity_path = await tree.path(0);