Skip to content

Commit

Permalink
performance optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
Kolezhniuk committed Jan 19, 2023
1 parent 7f9c32a commit 94eca10
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@iden3/js-crypto",
"version": "0.0.3",
"version": "0.0.4",
"description": "",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
Expand Down
12 changes: 6 additions & 6 deletions src/poseidon/poseidon-opt.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { F1Field, Scalar, utils } from '../ff';
import op from './poseidon-constants-opt.json';

export const OPT = utils.unstringifyBigInts(op);

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];
const SPONGE_INPUTS = 16;
Expand All @@ -19,15 +21,13 @@ export class Poseidon {
throw new Error('Invalid inputs');
}

const opt = utils.unstringifyBigInts(op);

const t = inputs.length + 1;
const nRoundsF = N_ROUNDS_F;
const nRoundsP = N_ROUNDS_P[t - 2];
const C = opt.C[t - 2];
const S = opt.S[t - 2];
const M = opt.M[t - 2];
const P = opt.P[t - 2];
const C = OPT.C[t - 2];
const S = OPT.S[t - 2];
const M = OPT.M[t - 2];
const P = OPT.P[t - 2];

let state: bigint[] = [F.zero, ...inputs.map((a) => F.e(a))];

Expand Down

0 comments on commit 94eca10

Please sign in to comment.