de.flexiprovider.common.math.polynomials
Class GFP64Polynomial

java.lang.Object
  |
  +--de.flexiprovider.common.math.polynomials.GFP64Polynomial

public class GFP64Polynomial
extends java.lang.Object

An Element of this class represents a Polynomial within a GFP Ring Structure.

The Structure is defined by the modulo Function and the large "prime" p. This Class has methods for multiplying, adding and reducing Polynomials.

This Class has been developed mainly for the LMOTS Signature scheme, so the available methods may not be a complete Implementation of the methods that may be required or expected on Ring Arithmetic and some of the implemented Methods are intended only for use of the LMOTS Signature scheme. Such as the ability to create random Polynomials within this Ring Structure with a custom modulo limit or Multiplication of a Polynomial with a Vector of Polynomials.


Constructor Summary
GFP64Polynomial(byte[] encoded)
          Constructor for decoding a previously encoded GFPPolynomial using the getEncoded() method
GFP64Polynomial(long[] f, long p, long[] poly)
          Standard Constructor for generating a new GFPPolynomial
GFP64Polynomial(long[] f, long p, SecureRandom gen)
          Special Constructor without a Polynomial parameter but with a Secure Random generator.
 
Method Summary
 GFP64Polynomial add(GFP64Polynomial gfp)
          adds the given Polynomial to this Polynomial and returns the result
 void addToThis(GFP64Polynomial gfp)
          Adds the supplied Polynomial to this Polynomial and sets this Polynomial as the result
 boolean arrEqual(long[] arr1, long[] arr2)
           
 boolean equals(java.lang.Object obj)
           
 GFP64Polynomial generatePoly()
          Generates a random Polynomial, complying to the specification of this Ring
 GFP64Polynomial generatePoly(long limit)
          Generates a random Polynomial with the specified limit, denoting the maximum Value of entries in this Polynomial.
 GFP64Polynomial generatePoly(long limit, boolean negative)
           
 long[] getCompressed()
          Subtracts p from every entry in this polynomial with a value greater p/2.
 byte[] getEncoded()
           
 long[] getF()
           
 long getP()
           
 long[] getPoly()
           
 SecureRandom getRandomizer()
           
 GFP64Polynomial multiply(GFP64Polynomial gfp)
          multiplies the given Polynomial to this Polynomial and returns the Result
 java.util.Vector multiply(java.util.Vector k)
          multiplies this Polynomial with a Vector of Polynomials and returns the Result
 void multiplyToThis(GFP64Polynomial gfp)
          Multiplies the given Polynomial to this Polynomial and sets this Polynomial to the Result
 boolean paramEqual(GFP64Polynomial gfp)
           
 void print()
           
 GFP64Polynomial subtract(GFP64Polynomial gfp)
           
 void subtractFromThis(GFP64Polynomial gfp)
           
 
Methods inherited from class java.lang.Object
, clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GFP64Polynomial

public GFP64Polynomial(byte[] encoded)
                throws codec.asn1.ASN1Exception,
                       java.io.IOException
Constructor for decoding a previously encoded GFPPolynomial using the getEncoded() method
Parameters:
encoded - the byte array containing the encoded GFPPolynomial
Throws:
java.io.IOException -  
codec.asn1.ASN1Exception -  

GFP64Polynomial

public GFP64Polynomial(long[] f,
                       long p,
                       long[] poly)
Standard Constructor for generating a new GFPPolynomial
Parameters:
f - the modulo Polynomial of the Ring
p - the modulo "prime" of the Ring
poly - the Polynomial an long array, most significant entry is right

GFP64Polynomial

public GFP64Polynomial(long[] f,
                       long p,
                       SecureRandom gen)
Special Constructor without a Polynomial parameter but with a Secure Random generator. This Constructor can only be used for methods which do not require a Polynomial to be present, such as generatePoly()
Parameters:
f - the modulo Polynomial of the Ring
p - the modulo "prime" of the Ring
gen - a predefined secure Random Number Generator
Method Detail

add

public GFP64Polynomial add(GFP64Polynomial gfp)
adds the given Polynomial to this Polynomial and returns the result
Parameters:
gfp - the Polynomial to be added
Returns:
the Addition of the two Polynomials

addToThis

public void addToThis(GFP64Polynomial gfp)
Adds the supplied Polynomial to this Polynomial and sets this Polynomial as the result
Parameters:
gfp - the Polynomial to be added

arrEqual

public boolean arrEqual(long[] arr1,
                        long[] arr2)

getCompressed

public long[] getCompressed()
Subtracts p from every entry in this polynomial with a value greater p/2.

This Function is used for calculating the correct Norm of a Polynomial, since the Norm uses the absolute Value for determining the Maximum

Returns:
the compressed polynomial

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

generatePoly

public GFP64Polynomial generatePoly()
Generates a random Polynomial, complying to the specification of this Ring
Returns:
the randomly generated Polynomial

generatePoly

public GFP64Polynomial generatePoly(long limit)
Generates a random Polynomial with the specified limit, denoting the maximum Value of entries in this Polynomial.
Parameters:
limit - the limit to be used for modulo in the generated Polynomial. Only used if the supplied number is lower than p, otherwise p is used.
Returns:
the randomly generated Polynomial

generatePoly

public GFP64Polynomial generatePoly(long limit,
                                    boolean negative)

getEncoded

public byte[] getEncoded()
                  throws codec.asn1.ASN1Exception,
                         java.io.IOException

getF

public long[] getF()

getP

public long getP()

getPoly

public long[] getPoly()
Returns:
The (reduced) Polynomial as an long array

getRandomizer

public SecureRandom getRandomizer()

multiply

public GFP64Polynomial multiply(GFP64Polynomial gfp)
multiplies the given Polynomial to this Polynomial and returns the Result
Parameters:
gfp - the Polynomial to be multiplied
Returns:
the Product of the two Polynomials

multiply

public java.util.Vector multiply(java.util.Vector k)
multiplies this Polynomial with a Vector of Polynomials and returns the Result

Multiplication with a Vector is designed as follows:

Vector � = (a1, a2, ... , am), Polynomial p � * p = (a1*p, a2*p, ... , am * p)

Parameters:
k - the Vector of Polynomials to be multiplied
Returns:
the Vector of the Product

multiplyToThis

public void multiplyToThis(GFP64Polynomial gfp)
Multiplies the given Polynomial to this Polynomial and sets this Polynomial to the Result
Parameters:
gfp - the Polynomial to be multiplied

paramEqual

public boolean paramEqual(GFP64Polynomial gfp)

print

public void print()

subtract

public GFP64Polynomial subtract(GFP64Polynomial gfp)

subtractFromThis

public void subtractFromThis(GFP64Polynomial gfp)