de.flexiprovider.common.math.polynomials
Class SparseBinaryConvolutionPolynomial

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

public class SparseBinaryConvolutionPolynomial
extends java.lang.Object
implements ConvolutionPolynomial

This class represents sparse binary polynomials in the ring Z(X)/(X^N-1). The polynomials are stored as int arrays of the degrees of the monomials with coefficient 1.

Author:
Martin Döring

Field Summary
(package private)  int[] degrees
          The array of the degrees of the monomials with coefficient 1
(package private)  int N
          The degree of the reduction polynomial
 
Constructor Summary
SparseBinaryConvolutionPolynomial(BinaryConvolutionPolynomial binPol)
          Construct a SparseBinaryConvolutionPolynomial out of the given BinaryConvolutionPolynomial.
SparseBinaryConvolutionPolynomial(int N, int[] degrees)
          Create a sparse binary polynomial out of the given degree array
SparseBinaryConvolutionPolynomial(int N, int d, SecureRandom sr)
          Create a sparse binary polynomial of degree less than N.
SparseBinaryConvolutionPolynomial(SparseBinaryConvolutionPolynomial other)
          Copy constructor.
 
Method Summary
 boolean equals(java.lang.Object other)
          Compare this 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[][] getPatterns()
          Compute an array of bit pattern locations (minimal size).
 int hashCode()
           
static SparseBinaryConvolutionPolynomial OS2REP(int N, int d, byte[] encoded)
          Create a sparse binary polynomial out of the given byte array.
 byte[] RE2OSP()
          Encode this polynomial as a byte array.
 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

degrees

int[] degrees
The array of the degrees of the monomials with coefficient 1
Constructor Detail

SparseBinaryConvolutionPolynomial

public SparseBinaryConvolutionPolynomial(int N,
                                         int[] degrees)
Create a sparse binary polynomial out of the given degree array
Parameters:
N - the degree of the reduction polynomial
degrees - the array of the degrees of the monomials with coefficient 1

SparseBinaryConvolutionPolynomial

public SparseBinaryConvolutionPolynomial(int N,
                                         int d,
                                         SecureRandom sr)
Create a sparse 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

SparseBinaryConvolutionPolynomial

public SparseBinaryConvolutionPolynomial(BinaryConvolutionPolynomial binPol)
Construct a SparseBinaryConvolutionPolynomial out of the given BinaryConvolutionPolynomial.
Parameters:
binPol - the BinaryPolynomial

SparseBinaryConvolutionPolynomial

public SparseBinaryConvolutionPolynomial(SparseBinaryConvolutionPolynomial other)
Copy constructor.
Parameters:
other - another SparseBinaryPolynomial
Method Detail

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

getPatterns

public int[][] getPatterns()
Compute an array of bit pattern locations (minimal size).
Returns:
an array of bit pattern locations

equals

public boolean equals(java.lang.Object other)
Compare this 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

RE2OSP

public byte[] RE2OSP()
Encode this polynomial as a byte array.
Returns:
the encoded polynomial

OS2REP

public static SparseBinaryConvolutionPolynomial OS2REP(int N,
                                                       int d,
                                                       byte[] encoded)
                                                throws java.lang.IllegalArgumentException
Create a sparse binary polynomial out of the given byte array.
Parameters:
N - the degree of the reduction polynomial
d - the number of non-zero coefficients
encoded - an encoded sparse binary polynomial
Returns:
the decoded polynomial
Throws:
java.lang.IllegalArgumentException - if the encoded polynomial has wrong length.

toString

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