Class 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
    • 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​(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)
      • 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);
      • 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
      • 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.