const Scalar = require("ffjavascript").Scalar const Web3Utils = require("web3-utils"); const ZqField = require("ffjavascript").ZqField; const F = new ZqField(Scalar.fromString("21888242871839275222246405745257275088548364400416034343698204186575808495617")); const SEED = "mimcsponge"; const NROUNDS = 220; exports.getIV = (seed) => { if (typeof seed === "undefined") seed = SEED; const c = Web3Utils.keccak256(seed+"_iv"); const cn = Scalar.fromString(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{ let xL = F.e(_xL_in); let xR = F.e(_xR_in); const k = F.e(_k); for (let i=0; i { if (typeof(numOutputs) === "undefined") { numOutputs = 1; } if (typeof(key) === "undefined") { key = F.zero; } let R = F.zero; let C = F.zero; for (let i=0; i F.normalize(x)); } };