org.bouncycastle.pqc.math.ntru

## Class Polynomial

- java.lang.Object
- - org.bouncycastle.pqc.math.ntru.Polynomial

- Direct Known Subclasses:
    HPSPolynomial, HRSSPolynomial

      public abstract class Polynomial
      extends java.lang.Object

  Polynomial for `org.bouncycastle.pqc.crypto.ntru`.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `short[]` | `coeffs` An array of coefficients
    `protected NTRUParameterSet` | `params`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Polynomial(NTRUParameterSet params)`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract void` | `lift(Polynomial a)`
    `void` | `mod3PhiN()`
    `void` | `modQPhiN()`
    `void` | `r2Inv(Polynomial a)`
    `void` | `rqInv(Polynomial a)`
    `void` | `rqMul(Polynomial a, Polynomial b)`
    `void` | `rqSumZeroFromBytes(byte[] a)` Unpack a Rq0 polynomial
    `byte[]` | `rqSumZeroToBytes(int len)` Pack a Rq0 polynomial as a byte array
    `void` | `rqToS3(Polynomial a)`
    `void` | `s3FromBytes(byte[] msg)` Unpack a S3 polynomial
    `void` | `s3Inv(Polynomial a)`
    `void` | `s3Mul(Polynomial a, Polynomial b)`
    `void` | `s3ToBytes(byte[] msg, int msgOff)`
    `byte[]` | `s3ToBytes(int messageSize)` Pack an S3 polynomial as a byte array
    `abstract void` | `sqFromBytes(byte[] a)` Unpack a Sq polynomial
    `void` | `sqMul(Polynomial a, Polynomial b)`
    `abstract byte[]` | `sqToBytes(int len)` Pack Sq polynomial as a byte array
    `void` | `trinaryZqToZ3()`
    `void` | `z3ToZq()`

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

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

- - ### Field Detail

    - #### coeffs

          public short[] coeffs

      An array of coefficients

    - #### params

          protected NTRUParameterSet params

  - ### Constructor Detail

    - #### Polynomial

          public Polynomial(NTRUParameterSet params)

  - ### Method Detail

    - #### mod3PhiN

          public void mod3PhiN()

    - #### modQPhiN

          public void modQPhiN()

    - #### sqToBytes

          public abstract byte[] sqToBytes(int len)

      Pack Sq polynomial as a byte array
      Parameters:
        `len` - array length of packed polynomial
      Returns:
      See Also:
        NTRU specification section 1.8.5

    - #### sqFromBytes

          public abstract void sqFromBytes(byte[] a)

      Unpack a Sq polynomial
      Parameters:
        `a` - byte array of packed polynomial
      See Also:
        NTRU specification section 1.8.6

    - #### rqSumZeroToBytes

          public byte[] rqSumZeroToBytes(int len)

      Pack a Rq0 polynomial as a byte array
      Parameters:
        `len` - array length of packed polynomial
      Returns:
      See Also:
        NTRU specification section 1.8.3

    - #### rqSumZeroFromBytes

          public void rqSumZeroFromBytes(byte[] a)

      Unpack a Rq0 polynomial
      Parameters:
        `a` - byte array of packed polynomial
      See Also:
        NTRU specification section 1.8.4

    - #### s3ToBytes

          public byte[] s3ToBytes(int messageSize)

      Pack an S3 polynomial as a byte array
      Parameters:
        `messageSize` - array length of packed polynomial
      Returns:
      See Also:
        NTRU specification section 1.8.7

    - #### s3ToBytes

          public void s3ToBytes(byte[] msg,
                                int msgOff)

    - #### s3FromBytes

          public void s3FromBytes(byte[] msg)

      Unpack a S3 polynomial
      Parameters:
        `msg` - byte array of packed polynomial
      See Also:
        NTRU specification section 1.8.8

    - #### sqMul

          public void sqMul(Polynomial a,
                            Polynomial b)

    - #### rqMul

          public void rqMul(Polynomial a,
                            Polynomial b)

    - #### s3Mul

          public void s3Mul(Polynomial a,
                            Polynomial b)

    - #### lift

          public abstract void lift(Polynomial a)

      Parameters:
        `a` -
      See Also:
        NTRU specification section 1.9.3

    - #### rqToS3

          public void rqToS3(Polynomial a)

    - #### r2Inv

          public void r2Inv(Polynomial a)

    - #### rqInv

          public void rqInv(Polynomial a)

    - #### s3Inv

          public void s3Inv(Polynomial a)

    - #### z3ToZq

          public void z3ToZq()

    - #### trinaryZqToZ3

          public void trinaryZqToZ3()