Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
*/
const crypto = require('crypto');
const path = require('path');
const {unstringifyBigInts, stringifyBigInts} = require('websnark/tools/stringifybigint.js');
const chai = require('chai');
const assert = chai.assert;
const snarkjs = require('snarkjs');
const circomlib = require('circomlib');
const bigInt = snarkjs.bigInt;
const eddsa = circomlib.eddsa;
const mimcsponge = circomlib.mimcsponge;
const proof_util = require('../util');
const fetch = require('node-fetch');
const Web3 = require('web3');
const ethers = require('ethers');
let logger;
/* uint8array to hex */
function hex(byteArray) {
return Array.prototype.map.call(byteArray, function(byte) {
return ('0' + (byte & 0xFF).toString(16)).slice(-2);
* semaphorejs is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with semaphorejs. If not, see .
*/
const chai = require('chai');
const snarkjs = require('snarkjs');
const circomlib = require('circomlib');
const bigInt = snarkjs.bigInt;
const mimcsponge = circomlib.mimcsponge;
let build_merkle_tree_example = (n_levels, identity_commitment) => {
let current_index = 0;
let path_index = [];
let path_elements = [];
let current_element = identity_commitment;
for (let i = 0; i < n_levels; i++) {
path_elements.push(bigInt(0));
current_element = mimcsponge.multiHash([ bigInt(current_element), bigInt(0) ]);
path_index.push(current_index % 2);
current_index = Math.floor(current_index / 2);
}
const root = current_element;
const circomlib = require('circomlib')
const mimcsponge = circomlib.mimcsponge
const snarkjs = require('snarkjs')
const bigInt = snarkjs.bigInt
class MimcSpongeHasher {
hash(level, left, right) {
return mimcsponge.multiHash([bigInt(left), bigInt(right)]).toString()
}
}
module.exports = MimcSpongeHasher