const bigInt = require("big-integer"); const ZqField = require("ffjavascript").ZqField; const Web3Utils = require("web3-utils"); const F = new ZqField(bigInt("21888242871839275222246405745257275088548364400416034343698204186575808495617")); const SEED = "mimc"; const NROUNDS = 91; exports.getIV = (seed) => { if (typeof seed === "undefined") seed = SEED; const c = Web3Utils.keccak256(seed+"_iv"); const cn = bigInt(Web3Utils.toBN(c).toString()); const iv = cn.mod(F.p); return iv; }; exports.getConstants = (seed, nRounds) => { if (typeof seed === "undefined") seed = SEED; if (typeof nRounds === "undefined") nRounds = NROUNDS; const cts = new Array(nRounds); let c = Web3Utils.keccak256(SEED); for (let i=1; i{ const x_in = bigInt(_x_in); const k = bigInt(_k); let r; for (let i=0; i { let r; if (typeof(key) === "undefined") { r = F.zero; } else { r = key; } for (let i=0; i