Skip to content

Commit 95aa2a7

Browse files
authored
fix: throw when making Fr from negatives (#16002)
Part 2 - because i opened the original against master....
2 parents 7b4a616 + 0523ec8 commit 95aa2a7

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)