de.flexiprovider.common.math.polynomials
Class BinaryConvolutionPolynomial

java.lang.Object
  |
  +--de.flexiprovider.common.math.polynomials.BinaryConvolutionPolynomial
All Implemented Interfaces:
ConvolutionPolynomial

public class BinaryConvolutionPolynomial
extends java.lang.Object
implements ConvolutionPolynomial

This class represents binary polynomials in the ring Z(X)/(X^N-1). The coefficients of the polynomials are stored as compressed int arrays (32 coefficients per int).

Author:
Martin Döring

Field Summary
(package private)  int[] coefficients
          The coefficient array
(package private)  int degree
          The degree of this polynomial
(package private)  int N
          The degree of the reduction polynomial
 
Constructor Summary
BinaryConvolutionPolynomial(BinaryConvolutionPolynomial other)
          Copy constructor.
BinaryConvolutionPolynomial(int N, int[] coefficients)
          Create a binary polynomial out of the given coefficient array
BinaryConvolutionPolynomial(int N, int d, SecureRandom sr)
          Create a binary polynomial of degree less than N.
 
Method Summary
 boolean equals(java.lang.Object other)
          Compare this binary polynomial with the given object.
(package private)  int[][] getPatternLocations(int w)
          Compute an array of bit pattern locations given a windows size according to Algorithm 2 of M.-K.
 int hashCode()
           
(package private)  int numCoeffs()
          Compute the number of 1 coefficients of this binary polynomial.
 void setCoefficient(int index)
          Set the coefficient with the given index.
 boolean testCoefficient(int index)
          Test whether the coefficient with the given index is 1.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
, clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

N

int N
The degree of the reduction polynomial

degree

int degree
The degree of this polynomial

coefficients

int[] coefficients
The coefficient array
Constructor Detail

BinaryConvolutionPolynomial

public BinaryConvolutionPolynomial(int N,
                                   int[] coefficients)
                            throws java.lang.IllegalArgumentException
Create a binary polynomial out of the given coefficient array
Parameters:
N - the degree of the reduction polynomial
coefficients - the coefficient array
Throws:
java.lang.IllegalArgumentException - if the degree of the given coefficient array is >= N.

BinaryConvolutionPolynomial

public BinaryConvolutionPolynomial(int N,
                                   int d,
                                   SecureRandom sr)
Create a binary polynomial of degree less than N.
Parameters:
N - the degree of the reduction polynomial
d - the number of non-zero coefficients
sr - source of randomness to create the polynomial

BinaryConvolutionPolynomial

public BinaryConvolutionPolynomial(BinaryConvolutionPolynomial other)
Copy constructor.
Parameters:
other - another BinaryPolynomial
Method Detail

setCoefficient

public void setCoefficient(int index)
Set the coefficient with the given index. If the index is out of bounds, do nothing.
Parameters:
index - the index

testCoefficient

public boolean testCoefficient(int index)
Test whether the coefficient with the given index is 1. If the index if out of bounds, return false.
Parameters:
index - the index of the coefficient to test
Returns:
true if the coefficient with the given index is 1, false otherwise or if the index is out of bounds

getPatternLocations

int[][] getPatternLocations(int w)
Compute an array of bit pattern locations given a windows size according to Algorithm 2 of M.-K. Lee, J. W. Kim, J. E. Song, and K. Park, "Sliding Window Method for NTRU", LNCS 4521.
Parameters:
w - the window size
Returns:
an array [b_0, ... b_{w-1}] of bit pattern locations

equals

public boolean equals(java.lang.Object other)
Compare this binary polynomial with the given object.
Overrides:
equals in class java.lang.Object
Parameters:
other - the other object
Returns:
the result of the comparison

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object
Returns:
the hash code of this polynomial

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
a human readable form of this polynomial

numCoeffs

int numCoeffs()
Compute the number of 1 coefficients of this binary polynomial.
Returns:
the number of 1 coefficients