Class GF2nField
java.lang.Object
org.bouncycastle.pqc.legacy.math.linearalgebra.GF2nField
- Direct Known Subclasses:
GF2nONBField,GF2nPolynomialField
This abstract class defines the finite field GF(2n). It
holds the extension degree n, the characteristic, the irreducible
fieldpolynomial and conversion matrices. GF2nField is implemented by the
classes GF2nPolynomialField and GF2nONBField.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected GF2Polynomialthe irreducible fieldPolynomial stored in normal order (also for ONB)protected Vectorholds a list of GF2nFields to which elements have been converted and thus a COB-Matrix existsprotected Vectorthe COB matricesprotected intthe degree of this fieldprotected final SecureRandom -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidComputes the change-of-basis matrix for basis conversion according to 1363.protected abstract voidComputes the fieldpolynomial.final GF2nElementconvert(GF2nElement elem, GF2nField basis) Converts the given element in representation according to this field to a new element in representation according to B1 using the change-of-basis matrix calculated by computeCOBMatrix.final booleanDecides whether the given object other is the same as this field.final intReturns the degree n of this field.final GF2PolynomialReturns the fieldpolynomial as a new Bitstring.protected abstract GF2nElementgetRandomRoot(GF2Polynomial B0FieldPolynomial) Computes a random root from the given irreducible fieldpolynomial according to IEEE 1363 algorithm A.5.6.inthashCode()protected final GF2Polynomial[]invertMatrix(GF2Polynomial[] matrix) Inverts the given matrix represented as bitstrings.
-
Field Details
-
random
-
mDegree
protected int mDegreethe degree of this field -
fieldPolynomial
the irreducible fieldPolynomial stored in normal order (also for ONB) -
fields
holds a list of GF2nFields to which elements have been converted and thus a COB-Matrix exists -
matrices
the COB matrices
-
-
Constructor Details
-
GF2nField
-
-
Method Details
-
getDegree
public final int getDegree()Returns the degree n of this field.- Returns:
- the degree n of this field
-
getFieldPolynomial
Returns the fieldpolynomial as a new Bitstring.- Returns:
- a copy of the fieldpolynomial as a new Bitstring
-
equals
Decides whether the given object other is the same as this field. -
hashCode
public int hashCode() -
getRandomRoot
Computes a random root from the given irreducible fieldpolynomial according to IEEE 1363 algorithm A.5.6. This cal take very long for big degrees.- Parameters:
B0FieldPolynomial- the fieldpolynomial if the other basis as a Bitstring- Returns:
- a random root of BOFieldPolynomial in representation according to this field
- See Also:
-
computeCOBMatrix
Computes the change-of-basis matrix for basis conversion according to 1363. The result is stored in the lists fields and matrices.- Parameters:
B1- the GF2nField to convert to- See Also:
-
computeFieldPolynomial
protected abstract void computeFieldPolynomial()Computes the fieldpolynomial. This can take a long time for big degrees. -
invertMatrix
Inverts the given matrix represented as bitstrings.- Parameters:
matrix- the matrix to invert as a Bitstring[]- Returns:
- matrix^(-1)
-
convert
Converts the given element in representation according to this field to a new element in representation according to B1 using the change-of-basis matrix calculated by computeCOBMatrix.- Parameters:
elem- the GF2nElement to convertbasis- the basis to convert elem to- Returns:
- elem converted to a new element representation according to basis
- Throws:
RuntimeException- See Also:
-