PolynomialGF2mSmallM (Bouncy Castle Library 1.54 API Specification)
Date: 2015-12-29

org.bouncycastle.pqc.math.linearalgebra

## Class PolynomialGF2mSmallM

- java.lang.Object
- - org.bouncycastle.pqc.math.linearalgebra.PolynomialGF2mSmallM

-     public class PolynomialGF2mSmallM
      extends java.lang.Object

  This class describes operations with polynomials from the ring R = GF(2^m)[X], where 2 <= m <=31.
  See Also:
    `GF2mField`, `PolynomialRingGF2m`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static char` | `RANDOM_IRREDUCIBLE_POLYNOMIAL` Constant used for polynomial construction (see constructor `PolynomialGF2mSmallM(GF2mField, int, char, SecureRandom)`).

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PolynomialGF2mSmallM(GF2mField field)` Construct the zero polynomial over the finite field GF(2^m).
    `PolynomialGF2mSmallM(GF2mField field, byte[] enc)` Create a polynomial over the finite field GF(2^m).
    `PolynomialGF2mSmallM(GF2mField field, int degree)` Construct a monomial of the given degree over the finite field GF(2^m).
    `PolynomialGF2mSmallM(GF2mField field, int[] coeffs)` Construct the polynomial over the given finite field GF(2^m) from the given coefficient vector.
    `PolynomialGF2mSmallM(GF2mField field, int deg, char typeOfPolynomial, java.security.SecureRandom sr)` Construct a polynomial over the finite field GF(2^m).
    `PolynomialGF2mSmallM(GF2mVector vect)` Create a polynomial over the finite field GF(2^m) out of the given coefficient vector.
    `PolynomialGF2mSmallM(PolynomialGF2mSmallM other)` Copy constructor.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `PolynomialGF2mSmallM` | `add(PolynomialGF2mSmallM addend)` Compute the sum of this polynomial and the given polynomial.
    `PolynomialGF2mSmallM` | `addMonomial(int degree)` Compute the sum of this polynomial and the monomial of the given degree.
    `void` | `addToThis(PolynomialGF2mSmallM addend)` Add the given polynomial to this polynomial (overwrite this).
    `PolynomialGF2mSmallM[]` | `div(PolynomialGF2mSmallM f)` Divide this polynomial by the given polynomial.
    `boolean` | `equals(java.lang.Object other)` checks if given object is equal to this polynomial.
    `int` | `evaluateAt(int e)` Evaluate this polynomial `p` at a value `e` (in `GF(2^m)`) with the Horner scheme.
    `PolynomialGF2mSmallM` | `gcd(PolynomialGF2mSmallM f)` Return the greatest common divisor of this and a polynomial f
    `int` | `getCoefficient(int index)` Return the coefficient with the given index.
    `int` | `getDegree()` Return the degree of this polynomial
    `byte[]` | `getEncoded()` Returns encoded polynomial, i.e., this polynomial in byte array form
    `int` | `getHeadCoefficient()`
    `int` | `hashCode()`
    `PolynomialGF2mSmallM` | `mod(PolynomialGF2mSmallM f)` Reduce this polynomial modulo another polynomial.
    `PolynomialGF2mSmallM` | `modDiv(PolynomialGF2mSmallM divisor, PolynomialGF2mSmallM modulus)` Compute the result of the division of this polynomial by another polynomial modulo a third polynomial.
    `PolynomialGF2mSmallM` | `modInverse(PolynomialGF2mSmallM a)` Compute the inverse of this polynomial modulo the given polynomial.
    `PolynomialGF2mSmallM` | `modMultiply(PolynomialGF2mSmallM a, PolynomialGF2mSmallM b)` Compute the product of this polynomial and another polynomial modulo a third polynomial.
    `PolynomialGF2mSmallM[]` | `modPolynomialToFracton(PolynomialGF2mSmallM g)` Compute a polynomial pair (a,b) from this polynomial and the given polynomial g with the property b*this = a mod g and deg(a)<=deg(g)/2.
    `PolynomialGF2mSmallM` | `modSquareMatrix(PolynomialGF2mSmallM[] matrix)` Square this polynomial using a squaring matrix.
    `PolynomialGF2mSmallM` | `modSquareRoot(PolynomialGF2mSmallM a)` Compute the square root of this polynomial modulo the given polynomial.
    `PolynomialGF2mSmallM` | `modSquareRootMatrix(PolynomialGF2mSmallM[] matrix)` Compute the square root of this polynomial using a square root matrix.
    `PolynomialGF2mSmallM` | `multiply(PolynomialGF2mSmallM factor)` Compute the product of this polynomial and the given factor using a Karatzuba like scheme.
    `void` | `multThisWithElement(int element)` Multiply this polynomial with an element from GF(2^m).
    `PolynomialGF2mSmallM` | `multWithElement(int element)` Compute the product of this polynomial with an element from GF(2^m).
    `PolynomialGF2mSmallM` | `multWithMonomial(int k)` Compute the product of this polynomial with a monomial X^k.
    `java.lang.String` | `toString()` Returns a human readable form of the polynomial.

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

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

- - ### Field Detail

    - #### RANDOM_IRREDUCIBLE_POLYNOMIAL

          public static final char RANDOM_IRREDUCIBLE_POLYNOMIAL

      Constant used for polynomial construction (see constructor `PolynomialGF2mSmallM(GF2mField, int, char, SecureRandom)`).
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### PolynomialGF2mSmallM

          public PolynomialGF2mSmallM(GF2mField field)

      Construct the zero polynomial over the finite field GF(2^m).
      Parameters:
        `field` - the finite field GF(2^m)

    - #### PolynomialGF2mSmallM

          public PolynomialGF2mSmallM(GF2mField field,
                              int deg,
                              char typeOfPolynomial,
                              java.security.SecureRandom sr)

      Construct a polynomial over the finite field GF(2^m).
      Parameters:
        `field` - the finite field GF(2^m)
        `deg` - degree of polynomial
        `typeOfPolynomial` - type of polynomial
        `sr` - PRNG

    - #### PolynomialGF2mSmallM

          public PolynomialGF2mSmallM(GF2mField field,
                              int degree)

      Construct a monomial of the given degree over the finite field GF(2^m).
      Parameters:
        `field` - the finite field GF(2^m)
        `degree` - the degree of the monomial

    - #### PolynomialGF2mSmallM

          public PolynomialGF2mSmallM(GF2mField field,
                              int[] coeffs)

      Construct the polynomial over the given finite field GF(2^m) from the given coefficient vector.
      Parameters:
        `field` - finite field GF2m
        `coeffs` - the coefficient vector

    - #### PolynomialGF2mSmallM

          public PolynomialGF2mSmallM(GF2mField field,
                              byte[] enc)

      Create a polynomial over the finite field GF(2^m).
      Parameters:
        `field` - the finite field GF(2^m)
        `enc` - byte[] polynomial in byte array form

    - #### PolynomialGF2mSmallM

          public PolynomialGF2mSmallM(PolynomialGF2mSmallM other)

      Copy constructor.
      Parameters:
        `other` - another `PolynomialGF2mSmallM`

    - #### PolynomialGF2mSmallM

          public PolynomialGF2mSmallM(GF2mVector vect)

      Create a polynomial over the finite field GF(2^m) out of the given coefficient vector. The finite field is also obtained from the `GF2mVector`.
      Parameters:
        `vect` - the coefficient vector

  - ### Method Detail

    - #### getDegree

          public int getDegree()

      Return the degree of this polynomial
      Returns:
        int degree of this polynomial if this is zero polynomial return -1

    - #### getHeadCoefficient

          public int getHeadCoefficient()

      Returns:
        the head coefficient of this polynomial

    - #### getCoefficient

          public int getCoefficient(int index)

      Return the coefficient with the given index.
      Parameters:
        `index` - the index
      Returns:
        the coefficient with the given index

    - #### getEncoded

          public byte[] getEncoded()

      Returns encoded polynomial, i.e., this polynomial in byte array form
      Returns:
        the encoded polynomial

    - #### evaluateAt

          public int evaluateAt(int e)

      Evaluate this polynomial `p` at a value `e` (in `GF(2^m)`) with the Horner scheme.
      Parameters:
        `e` - the element of the finite field GF(2^m)
      Returns:
        `this(e)`

    - #### add

          public PolynomialGF2mSmallM add(PolynomialGF2mSmallM addend)

      Compute the sum of this polynomial and the given polynomial.
      Parameters:
        `addend` - the addend
      Returns:
        `this + a` (newly created)

    - #### addToThis

          public void addToThis(PolynomialGF2mSmallM addend)

      Add the given polynomial to this polynomial (overwrite this).
      Parameters:
        `addend` - the addend

    - #### addMonomial

          public PolynomialGF2mSmallM addMonomial(int degree)

      Compute the sum of this polynomial and the monomial of the given degree.
      Parameters:
        `degree` - the degree of the monomial
      Returns:
        `this + X^k`

    - #### multWithElement

          public PolynomialGF2mSmallM multWithElement(int element)

      Compute the product of this polynomial with an element from GF(2^m).
      Parameters:
        `element` - an element of the finite field GF(2^m)
      Returns:
        `this * element` (newly created)
      Throws:
        `java.lang.ArithmeticException` - if `element` is not an element of the finite field this polynomial is defined over.

    - #### multThisWithElement

          public void multThisWithElement(int element)

      Multiply this polynomial with an element from GF(2^m).
      Parameters:
        `element` - an element of the finite field GF(2^m)
      Throws:
        `java.lang.ArithmeticException` - if `element` is not an element of the finite field this polynomial is defined over.

    - #### multWithMonomial

          public PolynomialGF2mSmallM multWithMonomial(int k)

      Compute the product of this polynomial with a monomial X^k.
      Parameters:
        `k` - the degree of the monomial
      Returns:
        `this * X^k`

    - #### div

          public PolynomialGF2mSmallM[] div(PolynomialGF2mSmallM f)

      Divide this polynomial by the given polynomial.
      Parameters:
        `f` - a polynomial
      Returns:
        polynomial pair = {q,r} where this = q*f+r and deg(r) < deg(f);

    - #### gcd

          public PolynomialGF2mSmallM gcd(PolynomialGF2mSmallM f)

      Return the greatest common divisor of this and a polynomial f
      Parameters:
        `f` - polynomial
      Returns:
        GCD(this, f)

    - #### multiply

          public PolynomialGF2mSmallM multiply(PolynomialGF2mSmallM factor)

      Compute the product of this polynomial and the given factor using a Karatzuba like scheme.
      Parameters:
        `factor` - the polynomial
      Returns:
        `this * factor`

    - #### mod

          public PolynomialGF2mSmallM mod(PolynomialGF2mSmallM f)

      Reduce this polynomial modulo another polynomial.
      Parameters:
        `f` - the reduction polynomial
      Returns:
        `this mod f`

    - #### modMultiply

          public PolynomialGF2mSmallM modMultiply(PolynomialGF2mSmallM a,
                                         PolynomialGF2mSmallM b)

      Compute the product of this polynomial and another polynomial modulo a third polynomial.
      Parameters:
        `a` - another polynomial
        `b` - the reduction polynomial
      Returns:
        `this * a mod b`

    - #### modSquareMatrix

          public PolynomialGF2mSmallM modSquareMatrix(PolynomialGF2mSmallM[] matrix)

      Square this polynomial using a squaring matrix.
      Parameters:
        `matrix` - the squaring matrix
      Returns:
        `this^2` modulo the reduction polynomial implicitly given via the squaring matrix

    - #### modSquareRoot

          public PolynomialGF2mSmallM modSquareRoot(PolynomialGF2mSmallM a)

      Compute the square root of this polynomial modulo the given polynomial.
      Parameters:
        `a` - the reduction polynomial
      Returns:
        `this^(1/2) mod a`

    - #### modSquareRootMatrix

          public PolynomialGF2mSmallM modSquareRootMatrix(PolynomialGF2mSmallM[] matrix)

      Compute the square root of this polynomial using a square root matrix.
      Parameters:
        `matrix` - the matrix for computing square roots in `(GF(2^m))^t` the polynomial ring defining the square root matrix
      Returns:
        `this^(1/2)` modulo the reduction polynomial implicitly given via the square root matrix

    - #### modDiv

          public PolynomialGF2mSmallM modDiv(PolynomialGF2mSmallM divisor,
                                    PolynomialGF2mSmallM modulus)

      Compute the result of the division of this polynomial by another polynomial modulo a third polynomial.
      Parameters:
        `divisor` - the divisor
        `modulus` - the reduction polynomial
      Returns:
        `this * divisor^(-1) mod modulus`

    - #### modInverse

          public PolynomialGF2mSmallM modInverse(PolynomialGF2mSmallM a)

      Compute the inverse of this polynomial modulo the given polynomial.
      Parameters:
        `a` - the reduction polynomial
      Returns:
        `this^(-1) mod a`

    - #### modPolynomialToFracton

          public PolynomialGF2mSmallM[] modPolynomialToFracton(PolynomialGF2mSmallM g)

      Compute a polynomial pair (a,b) from this polynomial and the given polynomial g with the property b*this = a mod g and deg(a)<=deg(g)/2.
      Parameters:
        `g` - the reduction polynomial
      Returns:
        PolynomialGF2mSmallM[] {a,b} with b*this = a mod g and deg(a)<= deg(g)/2

    - #### equals

          public boolean equals(java.lang.Object other)

      checks if given object is equal to this polynomial.

      The method returns false whenever the given object is not polynomial over GF(2^m).

      Overrides:
        `equals` in class `java.lang.Object`
      Parameters:
        `other` - object
      Returns:
        true or false

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `java.lang.Object`
      Returns:
        the hash code of this polynomial

    - #### toString

          public java.lang.String toString()

      Returns a human readable form of the polynomial.
      Overrides:
        `toString` in class `java.lang.Object`
      Returns:
        a human readable form of the polynomial.