// Copyright (c) 2018 Jordi Baylina // License: LGPL-3.0+ // const Contract = require("./evmasm"); const { unstringifyBigInts } = require("ffjavascript").utils; const Web3Utils = require("web3-utils"); const { C:K, M } = unstringifyBigInts(require("./poseidon_constants.json")); const N_ROUNDS_F = 8; const N_ROUNDS_P = [56, 57, 56, 60, 60, 63, 64, 63]; function toHex256(a) { let S = a.toString(16); while (S.length < 64) S="0"+S; return "0x" + S; } function createCode(nInputs) { if (( nInputs<1) || (nInputs>8)) throw new Error("Invalid number of inputs. Must be 1<=nInputs<=8"); const t = nInputs + 1; const nRoundsF = N_ROUNDS_F; const nRoundsP = N_ROUNDS_P[t - 2]; const C = new Contract(); function saveM() { for (let i=0; i=nRoundsP+nRoundsF/2)) { for (let j=0; j