Skip to content

Commit

Permalink
feat(poseidon): support from 1 to 16 posedion inputs
Browse files Browse the repository at this point in the history
re #238
  • Loading branch information
cedoor committed Apr 10, 2024
1 parent 660c98d commit e40723c
Show file tree
Hide file tree
Showing 40 changed files with 15,514 additions and 504 deletions.
85 changes: 78 additions & 7 deletions packages/poseidon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,84 @@
"default": "./dist/index.js"
},
"./1": {
"types": "./dist/types/1/index.d.ts",
"require": "./dist/lib.commonjs/1/index.cjs",
"default": "./dist/lib.esm/1/index.js"
"types": "./dist/types/poseidon-1/index.d.ts",
"require": "./dist/lib.commonjs/poseidon-1/index.cjs",
"default": "./dist/lib.esm/poseidon-1/index.js"
},
"./2": {
"types": "./dist/types/2/index.d.ts",
"require": "./dist/lib.commonjs/2/index.cjs",
"default": "./dist/lib.esm/2/index.js"
"types": "./dist/types/poseidon-2/index.d.ts",
"require": "./dist/lib.commonjs/poseidon-2/index.cjs",
"default": "./dist/lib.esm/poseidon-2/index.js"
},
"./3": {
"types": "./dist/types/poseidon-3/index.d.ts",
"require": "./dist/lib.commonjs/poseidon-3/index.cjs",
"default": "./dist/lib.esm/poseidon-3/index.js"
},
"./4": {
"types": "./dist/types/poseidon-4/index.d.ts",
"require": "./dist/lib.commonjs/poseidon-4/index.cjs",
"default": "./dist/lib.esm/poseidon-4/index.js"
},
"./5": {
"types": "./dist/types/poseidon-5/index.d.ts",
"require": "./dist/lib.commonjs/poseidon-5/index.cjs",
"default": "./dist/lib.esm/poseidon-5/index.js"
},
"./6": {
"types": "./dist/types/poseidon-6/index.d.ts",
"require": "./dist/lib.commonjs/poseidon-6/index.cjs",
"default": "./dist/lib.esm/poseidon-6/index.js"
},
"./7": {
"types": "./dist/types/poseidon-7/index.d.ts",
"require": "./dist/lib.commonjs/poseidon-7/index.cjs",
"default": "./dist/lib.esm/poseidon-7/index.js"
},
"./8": {
"types": "./dist/types/poseidon-8/index.d.ts",
"require": "./dist/lib.commonjs/poseidon-8/index.cjs",
"default": "./dist/lib.esm/poseidon-8/index.js"
},
"./9": {
"types": "./dist/types/poseidon-9/index.d.ts",
"require": "./dist/lib.commonjs/poseidon-9/index.cjs",
"default": "./dist/lib.esm/poseidon-9/index.js"
},
"./10": {
"types": "./dist/types/poseidon-10/index.d.ts",
"require": "./dist/lib.commonjs/poseidon-10/index.cjs",
"default": "./dist/lib.esm/poseidon-10/index.js"
},
"./11": {
"types": "./dist/types/poseidon-11/index.d.ts",
"require": "./dist/lib.commonjs/poseidon-11/index.cjs",
"default": "./dist/lib.esm/poseidon-11/index.js"
},
"./12": {
"types": "./dist/types/poseidon-12/index.d.ts",
"require": "./dist/lib.commonjs/poseidon-12/index.cjs",
"default": "./dist/lib.esm/poseidon-12/index.js"
},
"./13": {
"types": "./dist/types/poseidon-13/index.d.ts",
"require": "./dist/lib.commonjs/poseidon-13/index.cjs",
"default": "./dist/lib.esm/poseidon-13/index.js"
},
"./14": {
"types": "./dist/types/poseidon-14/index.d.ts",
"require": "./dist/lib.commonjs/poseidon-14/index.cjs",
"default": "./dist/lib.esm/poseidon-14/index.js"
},
"./15": {
"types": "./dist/types/poseidon-15/index.d.ts",
"require": "./dist/lib.commonjs/poseidon-15/index.cjs",
"default": "./dist/lib.esm/poseidon-15/index.js"
},
"./16": {
"types": "./dist/types/poseidon-16/index.d.ts",
"require": "./dist/lib.commonjs/poseidon-16/index.cjs",
"default": "./dist/lib.esm/poseidon-16/index.js"
}
},
"files": [
Expand Down Expand Up @@ -54,6 +124,7 @@
"rollup-plugin-cleanup": "^3.2.1"
},
"dependencies": {
"@noble/curves": "^1.4.0"
"@noble/curves": "1.4.0",
"@zk-kit/utils": "1.0.0-beta"
}
}
15 changes: 15 additions & 0 deletions packages/poseidon/src/getConstants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { base64ToBigInt } from "@zk-kit/utils/conversions"
import { Constants } from "./types"

/**
* Converts Poseidon base64 constants to bigints.
* @param C Rounds constants.
* @param M TxT matrix.
* @returns An object with all bigint constants.
*/
export default function getConstants(C: string[][], M: string[][]): Constants {
return {
C: C.map((l) => l.map(base64ToBigInt)),
M: M.map((l) => l.map(base64ToBigInt))
}
}
35 changes: 34 additions & 1 deletion packages/poseidon/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,40 @@
import poseidon1 from "./poseidon-1"
import poseidon10 from "./poseidon-10"
import poseidon11 from "./poseidon-11"
import poseidon12 from "./poseidon-12"
import poseidon13 from "./poseidon-13"
import poseidon14 from "./poseidon-14"
import poseidon15 from "./poseidon-15"
import poseidon16 from "./poseidon-16"
import poseidon2 from "./poseidon-2"
import poseidon3 from "./poseidon-3"
import poseidon4 from "./poseidon-4"
import poseidon5 from "./poseidon-5"
import poseidon6 from "./poseidon-6"
import poseidon7 from "./poseidon-7"
import poseidon8 from "./poseidon-8"
import poseidon9 from "./poseidon-9"

import poseidon from "./poseidon"

export * from "./types"

export { poseidon, poseidon1, poseidon2 }
export {
poseidon,
poseidon1,
poseidon10,
poseidon11,
poseidon12,
poseidon13,
poseidon14,
poseidon15,
poseidon16,
poseidon2,
poseidon3,
poseidon4,
poseidon5,
poseidon6,
poseidon7,
poseidon8,
poseidon9
}
Loading

0 comments on commit e40723c

Please sign in to comment.