DenseTernaryPolynomial (Bouncy Castle Library 1.52 API Specification)

org.bouncycastle.pqc.math.ntru.polynomial

## Class DenseTernaryPolynomial

- java.lang.Object
- - org.bouncycastle.pqc.math.ntru.polynomial.IntegerPolynomial
  - - org.bouncycastle.pqc.math.ntru.polynomial.DenseTernaryPolynomial

- All Implemented Interfaces:
    Polynomial, TernaryPolynomial

      public class DenseTernaryPolynomial
      extends IntegerPolynomial
      implements TernaryPolynomial

  A `TernaryPolynomial` with a "high" number of nonzero coefficients.

- - ### Field Summary

    - ### Fields inherited from class org.bouncycastle.pqc.math.ntru.polynomial.IntegerPolynomial

      `coeffs`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DenseTernaryPolynomial(int[] coeffs)` Constructs a new `DenseTernaryPolynomial` with a given set of coefficients.
    `DenseTernaryPolynomial(IntegerPolynomial intPoly)` Constructs a `DenseTernaryPolynomial` from a `IntegerPolynomial`.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static DenseTernaryPolynomial` | `generateRandom(int N, int numOnes, int numNegOnes, java.security.SecureRandom random)` Generates a random polynomial with `numOnes` coefficients equal to 1, `numNegOnes` coefficients equal to -1, and the rest equal to 0.
    `static DenseTernaryPolynomial` | `generateRandom(int N, java.security.SecureRandom random)` Generates a polynomial with coefficients randomly selected from `{-1, 0, 1}`.
    `int[]` | `getNegOnes()`
    `int[]` | `getOnes()`
    `IntegerPolynomial` | `mult(IntegerPolynomial poly2, int modulus)` Multiplies the polynomial with another, taking the values mod modulus and the indices mod N
    `int` | `size()` Returns the maximum number of coefficients the polynomial can have

    - ### Methods inherited from class org.bouncycastle.pqc.math.ntru.polynomial.IntegerPolynomial

      `add, add, center0, centeredNormSq, clear, clone, count, div, ensurePositive, equals, equalsOne, fromBinary, fromBinary, fromBinary3Sves, fromBinary3Tight, fromBinary3Tight, invertF3, invertFq, mod, mod3, modPositive, mult, mult, mult, mult3, resultant, resultant, resultantMultiThread, rotate1, sub, sub, sumCoeffs, toBinary, toBinary3Sves, toBinary3Tight, toIntegerPolynomial`

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

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

    - ### Methods inherited from interface org.bouncycastle.pqc.math.ntru.polynomial.TernaryPolynomial

      `clear, mult`

    - ### Methods inherited from interface org.bouncycastle.pqc.math.ntru.polynomial.Polynomial

      `mult, toIntegerPolynomial`

- - ### Constructor Detail

    - #### DenseTernaryPolynomial

          public DenseTernaryPolynomial(IntegerPolynomial intPoly)

      Constructs a `DenseTernaryPolynomial` from a `IntegerPolynomial`. The two polynomials are independent of each other.
      Parameters:
        `intPoly` - the original polynomial

    - #### DenseTernaryPolynomial

          public DenseTernaryPolynomial(int[] coeffs)

      Constructs a new `DenseTernaryPolynomial` with a given set of coefficients.
      Parameters:
        `coeffs` - the coefficients

  - ### Method Detail

    - #### generateRandom

          public static DenseTernaryPolynomial generateRandom(int N,
                                              int numOnes,
                                              int numNegOnes,
                                              java.security.SecureRandom random)

      Generates a random polynomial with `numOnes` coefficients equal to 1, `numNegOnes` coefficients equal to -1, and the rest equal to 0.
      Parameters:
        `N` - number of coefficients
        `numOnes` - number of 1's
        `numNegOnes` - number of -1's

    - #### generateRandom

          public static DenseTernaryPolynomial generateRandom(int N,
                                              java.security.SecureRandom random)

      Generates a polynomial with coefficients randomly selected from `{-1, 0, 1}`.
      Parameters:
        `N` - number of coefficients

    - #### mult

          public IntegerPolynomial mult(IntegerPolynomial poly2,
                               int modulus)

      Description copied from class: `IntegerPolynomial`
      Multiplies the polynomial with another, taking the values mod modulus and the indices mod N
      Specified by:
        `mult` in interface `Polynomial`
      Overrides:
        `mult` in class `IntegerPolynomial`
      Parameters:
        `poly2` - a polynomial
        `modulus` - a modulus to apply
      Returns:
        the product of the two polynomials

    - #### getOnes

          public int[] getOnes()

      Specified by:
        `getOnes` in interface `TernaryPolynomial`

    - #### getNegOnes

          public int[] getNegOnes()

      Specified by:
        `getNegOnes` in interface `TernaryPolynomial`

    - #### size

          public int size()

      Description copied from interface: `TernaryPolynomial`
      Returns the maximum number of coefficients the polynomial can have
      Specified by:
        `size` in interface `TernaryPolynomial`