Skip to content

Commit

Permalink
Fix check
Browse files Browse the repository at this point in the history
  • Loading branch information
Kolezhniuk committed Jan 20, 2025
1 parent 5a6fce1 commit 87ab752
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/poseidon/poseidon-opt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class Poseidon {
throw new Error('Invalid inputs');
}

if (inputs.some((i) => i > F.p)) {
if (inputs.some((i) => i < 0 || i >= F.p)) {
throw new Error(`One or more inputs are not in the field: ${F.p}`);
}

Expand Down
4 changes: 4 additions & 0 deletions tests/poseidon.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,9 @@ describe('Poseidon test', () => {
expect(() => poseidon.hash([1n, 1n + poseidon.F.p])).toThrow(
`One or more inputs are not in the field: ${poseidon.F.p}`
);

expect(() => poseidon.hash([1n, 1n - poseidon.F.p])).toThrow(
`One or more inputs are not in the field: ${poseidon.F.p}`
);
});
});

0 comments on commit 87ab752

Please sign in to comment.