Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions build/main.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -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];
Expand Down
8 changes: 4 additions & 4 deletions src/poseidon_opt.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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];
Expand Down
8 changes: 4 additions & 4 deletions src/poseidon_reference.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down