GF2nPolynomialField (Bouncy Castle Library 1.52 API Specification)

org.bouncycastle.pqc.math.linearalgebra

## Class GF2nPolynomialField

- java.lang.Object
- - org.bouncycastle.pqc.math.linearalgebra.GF2nField
  - - org.bouncycastle.pqc.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:
    `GF2nField`, `GF2nPolynomialElement`

- - ### Field Summary

    - ### Fields inherited from class org.bouncycastle.pqc.math.linearalgebra.GF2nField

      `fieldPolynomial, fields, matrices, mDegree`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `GF2nPolynomialField(int deg)` constructs an instance of the finite field with 2deg elements and characteristic 2.
    `GF2nPolynomialField(int deg, boolean file)` constructs an instance of the finite field with 2deg elements and characteristic 2.
    `GF2nPolynomialField(int deg, GF2Polynomial polynomial)` Creates a new GF2nField of degree i and uses the given polynomial as field polynomial.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `computeCOBMatrix(GF2nField B1)` Computes the change-of-basis matrix for basis conversion according to 1363.
    `protected void` | `computeFieldPolynomial()` Computes the field polynomial.
    `protected void` | `computeFieldPolynomial2()` Computes the field polynomial.
    `int[]` | `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` | `getRandomRoot(GF2Polynomial polynomial)` Compute a random root of the given GF2Polynomial.
    `GF2Polynomial` | `getSquaringVector(int i)` Return row vector i of the squaring matrix.
    `int` | `getTc()` Returns the degree of the middle coefficient of the used field trinomial (x^n + x^(getTc()) + 1).
    `boolean` | `isPentanomial()` Returns true if the field polynomial is a pentanomial.
    `boolean` | `isTrinomial()` Returns true if the field polynomial is a trinomial.

    - ### Methods inherited from class org.bouncycastle.pqc.math.linearalgebra.GF2nField

      `convert, equals, getDegree, getFieldPolynomial, hashCode, invertMatrix`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### GF2nPolynomialField

          public GF2nPolynomialField(int deg)

      constructs an instance of the finite field with 2deg elements and characteristic 2.
      Parameters:
        `deg` - the extention degree of this field

    - #### GF2nPolynomialField

          public GF2nPolynomialField(int deg,
                             boolean file)

      constructs an instance of the finite field with 2deg elements and characteristic 2.
      Parameters:
        `deg` - the degree of this field
        `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,
                             GF2Polynomial polynomial)
                              throws java.lang.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
        `polynomial` - the field polynomial to use
      Throws:
        `PolynomialIsNotIrreducibleException` - if the given polynomial is not irreducible in GF(2^i)
        `java.lang.RuntimeException`

  - ### Method Detail

    - #### 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 java.lang.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:
        `GFException` - if the field polynomial is not a trinomial
        `java.lang.RuntimeException`

    - #### getPc

          public int[] getPc()
                      throws java.lang.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:
        `GFException` - if the field polynomial is not a pentanomial
        `java.lang.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:
        `GF2nPolynomialElement.squareMatrix()`

    - #### 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.