Class GF2nPolynomialField

java.lang.Object
org.bouncycastle.pqc.legacy.math.linearalgebra.GF2nField
org.bouncycastle.pqc.legacy.math.linearalgebra.GF2nPolynomialField

public class GF2nPolynomialField extends GF2nField
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:
  • Constructor Details

    • GF2nPolynomialField

      public GF2nPolynomialField(int deg, SecureRandom random)
      constructs an instance of the finite field with 2deg elements and characteristic 2.
      Parameters:
      deg - the extention degree of this field
      random - source of randomness for generating new polynomials.
    • GF2nPolynomialField

      public GF2nPolynomialField(int deg, SecureRandom random, boolean file)
      constructs an instance of the finite field with 2deg elements and characteristic 2.
      Parameters:
      deg - the degree of this field
      random - source of randomness for generating new polynomials.
      file - 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)
    • GF2nPolynomialField

      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 - degree of the GF2nField
      random - source of randomness for generating new polynomials.
      polynomial - the field polynomial to use
      Throws:
      RuntimeException
  • Method Details

    • isTrinomial

      public boolean isTrinomial()
      Returns true if the field polynomial is a trinomial. The coefficient can be retrieved using getTc().
      Returns:
      true if the field polynomial is a trinomial
    • isPentanomial

      public boolean isPentanomial()
      Returns true if the field polynomial is a pentanomial. The coefficients can be retrieved using getPc().
      Returns:
      true if the field polynomial is a pentanomial
    • getTc

      public int getTc() throws RuntimeException
      Returns the degree of the middle coefficient of the used field trinomial (x^n + x^(getTc()) + 1).
      Returns:
      the middle coefficient of the used field trinomial
      Throws:
      RuntimeException
    • getPc

      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:
      the middle coefficients of the used field pentanomial
      Throws:
      RuntimeException
    • getSquaringVector

      public GF2Polynomial getSquaringVector(int i)
      Return row vector i of the squaring matrix.
      Parameters:
      i - the index of the row vector to return
      Returns:
      a copy of squaringMatrix[i]
      See Also:
    • getRandomRoot

      protected GF2nElement getRandomRoot(GF2Polynomial polynomial)
      Compute a random root of the given GF2Polynomial.
      Specified by:
      getRandomRoot in class GF2nField
      Parameters:
      polynomial - the polynomial
      Returns:
      a random root of polynomial
      See Also:
      • "P1363 A.5.6, p103f"
    • computeCOBMatrix

      protected 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.
      Specified by:
      computeCOBMatrix in class GF2nField
      Parameters:
      B1 - the GF2nField to convert to
      See Also:
      • "P1363 A.7.3, p111ff"
    • computeFieldPolynomial

      protected void computeFieldPolynomial()
      Computes the field polynomial. This can take a long time for big degrees.
      Specified by:
      computeFieldPolynomial in class GF2nField
    • computeFieldPolynomial2

      protected void computeFieldPolynomial2()
      Computes the field polynomial. This can take a long time for big degrees.