HFE
Class HFE2_n

java.lang.Object
  |
  +--HFE.HFE2_n
All Implemented Interfaces:
CheckRoot

class HFE2_n
extends java.lang.Object
implements CheckRoot

This class is the "central class" of QuartzLight and is used for speed measurement.

Version:
0.15

Field Summary
private static int[] codeVec
          Cipher as a vector.
(package private) static int extensionDegree
          Holds the degree of the irreducible polynomial and thereby also the degree of the extension field
(package private)  boolean foundRoot
          signals if we found a root or not, i.e., if the root-field is valid or not.
(package private) static int[] generatingPolynomial
          Central switch to change generating polynomial.
(package private) static Poly2Max generatingPolynomialAsMaxPoly
          Polynomial set in variable generatingPolynomial but as a Poly2Max polynomial.
(package private) static int messageSigLength
          Holds the number of bits for a message in terms of a signature.
(package private) static int padBits
          Holds the number of bits for a message in terms of a signature.
private  Poly2_nMax privatePoly
          Stores the private polynomial over GF(2^n).
private  Poly2MultiSquare[] publicPoly
          Stores the public key in an array of polynomials.
(package private) static int reductionTerm
          Central switch to change the reduction term, i.e.
private static int[] resVec
          Message as a vector.
(package private)  java.util.Random rnd
          Random number generator for signature generation
private  RootFinding rootFinder
          Root finding algorithm
private static int[] rootVec
          Message as a vector.
(package private) static int signatureLength
          Holds the number of bits for a signature.
private static int[] sigTmpVec
          Hash of message as a vector.
private static int[] textVec
          Message as a vector.
private static Field2_n tmpElem1
          Temporary register [element of GF(2^n)].
private static Field2_n tmpElem2
          Temporary register [element of GF(2^n)].
private  Transform2 transS
          Transformation S in HFE
private  AffinePolyVec transSpoly
          Transform S in HFE in terms of affine polynomials
private  Transform2 transT
          Transformation T in HFE
private  AffinePolyVec transTpoly
          Transform T in HFE in terms of affine polynomials
private static int[] valueVec
          Message in a special format as a vector.
 
Constructor Summary
(package private) HFE2_n(byte[] seed)
          Initializes HFE2_n by generating the public and the private key from the given seed.
 
Method Summary
 boolean checkRoot(Field2_n root)
          Collects the roots.
private  void encryptPrivate(Field2_n plain, Field2_n res)
          Encryptes a given, n bit plain text.
(package private)  void generateKeys(byte[] seed)
          Generates the public and the private key from a given seed and stores them in the object's fields.
(package private)  void generateKeysInterpoly(byte[] seed)
          Generates the public and the private key from a given seed and stores them in the object's fields.
private static Poly2_nMax genPolyPrivate(java.security.SecureRandom rndGen)
          Generates a private polynomial for HFE.
private  void genPolyPublic()
          Generats the public polynomials from the private polynomial using base transformation.
private  void genPolyPublicInterpoly(Poly2MultiSquare[] res)
          Generats the public polynomials from the private polynomial using polynomial interpolation.
private  Poly2MultiSquare[] genPolyPublicSlow()
          Generats the public polynomials from the private polynomial using base transformation.
 void genSign(int[] message, int[] res)
          Generates signature for given message using (S,P,T).
static void main(java.lang.String[] args)
          Tests everything in this class
static void speedIt()
          Tests how fast the package runs on the current hardware.
static void testIt()
          Tests the functionality of the whole class.
 boolean valSign(int[] message, int[] sig)
          Validates if given signature sig is valid or not.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

generatingPolynomial

static final int[] generatingPolynomial
Central switch to change generating polynomial. Saves only the powers as the coefficients must be 1. The same polynomial (but in a different format) is stored in generatingPolynomialAsMaxPoly

reductionTerm

static final int reductionTerm
Central switch to change the reduction term, i.e. the part of the polynomial with is not the degree and not zero

extensionDegree

static final int extensionDegree
Holds the degree of the irreducible polynomial and thereby also the degree of the extension field

generatingPolynomialAsMaxPoly

static final Poly2Max generatingPolynomialAsMaxPoly
Polynomial set in variable generatingPolynomial but as a Poly2Max polynomial. Does not need to be changed for different Field2_n.

padBits

static final int padBits
Holds the number of bits for a message in terms of a signature. Is 7 in Quartz.

messageSigLength

static final int messageSigLength
Holds the number of bits for a message in terms of a signature. This is smaller than messageLength as we need some "extra bits" for random padding.

signatureLength

static final int signatureLength
Holds the number of bits for a signature.

foundRoot

boolean foundRoot
signals if we found a root or not, i.e., if the root-field is valid or not.

privatePoly

private Poly2_nMax privatePoly
Stores the private polynomial over GF(2^n). Is used for decryption.

publicPoly

private Poly2MultiSquare[] publicPoly
Stores the public key in an array of polynomials. Is used for encryption - slow variation!

transS

private Transform2 transS
Transformation S in HFE

transT

private Transform2 transT
Transformation T in HFE

transSpoly

private AffinePolyVec transSpoly
Transform S in HFE in terms of affine polynomials

transTpoly

private AffinePolyVec transTpoly
Transform T in HFE in terms of affine polynomials

rootFinder

private RootFinding rootFinder
Root finding algorithm

textVec

private static int[] textVec
Message as a vector. For the sake of speed is it a static.

sigTmpVec

private static int[] sigTmpVec
Hash of message as a vector. For the sake of speed is it a static. Is used in genSign(int[], int[])

resVec

private static int[] resVec
Message as a vector. For the sake of speed is it a static.

rootVec

private static int[] rootVec
Message as a vector. For the sake of speed is it a static. Is used in genSign(int[], int[])

valueVec

private static int[] valueVec
Message in a special format as a vector. For the sake of speed is it a static.

codeVec

private static int[] codeVec
Cipher as a vector. For the sake of speed static.

tmpElem1

private static Field2_n tmpElem1
Temporary register [element of GF(2^n)]. Static for the sake of speed

tmpElem2

private static Field2_n tmpElem2
Temporary register [element of GF(2^n)]. Static for the sake of speed

rnd

java.util.Random rnd
Random number generator for signature generation
Constructor Detail

HFE2_n

HFE2_n(byte[] seed)
Initializes HFE2_n by generating the public and the private key from the given seed. Also generates the message digest.
Parameters:
seed - Seed for the cryptographic random number generator.
Method Detail

genPolyPrivate

private static Poly2_nMax genPolyPrivate(java.security.SecureRandom rndGen)
Generates a private polynomial for HFE.
Parameters:
rndGen - Secure random number generator
Returns:
private polynomial

genPolyPublicSlow

private Poly2MultiSquare[] genPolyPublicSlow()
Generats the public polynomials from the private polynomial using base transformation. This implementation is slow as it is based on slow implementations of multivariables polynomial vectors
Returns:
public polynomials

genPolyPublic

private void genPolyPublic()
Generats the public polynomials from the private polynomial using base transformation.
Returns:
public polynomials

genPolyPublicInterpoly

private void genPolyPublicInterpoly(Poly2MultiSquare[] res)
Generats the public polynomials from the private polynomial using polynomial interpolation.
Returns:
public polynomials

generateKeys

void generateKeys(byte[] seed)
Generates the public and the private key from a given seed and stores them in the object's fields.
Parameters:
seed - Seed for the random number generator. Must be "quite long" to be secure (e.g., at least 80 bits in the Quartz standard).

generateKeysInterpoly

void generateKeysInterpoly(byte[] seed)
Generates the public and the private key from a given seed and stores them in the object's fields.
Parameters:
seed - Seed for the random number generator. Must be "quite long" to be secure (e.g., at least 80 bits in the Quartz standard).

encryptPrivate

private void encryptPrivate(Field2_n plain,
                            Field2_n res)
Encryptes a given, n bit plain text.
Uses private key. Is used during public key generation. Needs transSpoly, transTpoly to be initialized correctly.
Parameters:
plain - plaintext as element from Field2_n
res - result as element from Field2_n

genSign

public void genSign(int[] message,
                    int[] res)
Generates signature for given message using (S,P,T).
Parameters:
message - to sign (in general: hash of this message with messageSigLength bits)
res - signature for this message with signatureLength bits

valSign

public boolean valSign(int[] message,
                       int[] sig)
Validates if given signature sig is valid or not.
Parameters:
message - which was signed (in general: hash of this message with messageSigLength bits) using method genSign(int[], int[])
sig - signature for this message with signatureLength bits
Returns:
true iff sig is valid for current public key

checkRoot

public boolean checkRoot(Field2_n root)
Collects the roots. In an encryption scheme, it would also check if the root is the correct message.
Specified by:
checkRoot in interface CheckRoot
Returns:
false

testIt

public static void testIt()
Tests the functionality of the whole class. If there occurs any error it will be printed on stdout.

speedIt

public static final void speedIt()
Tests how fast the package runs on the current hardware.

main

public static void main(java.lang.String[] args)
Tests everything in this class
See Also:
testIt()