Top Description Fields Constructors Methods
org.bouncycastle.pqc.legacy.math.linearalgebra

public abstract Class GF2nField

extends Object
Class Inheritance
Known Direct Subclasses
org.bouncycastle.pqc.legacy.math.linearalgebra.GF2nONBField, org.bouncycastle.pqc.legacy.math.linearalgebra.GF2nPolynomialField
Imports
java.security.SecureRandom, java.util.Vector

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

Modifier and TypeField and Description
protected GF2Polynomial
fieldPolynomial

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

protected Vector<E>
fields

holds a list of GF2nFields to which elements have been converted and thus a COB-Matrix exists

protected Vector<E>
matrices

the COB matrices

protected int
mDegree

the degree of this field

protected final SecureRandom

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
protected abstract void
computeCOBMatrix(GF2nField
the GF2nField to convert to
B1
)

Computes the change-of-basis matrix for basis conversion according to 1363.

protected abstract void
computeFieldPolynomial()

Computes the fieldpolynomial.

public final GF2nElement

Returns:

elem converted to a new element representation according to basis
convert
(GF2nElement
the GF2nElement to convert
elem
,
GF2nField
the basis to convert elem to
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.

public final boolean

Returns:

(this = = other)
equals
(Object
another object
other
)

Overrides java.lang.Object.equals.

Decides whether the given object other is the same as this field.

public final int

Returns:

the degree n of this field
getDegree
()

Returns the degree n of this field.

public final GF2Polynomial

Returns:

a copy of the fieldpolynomial as a new Bitstring
getFieldPolynomial
()

Returns the fieldpolynomial as a new Bitstring.

protected abstract GF2nElement

Returns:

a random root of BOFieldPolynomial in representation according to this field
getRandomRoot
(GF2Polynomial
the fieldpolynomial if the other basis as a Bitstring
B0FieldPolynomial
)

Computes a random root from the given irreducible fieldpolynomial according to IEEE 1363 algorithm A.5.6.

public int

Returns:

the hash code of this field
hashCode
()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

protected final GF2Polynomial[]

Returns:

matrix^(-1)
invertMatrix
(GF2Polynomial[]
the matrix to invert as a Bitstring[]
matrix
)

Inverts the given matrix represented as bitstrings.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

fieldPolynomialback to summary
protected GF2Polynomial fieldPolynomial

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

fieldsback to summary
protected Vector<E> fields

holds a list of GF2nFields to which elements have been converted and thus a COB-Matrix exists

matricesback to summary
protected Vector<E> matrices

the COB matrices

mDegreeback to summary
protected int mDegree

the degree of this field

randomback to summary
protected final SecureRandom random

Constructor Detail

GF2nFieldback to summary
protected GF2nField(SecureRandom random)

Method Detail

computeCOBMatrixback to summary
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:GF2nField

the GF2nField to convert to

See Also
P1363 A.7.3, p111ff
computeFieldPolynomialback to summary
protected abstract void computeFieldPolynomial()

Computes the fieldpolynomial. This can take a long time for big degrees.

convertback to summary
public final GF2nElement convert(GF2nElement elem, GF2nField basis) throws 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:GF2nElement

the GF2nElement to convert

basis:GF2nField

the basis to convert elem to

Returns:GF2nElement

elem converted to a new element representation according to basis

See Also
GF2nField#computeCOBMatrix, GF2nField#getRandomRoot, GF2nPolynomial, P1363 A.7 p109ff
equalsback to summary
public final boolean equals(Object other)

Overrides java.lang.Object.equals.

Decides whether the given object other is the same as this field.

Parameters
other:Object

another object

Returns:boolean

(this = = other)

getDegreeback to summary
public final int getDegree()

Returns the degree n of this field.

Returns:int

the degree n of this field

getFieldPolynomialback to summary
public final GF2Polynomial getFieldPolynomial()

Returns the fieldpolynomial as a new Bitstring.

Returns:GF2Polynomial

a copy of the fieldpolynomial as a new Bitstring

getRandomRootback to summary
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:GF2Polynomial

the fieldpolynomial if the other basis as a Bitstring

Returns:GF2nElement

a random root of BOFieldPolynomial in representation according to this field

See Also
P1363 A.5.6, p103f
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

the hash code of this field

invertMatrixback to summary
protected final GF2Polynomial[] invertMatrix(GF2Polynomial[] matrix)

Inverts the given matrix represented as bitstrings.

Parameters
matrix:GF2Polynomial[]

the matrix to invert as a Bitstring[]

Returns:GF2Polynomial[]

matrix^(-1)