Skip to content

Commit cfe74d4

Browse files
committed
panic on neg input Fp larger than field modulus
1 parent 311e115 commit cfe74d4

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

soroban-sdk/src/crypto/bls12_381.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,10 @@ impl Neg for Fp {
203203
1873798617647539866,
204204
]);
205205
// Compute modulus - value
206-
res.sub_with_borrow(&fp_bigint);
206+
let borrow = res.sub_with_borrow(&fp_bigint);
207+
if borrow {
208+
sdk_panic!("invalid input - Fp is larger than the field modulus")
209+
}
207210
let mut bytes = [0u8; 48];
208211
res.copy_into_array(&mut bytes);
209212
Fp::from_array(&self.env(), &bytes)

0 commit comments

Comments
 (0)