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

public Class GF2nPolynomialField

extends GF2nField
Class Inheritance
Imports
java.security.SecureRandom, java.util.Vector

This class implements the abstract class GF2nField for polynomial representation. It computes the field polynomial and the squaring matrix. GF2nField is used by GF2nPolynomialElement which implements the elements of this field.
See Also
GF2nField, GF2nPolynomialElement

Field Summary

Modifier and TypeField and Description
private boolean
private boolean
private int[]
pack-priv GF2Polynomial[]
squaringMatrix

Matrix used for fast squaring

private int
Inherited from org.bouncycastle.pqc.legacy.math.linearalgebra.GF2nField:
fieldPolynomialfieldsmatricesmDegreerandom

Constructor Summary

AccessConstructor and Description
public
GF2nPolynomialField(int
the extention degree of this field
deg
,
SecureRandom
source of randomness for generating new polynomials.
random
)

constructs an instance of the finite field with 2deg elements and characteristic 2.

public
GF2nPolynomialField(int
the degree of this field
deg
,
SecureRandom
source of randomness for generating new polynomials.
random
,
boolean
true if you want to read the field polynomial from the file false if you want to use a random fielpolynomial (this can take very long for huge degrees)
file
)

constructs an instance of the finite field with 2deg elements and characteristic 2.

public
GF2nPolynomialField(int
degree of the GF2nField
deg
,
SecureRandom
source of randomness for generating new polynomials.
random
,
GF2Polynomial
the field polynomial to use
polynomial
)

Creates a new GF2nField of degree i and uses the given polynomial as field polynomial.

Method Summary

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

Implements abstract org.bouncycastle.pqc.legacy.math.linearalgebra.GF2nField.computeCOBMatrix.

Computes the change-of-basis matrix for basis conversion according to 1363.
protected void
protected void
computeFieldPolynomial2()

Computes the field polynomial.

private void
computeSquaringMatrix()

Computes a new squaring matrix used for fast squaring.

public int[]

Returns:

the middle coefficients of the used field pentanomial
getPc
()

Returns the degree of the middle coefficients of the used field pentanomial (x^n + x^(getPc()[2]) + x^(getPc()[1]) + x^(getPc()[0]) + 1).

protected GF2nElement

Returns:

a random root of polynomial
getRandomRoot
(GF2Polynomial
the polynomial
polynomial
)

Implements abstract org.bouncycastle.pqc.legacy.math.linearalgebra.GF2nField.getRandomRoot.

Compute a random root of the given GF2Polynomial.
public GF2Polynomial

Returns:

a copy of squaringMatrix[i]
getSquaringVector
(int
the index of the row vector to return
i
)

Return row vector i of the squaring matrix.

public int

Returns:

the middle coefficient of the used field trinomial
getTc
()

Returns the degree of the middle coefficient of the used field trinomial (x^n + x^(getTc()) + 1).

public boolean

Returns:

true if the field polynomial is a pentanomial
isPentanomial
()

Returns true if the field polynomial is a pentanomial.

public boolean

Returns:

true if the field polynomial is a trinomial
isTrinomial
()

Returns true if the field polynomial is a trinomial.

private boolean

Returns:

true if an irreducible pentanomial is found
testPentanomials
()

Tests all pentanomials of degree (n+1) until a irreducible is found and stores the result in field polynomial.

private boolean

Returns:

true
testRandom
()

Tests random polynomials of degree (n+1) until an irreducible is found and stores the result in field polynomial.

private boolean

Returns:

true if an irreducible trinomial is found
testTrinomials
()

Tests all trinomials of degree (n+1) until a irreducible is found and stores the result in field polynomial.

Inherited from org.bouncycastle.pqc.legacy.math.linearalgebra.GF2nField:
convertequalsgetDegreegetFieldPolynomialhashCodeinvertMatrix

Field Detail

isPentanomialback to summary
private boolean isPentanomial
isTrinomialback to summary
private boolean isTrinomial
pcback to summary
private int[] pc
squaringMatrixback to summary
pack-priv GF2Polynomial[] squaringMatrix

Matrix used for fast squaring

tcback to summary
private int tc

Constructor Detail

GF2nPolynomialFieldback to summary
public GF2nPolynomialField(int deg, SecureRandom random)

constructs an instance of the finite field with 2deg elements and characteristic 2.

Parameters
deg:int

the extention degree of this field

random:SecureRandom

source of randomness for generating new polynomials.

GF2nPolynomialFieldback to summary
public GF2nPolynomialField(int deg, SecureRandom random, boolean file)

constructs an instance of the finite field with 2deg elements and characteristic 2.

Parameters
deg:int

the degree of this field

random:SecureRandom

source of randomness for generating new polynomials.

file:boolean

true if you want to read the field polynomial from the file false if you want to use a random fielpolynomial (this can take very long for huge degrees)

GF2nPolynomialFieldback to summary
public GF2nPolynomialField(int deg, SecureRandom random, GF2Polynomial polynomial) throws RuntimeException

Creates a new GF2nField of degree i and uses the given polynomial as field polynomial. The polynomial is checked whether it is irreducible. This can take some time if i is huge!

Parameters
deg:int

degree of the GF2nField

random:SecureRandom

source of randomness for generating new polynomials.

polynomial:GF2Polynomial

the field polynomial to use

Method Detail

computeCOBMatrixback to summary
protected void computeCOBMatrix(GF2nField B1)

Implements abstract org.bouncycastle.pqc.legacy.math.linearalgebra.GF2nField.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:GF2nField

the GF2nField to convert to

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

Implements abstract org.bouncycastle.pqc.legacy.math.linearalgebra.GF2nField.computeFieldPolynomial.

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

computeFieldPolynomial2back to summary
protected void computeFieldPolynomial2()

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

computeSquaringMatrixback to summary
private void computeSquaringMatrix()

Computes a new squaring matrix used for fast squaring.

See Also
GF2nPolynomialElement#square
getPcback to summary
public int[] getPc() throws RuntimeException

Returns the degree of the middle coefficients of the used field pentanomial (x^n + x^(getPc()[2]) + x^(getPc()[1]) + x^(getPc()[0]) + 1).

Returns:int[]

the middle coefficients of the used field pentanomial

getRandomRootback to summary
protected GF2nElement getRandomRoot(GF2Polynomial polynomial)

Implements abstract org.bouncycastle.pqc.legacy.math.linearalgebra.GF2nField.getRandomRoot.

Compute a random root of the given GF2Polynomial.

Parameters
polynomial:GF2Polynomial

the polynomial

Returns:GF2nElement

a random root of polynomial

getSquaringVectorback to summary
public GF2Polynomial getSquaringVector(int i)

Return row vector i of the squaring matrix.

Parameters
i:int

the index of the row vector to return

Returns:GF2Polynomial

a copy of squaringMatrix[i]

See Also
GF2nPolynomialElement#squareMatrix
getTcback to summary
public int getTc() throws RuntimeException

Returns the degree of the middle coefficient of the used field trinomial (x^n + x^(getTc()) + 1).

Returns:int

the middle coefficient of the used field trinomial

isPentanomialback to summary
public boolean isPentanomial()

Returns true if the field polynomial is a pentanomial. The coefficients can be retrieved using getPc().

Returns:boolean

true if the field polynomial is a pentanomial

isTrinomialback to summary
public boolean isTrinomial()

Returns true if the field polynomial is a trinomial. The coefficient can be retrieved using getTc().

Returns:boolean

true if the field polynomial is a trinomial

testPentanomialsback to summary
private boolean testPentanomials()

Tests all pentanomials of degree (n+1) until a irreducible is found and stores the result in field polynomial. Returns false if no irreducible pentanomial exists in GF(2^n). This can take very long for huge degrees.

Returns:boolean

true if an irreducible pentanomial is found

testRandomback to summary
private boolean testRandom()

Tests random polynomials of degree (n+1) until an irreducible is found and stores the result in field polynomial. This can take very long for huge degrees.

Returns:boolean

true

testTrinomialsback to summary
private boolean testTrinomials()

Tests all trinomials of degree (n+1) until a irreducible is found and stores the result in field polynomial. Returns false if no irreducible trinomial exists in GF(2^n). This can take very long for huge degrees.

Returns:boolean

true if an irreducible trinomial is found