Skip to content

Commit 0eed61b

Browse files
committed
fix: add error if bits under 2
1 parent 7535b91 commit 0eed61b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

hasher.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ export class Hasher {
3333
static generate(
3434
bits?: number,
3535
): HasherOptions {
36-
bits = bits ?? Number.MAX_SAFE_INTEGER.toString(2).length;
36+
bits = bits ?? Number.MAX_SAFE_INTEGER.toString(2).length; // default to Number.MAX_SAFE_INTEGER
37+
if (bits < 2) {
38+
throw new Error("bits must be greater than 2");
39+
}
3740
const modBase = 2n ** BigInt(bits);
3841
const prime = randomPrime(bits);
3942
return {

0 commit comments

Comments
 (0)