Class ProductFormPolynomial
java.lang.Object
org.bouncycastle.pqc.legacy.math.ntru.polynomial.ProductFormPolynomial
- All Implemented Interfaces:
Polynomial
A polynomial of the form
f1*f2+f3
, where
f1,f2,f3
are very sparsely populated ternary polynomials.-
Constructor Summary
ConstructorDescriptionProductFormPolynomial
(SparseTernaryPolynomial f1, SparseTernaryPolynomial f2, SparseTernaryPolynomial f3) -
Method Summary
Modifier and TypeMethodDescriptionboolean
static ProductFormPolynomial
fromBinary
(byte[] data, int N, int df1, int df2, int df3Ones, int df3NegOnes) static ProductFormPolynomial
fromBinary
(InputStream is, int N, int df1, int df2, int df3Ones, int df3NegOnes) static ProductFormPolynomial
generateRandom
(int N, int df1, int df2, int df3Ones, int df3NegOnes, SecureRandom random) int
hashCode()
Multiplies the polynomial by aBigIntPolynomial
, taking the indices mod N.Multiplies the polynomial by anIntegerPolynomial
, taking the indices modN
.mult
(IntegerPolynomial poly2, int modulus) Multiplies the polynomial by anIntegerPolynomial
, taking the coefficient values modmodulus
and the indices modN
.byte[]
toBinary()
Returns a polynomial that is equal to this polynomial (in the sense thatPolynomial.mult(IntegerPolynomial, int)
returns equalIntegerPolynomial
s).
-
Constructor Details
-
ProductFormPolynomial
public ProductFormPolynomial(SparseTernaryPolynomial f1, SparseTernaryPolynomial f2, SparseTernaryPolynomial f3)
-
-
Method Details
-
generateRandom
public static ProductFormPolynomial generateRandom(int N, int df1, int df2, int df3Ones, int df3NegOnes, SecureRandom random) -
fromBinary
public static ProductFormPolynomial fromBinary(byte[] data, int N, int df1, int df2, int df3Ones, int df3NegOnes) throws IOException - Throws:
IOException
-
fromBinary
public static ProductFormPolynomial fromBinary(InputStream is, int N, int df1, int df2, int df3Ones, int df3NegOnes) throws IOException - Throws:
IOException
-
toBinary
public byte[] toBinary() -
mult
Description copied from interface:Polynomial
Multiplies the polynomial by anIntegerPolynomial
, taking the indices modN
.- Specified by:
mult
in interfacePolynomial
- Parameters:
b
- a polynomial- Returns:
- the product of the two polynomials
-
mult
Description copied from interface:Polynomial
Multiplies the polynomial by aBigIntPolynomial
, taking the indices mod N. Does not change this polynomial but returns the result as a new polynomial.
Both polynomials must have the same number of coefficients.- Specified by:
mult
in interfacePolynomial
- Parameters:
b
- the polynomial to multiply by- Returns:
- a new polynomial
-
toIntegerPolynomial
Description copied from interface:Polynomial
Returns a polynomial that is equal to this polynomial (in the sense thatPolynomial.mult(IntegerPolynomial, int)
returns equalIntegerPolynomial
s). The new polynomial is guaranteed to be independent of the original.- Specified by:
toIntegerPolynomial
in interfacePolynomial
- Returns:
- a new
IntegerPolynomial
.
-
mult
Description copied from interface:Polynomial
Multiplies the polynomial by anIntegerPolynomial
, taking the coefficient values modmodulus
and the indices modN
.- Specified by:
mult
in interfacePolynomial
- Parameters:
poly2
- a polynomialmodulus
- a modulus to apply- Returns:
- the product of the two polynomials
-
hashCode
public int hashCode() -
equals
-