|
Bouncy Castle Cryptography 1.50 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.bouncycastle.pqc.math.ntru.polynomial.SparseTernaryPolynomial
public class SparseTernaryPolynomial
A TernaryPolynomial with a "low" number of nonzero coefficients.
| Constructor Summary | |
|---|---|
SparseTernaryPolynomial(int[] coeffs)
Constructs a new SparseTernaryPolynomial with a given set of coefficients. |
|
SparseTernaryPolynomial(IntegerPolynomial intPoly)
Constructs a DenseTernaryPolynomial from a IntegerPolynomial. |
|
| Method Summary | |
|---|---|
void |
clear()
|
boolean |
equals(java.lang.Object obj)
|
static SparseTernaryPolynomial |
fromBinary(java.io.InputStream is,
int N,
int numOnes,
int numNegOnes)
Decodes a byte array encoded with toBinary() to a ploynomial. |
static SparseTernaryPolynomial |
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. |
int[] |
getNegOnes()
|
int[] |
getOnes()
|
int |
hashCode()
|
BigIntPolynomial |
mult(BigIntPolynomial poly2)
Multiplies the polynomial by a BigIntPolynomial, taking the indices mod N. |
IntegerPolynomial |
mult(IntegerPolynomial poly2)
Multiplies the polynomial by an IntegerPolynomial, taking the indices mod N |
IntegerPolynomial |
mult(IntegerPolynomial poly2,
int modulus)
Multiplies the polynomial by an IntegerPolynomial,
taking the coefficient values mod modulus and the indices mod N. |
int |
size()
Returns the maximum number of coefficients the polynomial can have |
byte[] |
toBinary()
Encodes the polynomial to a byte array writing BITS_PER_INDEX bits for each coefficient. |
IntegerPolynomial |
toIntegerPolynomial()
Returns a polynomial that is equal to this polynomial (in the sense that Polynomial.mult(IntegerPolynomial, int)
returns equal IntegerPolynomials). |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SparseTernaryPolynomial(IntegerPolynomial intPoly)
DenseTernaryPolynomial from a IntegerPolynomial. The two polynomials are
independent of each other.
intPoly - the original polynomialpublic SparseTernaryPolynomial(int[] coeffs)
SparseTernaryPolynomial with a given set of coefficients.
coeffs - the coefficients| Method Detail |
|---|
public static SparseTernaryPolynomial fromBinary(java.io.InputStream is,
int N,
int numOnes,
int numNegOnes)
throws java.io.IOException
toBinary() to a ploynomial.
is - an input stream containing an encoded polynomialN - number of coefficients including zerosnumOnes - number of coefficients equal to 1numNegOnes - number of coefficients equal to -1
java.io.IOException
public static SparseTernaryPolynomial generateRandom(int N,
int numOnes,
int numNegOnes,
java.security.SecureRandom random)
numOnes coefficients equal to 1,
numNegOnes coefficients equal to -1, and the rest equal to 0.
N - number of coefficientsnumOnes - number of 1'snumNegOnes - number of -1'spublic IntegerPolynomial mult(IntegerPolynomial poly2)
TernaryPolynomialIntegerPolynomial, taking the indices mod N
mult in interface Polynomialmult in interface TernaryPolynomialpoly2 - a polynomial
public IntegerPolynomial mult(IntegerPolynomial poly2,
int modulus)
PolynomialIntegerPolynomial,
taking the coefficient values mod modulus and the indices mod N.
mult in interface Polynomialpoly2 - a polynomialmodulus - a modulus to apply
public BigIntPolynomial mult(BigIntPolynomial poly2)
PolynomialBigIntPolynomial, taking the indices mod N. Does not
change this polynomial but returns the result as a new polynomial.
mult in interface Polynomialpoly2 - the polynomial to multiply by
public int[] getOnes()
getOnes in interface TernaryPolynomialpublic int[] getNegOnes()
getNegOnes in interface TernaryPolynomialpublic byte[] toBinary()
BITS_PER_INDEX bits for each coefficient.
public IntegerPolynomial toIntegerPolynomial()
PolynomialPolynomial.mult(IntegerPolynomial, int)
returns equal IntegerPolynomials). The new polynomial is guaranteed to be independent of the original.
toIntegerPolynomial in interface PolynomialIntegerPolynomial.public int size()
TernaryPolynomial
size in interface TernaryPolynomialpublic void clear()
clear in interface TernaryPolynomialpublic int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Object
|
Bouncy Castle Cryptography 1.50 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||