Bouncy Castle Cryptography 1.48

org.bouncycastle.pqc.math.linearalgebra
Class GF2nField

java.lang.Object
  extended by org.bouncycastle.pqc.math.linearalgebra.GF2nField
Direct Known Subclasses:
GF2nONBField, GF2nPolynomialField

public abstract class GF2nField
extends java.lang.Object

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:
GF2nONBField, GF2nPolynomialField

Field Summary
protected  GF2Polynomial fieldPolynomial
          the irreducible fieldPolynomial stored in normal order (also for ONB)
protected  java.util.Vector fields
          holds a list of GF2nFields to which elements have been converted and thus a COB-Matrix exists
protected  java.util.Vector matrices
          the COB matrices
protected  int mDegree
          the degree of this field
 
Constructor Summary
GF2nField()
           
 
Method Summary
protected abstract  void computeCOBMatrix(GF2nField B1)
          Computes the change-of-basis matrix for basis conversion according to 1363.
protected abstract  void computeFieldPolynomial()
          Computes the fieldpolynomial.
 GF2nElement convert(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.
 boolean equals(java.lang.Object other)
          Decides whether the given object other is the same as this field.
 int getDegree()
          Returns the degree n of this field.
 GF2Polynomial getFieldPolynomial()
          Returns the fieldpolynomial as a new Bitstring.
protected abstract  GF2nElement getRandomRoot(GF2Polynomial B0FieldPolynomial)
          Computes a random root from the given irreducible fieldpolynomial according to IEEE 1363 algorithm A.5.6.
 int hashCode()
           
protected  GF2Polynomial[] invertMatrix(GF2Polynomial[] matrix)
          Inverts the given matrix represented as bitstrings.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mDegree

protected int mDegree
the degree of this field


fieldPolynomial

protected GF2Polynomial fieldPolynomial
the irreducible fieldPolynomial stored in normal order (also for ONB)


fields

protected java.util.Vector fields
holds a list of GF2nFields to which elements have been converted and thus a COB-Matrix exists


matrices

protected java.util.Vector matrices
the COB matrices

Constructor Detail

GF2nField

public GF2nField()
Method Detail

getDegree

public final int getDegree()
Returns the degree n of this field.

Returns:
the degree n of this field

getFieldPolynomial

public final GF2Polynomial getFieldPolynomial()
Returns the fieldpolynomial as a new Bitstring.

Returns:
a copy of the fieldpolynomial as a new Bitstring

equals

public final boolean equals(java.lang.Object other)
Decides whether the given object other is the same as this field.

Overrides:
equals in class java.lang.Object
Parameters:
other - another object
Returns:
(this == other)

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object
Returns:
the hash code of this field

getRandomRoot

protected abstract GF2nElement getRandomRoot(GF2Polynomial B0FieldPolynomial)
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:
"P1363 A.5.6, p103f"

computeCOBMatrix

protected abstract void computeCOBMatrix(GF2nField B1)
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:
"P1363 A.7.3, p111ff"

computeFieldPolynomial

protected abstract void computeFieldPolynomial()
Computes the fieldpolynomial. This can take a long time for big degrees.


invertMatrix

protected final GF2Polynomial[] invertMatrix(GF2Polynomial[] matrix)
Inverts the given matrix represented as bitstrings.

Parameters:
matrix - the matrix to invert as a Bitstring[]
Returns:
matrix^(-1)

convert

public final GF2nElement convert(GF2nElement elem,
                                 GF2nField basis)
                          throws java.lang.RuntimeException
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 convert
basis - the basis to convert elem to
Returns:
elem converted to a new element representation according to basis
Throws:
DifferentFieldsException - if elem cannot be converted according to basis.
java.lang.RuntimeException
See Also:
computeCOBMatrix(org.bouncycastle.pqc.math.linearalgebra.GF2nField), getRandomRoot(org.bouncycastle.pqc.math.linearalgebra.GF2Polynomial), GF2nPolynomial, "P1363 A.7 p109ff"

Bouncy Castle Cryptography 1.48