Top Description Fields Constructors Methods
org.bouncycastle.pqc.legacy.math.ntru.polynomial

public Class DenseTernaryPolynomial

extends IntegerPolynomial
implements TernaryPolynomial
Class Inheritance
All Implemented Interfaces
org.bouncycastle.pqc.legacy.math.ntru.polynomial.TernaryPolynomial, org.bouncycastle.pqc.legacy.math.ntru.polynomial.Polynomial
Imports
java.security.SecureRandom, org.bouncycastle.pqc.legacy.math.ntru.util.Util, org.bouncycastle.util.Arrays

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

Field Summary

Inherited from org.bouncycastle.pqc.legacy.math.ntru.polynomial.IntegerPolynomial:
coeffs

Constructor Summary

AccessConstructor and Description
pack-priv
DenseTernaryPolynomial(int
the number of coefficients
N
)

Constructs a new DenseTernaryPolynomial with N coefficients.

public
DenseTernaryPolynomial(IntegerPolynomial
the original polynomial
intPoly
)

Constructs a DenseTernaryPolynomial from a IntegerPolynomial.

public
DenseTernaryPolynomial(int[]
the coefficients
coeffs
)

Constructs a new DenseTernaryPolynomial with a given set of coefficients.

Method Summary

Modifier and TypeMethod and Description
private void
public static DenseTernaryPolynomial
generateRandom(int
number of coefficients
N
,
int
number of 1's
numOnes
,
int
number of -1's
numNegOnes
,
SecureRandom random)

Generates a random polynomial with numOnes coefficients equal to 1, numNegOnes coefficients equal to -1, and the rest equal to 0.

public static DenseTernaryPolynomial
generateRandom(int
number of coefficients
N
,
SecureRandom random)

Generates a polynomial with coefficients randomly selected from {-1, 0, 1}.

public int[]
public int[]
public IntegerPolynomial
mult(IntegerPolynomial
a polynomial
poly2
,
int
a modulus to apply
modulus
)

Overrides org.bouncycastle.pqc.legacy.math.ntru.polynomial.IntegerPolynomial.mult.

Implements org.bouncycastle.pqc.legacy.math.ntru.polynomial.Polynomial.mult.

Multiplies the polynomial by an IntegerPolynomial, taking the coefficient values mod modulus and the indices mod N.

public int
size()

Implements org.bouncycastle.pqc.legacy.math.ntru.polynomial.TernaryPolynomial.size.

Returns the maximum number of coefficients the polynomial can have

Inherited from org.bouncycastle.pqc.legacy.math.ntru.polynomial.IntegerPolynomial:
addaddcenter0centeredNormSqclearclonecountdegreedivensurePositiveequalsequalsOnefromBinaryfromBinaryfromBinary3SvesfromBinary3TightfromBinary3TightinvertF3invertFqmodmod3modCentermodPositivemultmultmultmult3resultantresultantresultantMultiThreadrotate1shiftGapsubsubsubsumCoeffstoBinarytoBinary3SvestoBinary3TighttoIntegerPolynomial

Constructor Detail

DenseTernaryPolynomialback to summary
pack-priv DenseTernaryPolynomial(int N)

Constructs a new DenseTernaryPolynomial with N coefficients.

Parameters
N:int

the number of coefficients

DenseTernaryPolynomialback to summary
public DenseTernaryPolynomial(IntegerPolynomial intPoly)

Constructs a DenseTernaryPolynomial from a IntegerPolynomial. The two polynomials are independent of each other.

Parameters
intPoly:IntegerPolynomial

the original polynomial

DenseTernaryPolynomialback to summary
public DenseTernaryPolynomial(int[] coeffs)

Constructs a new DenseTernaryPolynomial with a given set of coefficients.

Parameters
coeffs:int[]

the coefficients

Method Detail

checkTernarityback to summary
private void checkTernarity()
generateRandomback to summary
public static DenseTernaryPolynomial generateRandom(int N, int numOnes, int numNegOnes, 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:int

number of coefficients

numOnes:int

number of 1's

numNegOnes:int

number of -1's

generateRandomback to summary
public static DenseTernaryPolynomial generateRandom(int N, SecureRandom random)

Generates a polynomial with coefficients randomly selected from {-1, 0, 1}.

Parameters
N:int

number of coefficients

getNegOnesback to summary
public int[] getNegOnes()

Implements org.bouncycastle.pqc.legacy.math.ntru.polynomial.TernaryPolynomial.getNegOnes.

getOnesback to summary
public int[] getOnes()

Implements org.bouncycastle.pqc.legacy.math.ntru.polynomial.TernaryPolynomial.getOnes.

multback to summary
public IntegerPolynomial mult(IntegerPolynomial poly2, int modulus)

Overrides org.bouncycastle.pqc.legacy.math.ntru.polynomial.IntegerPolynomial.mult.

Implements org.bouncycastle.pqc.legacy.math.ntru.polynomial.Polynomial.mult.

Doc from org.bouncycastle.pqc.legacy.math.ntru.polynomial.Polynomial.mult.

Multiplies the polynomial by an IntegerPolynomial, taking the coefficient values mod modulus and the indices mod N.

Parameters
poly2:IntegerPolynomial

a polynomial

modulus:int

a modulus to apply

Returns:IntegerPolynomial

the product of the two polynomials

sizeback to summary
public int size()

Implements org.bouncycastle.pqc.legacy.math.ntru.polynomial.TernaryPolynomial.size.

Doc from org.bouncycastle.pqc.legacy.math.ntru.polynomial.TernaryPolynomial.size.

Returns the maximum number of coefficients the polynomial can have