We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a97e042 commit c5f4331Copy full SHA for c5f4331
sdk/zklogin/src/poseidon.ts
@@ -39,7 +39,16 @@ const poseidonNumToHashFN = [
39
poseidon16,
40
];
41
42
+export const BN254_FIELD_SIZE = 21888242871839275222246405745257275088548364400416034343698204186575808495617n;
43
+
44
export function poseidonHash(inputs: (number | bigint | string)[]): bigint {
45
+ inputs.forEach(x => {
46
+ const b = BigInt(x);
47
+ if (b < 0 || b >= BN254_FIELD_SIZE) {
48
+ throw new Error(`Element ${b} not in the BN254 field`);
49
+ }
50
+ });
51
52
const hashFN = poseidonNumToHashFN[inputs.length - 1];
53
54
if (hashFN) {
0 commit comments