Class DenseTernaryPolynomial
java.lang.Object
org.bouncycastle.pqc.legacy.math.ntru.polynomial.IntegerPolynomial
org.bouncycastle.pqc.legacy.math.ntru.polynomial.DenseTernaryPolynomial
- All Implemented Interfaces:
Polynomial,TernaryPolynomial
A
TernaryPolynomial with a "high" number of nonzero coefficients.-
Field Summary
Fields inherited from class org.bouncycastle.pqc.legacy.math.ntru.polynomial.IntegerPolynomial
coeffs -
Constructor Summary
ConstructorsConstructorDescriptionDenseTernaryPolynomial(int[] coeffs) Constructs a newDenseTernaryPolynomialwith a given set of coefficients.DenseTernaryPolynomial(IntegerPolynomial intPoly) Constructs aDenseTernaryPolynomialfrom aIntegerPolynomial. -
Method Summary
Modifier and TypeMethodDescriptionstatic DenseTernaryPolynomialgenerateRandom(int N, int numOnes, int numNegOnes, SecureRandom random) Generates a random polynomial withnumOnescoefficients equal to 1,numNegOnescoefficients equal to -1, and the rest equal to 0.static DenseTernaryPolynomialgenerateRandom(int N, SecureRandom random) Generates a polynomial with coefficients randomly selected from{-1, 0, 1}.int[]int[]getOnes()mult(IntegerPolynomial poly2, int modulus) Multiplies the polynomial with another, taking the values mod modulus and the indices mod Nintsize()Returns the maximum number of coefficients the polynomial can haveMethods inherited from class org.bouncycastle.pqc.legacy.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, toIntegerPolynomialMethods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.bouncycastle.pqc.legacy.math.ntru.polynomial.Polynomial
mult, toIntegerPolynomialMethods inherited from interface org.bouncycastle.pqc.legacy.math.ntru.polynomial.TernaryPolynomial
clear, mult
-
Constructor Details
-
DenseTernaryPolynomial
Constructs aDenseTernaryPolynomialfrom aIntegerPolynomial. The two polynomials are independent of each other.- Parameters:
intPoly- the original polynomial
-
DenseTernaryPolynomial
public DenseTernaryPolynomial(int[] coeffs) Constructs a newDenseTernaryPolynomialwith a given set of coefficients.- Parameters:
coeffs- the coefficients
-
-
Method Details
-
generateRandom
public static DenseTernaryPolynomial generateRandom(int N, int numOnes, int numNegOnes, SecureRandom random) Generates a random polynomial withnumOnescoefficients equal to 1,numNegOnescoefficients equal to -1, and the rest equal to 0.- Parameters:
N- number of coefficientsnumOnes- number of 1'snumNegOnes- number of -1's
-
generateRandom
Generates a polynomial with coefficients randomly selected from{-1, 0, 1}.- Parameters:
N- number of coefficients
-
mult
Description copied from class:IntegerPolynomialMultiplies the polynomial with another, taking the values mod modulus and the indices mod N- Specified by:
multin interfacePolynomial- Overrides:
multin classIntegerPolynomial- Parameters:
poly2- a polynomialmodulus- a modulus to apply- Returns:
- the product of the two polynomials
-
getOnes
public int[] getOnes()- Specified by:
getOnesin interfaceTernaryPolynomial
-
getNegOnes
public int[] getNegOnes()- Specified by:
getNegOnesin interfaceTernaryPolynomial
-
size
public int size()Description copied from interface:TernaryPolynomialReturns the maximum number of coefficients the polynomial can have- Specified by:
sizein interfaceTernaryPolynomial
-