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

public Class LongPolynomial2

extends Object
Class Inheritance
Imports
org.bouncycastle.util.Arrays

A polynomial class that combines two coefficients into one long value for faster multiplication in 64 bit environments.
Coefficients can be between 0 and 2047 and are stored in pairs in the bits 0..10 and 24..34 of a long number.

Field Summary

Modifier and TypeField and Description
private long[]
private int

Constructor Summary

AccessConstructor and Description
public
LongPolynomial2(IntegerPolynomial
the original polynomial. Coefficients must be between 0 and 2047.
p
)

Constructs a LongPolynomial2 from a IntegerPolynomial.

private
LongPolynomial2(long[] coeffs)

private

Method Summary

Modifier and TypeMethod and Description
private void
add(LongPolynomial2
another polynomial
b
)

Adds another polynomial which can have a different number of coefficients.

public Object
clone()

Overrides java.lang.Object.clone.

Creates and returns a copy of this object.
public boolean
equals(Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public LongPolynomial2
mult(LongPolynomial2 poly2)

Multiplies the polynomial with another, taking the indices mod N and the values mod 2048.

public void
mult2And(int
a bit mask less than 2048 to apply to each 11-bit coefficient
mask
)

Multiplies this polynomial by 2 and applies an AND mask to the upper and lower halves of each coefficients.

private LongPolynomial2
multRecursive(LongPolynomial2 poly2)

Karazuba multiplication

private void
sub(LongPolynomial2
another polynomial
b
)

Subtracts another polynomial which can have a different number of coefficients.

public void
subAnd(LongPolynomial2
another polynomial
b
,
int
a bit mask less than 2048 to apply to each 11-bit coefficient
mask
)

Subtracts another polynomial which must have the same number of coefficients, and applies an AND mask to the upper and lower halves of each coefficients.

public IntegerPolynomial
Inherited from java.lang.Object:
finalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

coeffsback to summary
private long[] coeffs
numCoeffsback to summary
private int numCoeffs

Constructor Detail

LongPolynomial2back to summary
public LongPolynomial2(IntegerPolynomial p)

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

Parameters
p:IntegerPolynomial

the original polynomial. Coefficients must be between 0 and 2047.

LongPolynomial2back to summary
private LongPolynomial2(long[] coeffs)
LongPolynomial2back to summary
private LongPolynomial2(int N)

Method Detail

addback to summary
private void add(LongPolynomial2 b)

Adds another polynomial which can have a different number of coefficients.

Parameters
b:LongPolynomial2

another polynomial

cloneback to summary
public Object clone()

Overrides java.lang.Object.clone.

Doc from java.lang.Object.clone.

Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object x, the expression:

x.clone() != x
will be true, and that the expression:
x.clone().getClass() == x.getClass()
will be true, but these are not absolute requirements. While it is typically the case that:
x.clone().equals(x)
will be true, this is not an absolute requirement.

By convention, the returned object should be obtained by calling super.clone. If a class and all of its superclasses (except Object) obey this convention, it will be the case that x.clone().getClass() == x.getClass().

By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by super.clone before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by super.clone need to be modified.

Returns:Object

a clone of this instance.

equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

multback to summary
public LongPolynomial2 mult(LongPolynomial2 poly2)

Multiplies the polynomial with another, taking the indices mod N and the values mod 2048.

mult2Andback to summary
public void mult2And(int mask)

Multiplies this polynomial by 2 and applies an AND mask to the upper and lower halves of each coefficients.

Parameters
mask:int

a bit mask less than 2048 to apply to each 11-bit coefficient

multRecursiveback to summary
private LongPolynomial2 multRecursive(LongPolynomial2 poly2)

Karazuba multiplication

subback to summary
private void sub(LongPolynomial2 b)

Subtracts another polynomial which can have a different number of coefficients.

Parameters
b:LongPolynomial2

another polynomial

subAndback to summary
public void subAnd(LongPolynomial2 b, int mask)

Subtracts another polynomial which must have the same number of coefficients, and applies an AND mask to the upper and lower halves of each coefficients.

Parameters
b:LongPolynomial2

another polynomial

mask:int

a bit mask less than 2048 to apply to each 11-bit coefficient

toIntegerPolynomialback to summary
public IntegerPolynomial toIntegerPolynomial()