Skip to content

Commit eb0437e

Browse files
committed
add comment for Fp::checked_neg
1 parent 7ddc97f commit eb0437e

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

soroban-sdk/src/crypto/bls12_381.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,11 @@ impl Fp {
168168
self.0.env()
169169
}
170170

171+
// `Fp` represents an element in the base field of the BLS12-381 elliptic curve.
172+
// For an element a ∈ Fp, its negation `-a` is defined as:
173+
// a + (-a) = 0 (mod p)
174+
// where `p` is the field modulus, and to make a valid point coordinate on the
175+
// curve, `a` also must be within the field range (i.e., 0 ≤ a < p).
171176
fn checked_neg(&self) -> Option<Fp> {
172177
let fp_bigint: BigInt<6> = (&self.0).into();
173178
if fp_bigint.is_zero() {

0 commit comments

Comments
 (0)