public final class Fp2Element
extends java.lang.Object
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.
| Modifier and Type | Field and Description |
|---|---|
static Fp2Element |
ONE
The Fp^2 one element (1 + 0*I).
|
static java.math.BigInteger |
P
Field characteristic, identical to the BLS12-381 base field p.
|
static Fp2Element |
ZERO
The Fp^2 zero element.
|
| Modifier and Type | Method and Description |
|---|---|
Fp2Element |
add(Fp2Element other) |
java.math.BigInteger |
c0() |
java.math.BigInteger |
c1() |
boolean |
equals(java.lang.Object other) |
Fp2Element |
frobenius()
Frobenius: (c0 + c1*I)^p = c0 - c1*I when p ≡ 3 (mod 4),
which holds for the BLS12-381 base field.
|
static Fp2Element |
fromFp(java.math.BigInteger c0) |
int |
hashCode() |
Fp2Element |
inverse()
Modular inverse: (c0 + c1*I)^-1 = (c0 - c1*I) / (c0^2 + c1^2).
|
boolean |
isSquare() |
boolean |
isZero() |
Fp2Element |
modPow(java.math.BigInteger exponent)
Modular exponentiation in Fp^2 by a non-negative integer exponent.
|
Fp2Element |
mul(Fp2Element other)
(a + b*I)(c + d*I) = (ac - bd) + (ad + bc)*I.
|
Fp2Element |
mulFp(java.math.BigInteger fp)
Multiply by a Fp scalar.
|
Fp2Element |
neg() |
static Fp2Element |
of(java.math.BigInteger c0,
java.math.BigInteger c1) |
static Fp2Element |
of(long c0,
long c1) |
int |
sgn0()
RFC 9380 sec. 4.1 sgn0 for m = 2.
|
Fp2Element |
sqrtOrNull()
Tries to compute a square root of
this in 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). |
Fp2Element |
square()
(a + b*I)^2 = (a-b)(a+b) + 2ab*I.
|
Fp2Element |
sub(Fp2Element other) |
java.lang.String |
toString() |
public static final java.math.BigInteger P
public static final Fp2Element ZERO
public static final Fp2Element ONE
public static Fp2Element of(java.math.BigInteger c0, java.math.BigInteger c1)
public static Fp2Element of(long c0, long c1)
public static Fp2Element fromFp(java.math.BigInteger c0)
public java.math.BigInteger c0()
public java.math.BigInteger c1()
public boolean isZero()
public Fp2Element add(Fp2Element other)
public Fp2Element sub(Fp2Element other)
public Fp2Element neg()
public Fp2Element mul(Fp2Element other)
public Fp2Element mulFp(java.math.BigInteger fp)
public Fp2Element square()
public Fp2Element frobenius()
public Fp2Element inverse()
public Fp2Element modPow(java.math.BigInteger exponent)
public int sgn0()
sign_0 = c0 mod 2 zero_0 = (c0 == 0) sign_1 = c1 mod 2 return sign_0 OR (zero_0 AND sign_1)
public Fp2Element sqrtOrNull()
this in 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).null if this is not a square.public boolean isSquare()
public boolean equals(java.lang.Object other)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Object