Class Fp2Element
java.lang.Object
org.bouncycastle.crypto.bls.Fp2Element
Immutable element of
Fp^2 = Fp[I] / (I^2 + 1), used as the base
field of BLS12-381 G2.
All operations reduce modulo p eagerly. Internally the two Fp components
are stored as plain BigInteger values.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Fp2ElementThe Fp^2 one element (1 + 0*I).static final BigIntegerField characteristic, identical to the BLS12-381 base field p.static final Fp2ElementThe Fp^2 zero element. -
Method Summary
Modifier and TypeMethodDescriptionadd(Fp2Element other) c0()c1()booleanFrobenius: (c0 + c1*I)^p = c0 - c1*I when p ≡ 3 (mod 4), which holds for the BLS12-381 base field.static Fp2ElementfromFp(BigInteger c0) inthashCode()inverse()Modular inverse: (c0 + c1*I)^-1 = (c0 - c1*I) / (c0^2 + c1^2).booleanisSquare()booleanisZero()modPow(BigInteger exponent) Modular exponentiation in Fp^2 by a non-negative integer exponent.mul(Fp2Element other) (a + b*I)(c + d*I) = (ac - bd) + (ad + bc)*I.mulFp(BigInteger fp) Multiply by a Fp scalar.neg()static Fp2Elementof(long c0, long c1) static Fp2Elementof(BigInteger c0, BigInteger c1) intsgn0()RFC 9380 sec. 4.1 sgn0 for m = 2.Tries to compute a square root ofthisin Fp^2, using the Wahby-Boneh algorithm specialised to p ≡ 3 (mod 4) ("Fast and simple constant-time hashing to the BLS12-381 elliptic curve", Algorithm 1).square()(a + b*I)^2 = (a-b)(a+b) + 2ab*I.sub(Fp2Element other) toString()
-
Field Details
-
P
Field characteristic, identical to the BLS12-381 base field p. -
ZERO
The Fp^2 zero element. -
ONE
The Fp^2 one element (1 + 0*I).
-
-
Method Details
-
of
-
of
-
fromFp
-
c0
- Returns:
- real component (the c0 in c0 + c1*I).
-
c1
- Returns:
- imaginary component (the c1 in c0 + c1*I).
-
isZero
public boolean isZero() -
add
-
sub
-
neg
-
mul
(a + b*I)(c + d*I) = (ac - bd) + (ad + bc)*I. -
mulFp
Multiply by a Fp scalar. -
square
(a + b*I)^2 = (a-b)(a+b) + 2ab*I. -
frobenius
Frobenius: (c0 + c1*I)^p = c0 - c1*I when p ≡ 3 (mod 4), which holds for the BLS12-381 base field. -
inverse
Modular inverse: (c0 + c1*I)^-1 = (c0 - c1*I) / (c0^2 + c1^2). -
modPow
Modular exponentiation in Fp^2 by a non-negative integer exponent. -
sgn0
public int sgn0()RFC 9380 sec. 4.1 sgn0 for m = 2.sign_0 = c0 mod 2 zero_0 = (c0 == 0) sign_1 = c1 mod 2 return sign_0 OR (zero_0 AND sign_1)
-
sqrtOrNull
Tries to compute a square root ofthisin Fp^2, using the Wahby-Boneh algorithm specialised to p ≡ 3 (mod 4) ("Fast and simple constant-time hashing to the BLS12-381 elliptic curve", Algorithm 1).- Returns:
- a square root, or
nullifthisis not a square.
-
isSquare
public boolean isSquare() -
equals
-
hashCode
-
toString
-