Skip to content

Commit 0523ec8

Browse files
IlyasRidhuanalexghr
authored andcommitted
fix: throw when making Fr from negatives
1 parent cadc2b7 commit 0523ec8

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

yarn-project/foundation/src/fields/fields.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ abstract class BaseField {
6060
this.asBigInt = BigInt(value);
6161
if (this.asBigInt >= this.modulus()) {
6262
throw new Error(`Value 0x${this.asBigInt.toString(16)} is greater or equal to field modulus.`);
63+
} else if (this.asBigInt < 0n) {
64+
throw new Error(`Value 0x${this.asBigInt.toString(16)} is negative.`);
6365
}
6466
} else if (value instanceof BaseField) {
6567
this.asBuffer = value.asBuffer;

0 commit comments

Comments
 (0)