diff --git a/build/main.cjs b/build/main.cjs index 41b3edb..2da078c 100644 --- a/build/main.cjs +++ b/build/main.cjs @@ -26807,19 +26807,19 @@ var _poseidonContract = /*#__PURE__*/Object.freeze({ generateABI: generateABI }); -function unsringifyConstants$1(Fr, o) { +function unstringifyConstants$1(Fr, o) { if ((typeof(o) == "string") && (/^[0-9]+$/.test(o) )) { return Fr.e(o); } else if ((typeof(o) == "string") && (/^0x[0-9a-fA-F]+$/.test(o) )) { return Fr.e(o); } else if (Array.isArray(o)) { - return o.map(unsringifyConstants$1.bind(null, Fr)); + return o.map(unstringifyConstants$1.bind(null, Fr)); } else if (typeof o == "object") { if (o===null) return null; const res = {}; const keys = Object.keys(o); keys.forEach( (k) => { - res[k] = unsringifyConstants$1(Fr, o[k]); + res[k] = unstringifyConstants$1(Fr, o[k]); }); return res; } else { @@ -26834,7 +26834,7 @@ async function buildPoseidon$1() { // Parameters are generated by a reference script https://extgit.iaik.tugraz.at/krypto/hadeshash/-/blob/master/code/generate_parameters_grain.sage // Used like so: sage generate_parameters_grain.sage 1 0 254 2 8 56 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001 - const {C, M} = unsringifyConstants$1(F, poseidonConstants); + const {C, M} = unstringifyConstants$1(F, poseidonConstants); // Using recommended parameters from whitepaper https://eprint.iacr.org/2019/458.pdf (table 2, table 8) // Generated by https://extgit.iaik.tugraz.at/krypto/hadeshash/-/blob/master/code/calc_round_numbers.py @@ -26886,19 +26886,19 @@ async function buildPoseidon$1() { // Parameters are generated by a reference script https://extgit.iaik.tugraz.at/krypto/hadeshash/-/blob/master/code/generate_parameters_grain.sage -function unsringifyConstants(Fr, o) { +function unstringifyConstants(Fr, o) { if ((typeof(o) == "string") && (/^[0-9]+$/.test(o) )) { return Fr.e(o); } else if ((typeof(o) == "string") && (/^0x[0-9a-fA-F]+$/.test(o) )) { return Fr.e(o); } else if (Array.isArray(o)) { - return o.map(unsringifyConstants.bind(null, Fr)); + return o.map(unstringifyConstants.bind(null, Fr)); } else if (typeof o == "object") { if (o===null) return null; const res = {}; const keys = Object.keys(o); keys.forEach( (k) => { - res[k] = unsringifyConstants(Fr, o[k]); + res[k] = unstringifyConstants(Fr, o[k]); }); return res; } else { @@ -26911,7 +26911,7 @@ async function buildPoseidon() { const F = bn128.Fr; - const opt = unsringifyConstants(F, poseidonConstants$1); + const opt = unstringifyConstants(F, poseidonConstants$1); const N_ROUNDS_F = 8; const N_ROUNDS_P = [56, 57, 56, 60, 60, 63, 64, 63, 60, 66, 60, 65, 70, 60, 64, 68]; diff --git a/src/poseidon_opt.js b/src/poseidon_opt.js index f9d2692..b647a29 100644 --- a/src/poseidon_opt.js +++ b/src/poseidon_opt.js @@ -12,19 +12,19 @@ import { getCurveFromName } from "ffjavascript"; import poseidonConstants from "./poseidon_constants_opt.js"; -function unsringifyConstants(Fr, o) { +function unstringifyConstants(Fr, o) { if ((typeof(o) == "string") && (/^[0-9]+$/.test(o) )) { return Fr.e(o); } else if ((typeof(o) == "string") && (/^0x[0-9a-fA-F]+$/.test(o) )) { return Fr.e(o); } else if (Array.isArray(o)) { - return o.map(unsringifyConstants.bind(null, Fr)); + return o.map(unstringifyConstants.bind(null, Fr)); } else if (typeof o == "object") { if (o===null) return null; const res = {}; const keys = Object.keys(o); keys.forEach( (k) => { - res[k] = unsringifyConstants(Fr, o[k]); + res[k] = unstringifyConstants(Fr, o[k]); }); return res; } else { @@ -37,7 +37,7 @@ export default async function buildPoseidon() { const F = bn128.Fr; - const opt = unsringifyConstants(F, poseidonConstants); + const opt = unstringifyConstants(F, poseidonConstants); const N_ROUNDS_F = 8; const N_ROUNDS_P = [56, 57, 56, 60, 60, 63, 64, 63, 60, 66, 60, 65, 70, 60, 64, 68]; diff --git a/src/poseidon_reference.js b/src/poseidon_reference.js index a57f52f..a4ea5f6 100644 --- a/src/poseidon_reference.js +++ b/src/poseidon_reference.js @@ -4,19 +4,19 @@ import { getCurveFromName } from "ffjavascript"; import poseidonConstants from "./poseidon_constants.js"; -function unsringifyConstants(Fr, o) { +function unstringifyConstants(Fr, o) { if ((typeof(o) == "string") && (/^[0-9]+$/.test(o) )) { return Fr.e(o); } else if ((typeof(o) == "string") && (/^0x[0-9a-fA-F]+$/.test(o) )) { return Fr.e(o); } else if (Array.isArray(o)) { - return o.map(unsringifyConstants.bind(null, Fr)); + return o.map(unstringifyConstants.bind(null, Fr)); } else if (typeof o == "object") { if (o===null) return null; const res = {}; const keys = Object.keys(o); keys.forEach( (k) => { - res[k] = unsringifyConstants(Fr, o[k]); + res[k] = unstringifyConstants(Fr, o[k]); }); return res; } else { @@ -31,7 +31,7 @@ export default async function buildPoseidon() { // Parameters are generated by a reference script https://extgit.iaik.tugraz.at/krypto/hadeshash/-/blob/master/code/generate_parameters_grain.sage // Used like so: sage generate_parameters_grain.sage 1 0 254 2 8 56 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001 - const {C, M} = unsringifyConstants(F, poseidonConstants); + const {C, M} = unstringifyConstants(F, poseidonConstants); // Using recommended parameters from whitepaper https://eprint.iacr.org/2019/458.pdf (table 2, table 8) // Generated by https://extgit.iaik.tugraz.at/krypto/hadeshash/-/blob/master/code/calc_round_numbers.py