// Copyright (c) 2018 Jordi Baylina // License: LGPL-3.0+ // import Contract from "./evmasm.js"; import { utils } from "ffjavascript"; const { unstringifyBigInts } = utils; import ethers from "ethers"; import poseidonConstants from "./poseidon_constants.js"; const { C:K, M } = unstringifyBigInts(poseidonConstants); 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; } export 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