HFE
Class Field4

java.lang.Object
  |
  +--HFE.Field4

final class Field4
extends java.lang.Object

This class encapsulates the operations for a finite field with 4 elements. The current field is generated by the polynomial f(x) = x^2 + x + 1
Most operations are performed using a look-up table, add and sub are using xor for integers.

Version:
0.1

Field Summary
private static int[][] divTab
          look-up table for multiplication
static int elements
          number of elements in this field
private static int[][] mulTab
          look-up table for multiplication
 
Constructor Summary
(package private) Field4()
           
 
Method Summary
static int add(int ter1, int ter2)
          Adds two numbers using the xor function for intergers.
static int div(int whom, int by)
          Divides two numbers using finite field arithmetic in F_4.
static boolean isElement(int elem)
          Checks if a given integer is within the range of a Field4 element.
static boolean isElement(int[] elems)
          Checks if a given vector consists only of Field4 elements.
static boolean isElement(int[][] elems)
          Checks if a given matrix consists only of Field4 elements.
static void main(java.lang.String[] args)
          Tests everything in this class
static int mul(int fac1, int fac2)
          Multiplies two numbers using finite field arithmetic in F_4.
static int rnd(java.util.Random rnd)
          returns a random element from Field4.
static int sub(int ter1, int ter2)
          Subtracts two numbers using the xor function for intergers.
static void testIt()
          Tests the functionality of the whole class.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

elements

public static final int elements
number of elements in this field

mulTab

private static final int[][] mulTab
look-up table for multiplication

divTab

private static final int[][] divTab
look-up table for multiplication
Constructor Detail

Field4

Field4()
Method Detail

isElement

public static boolean isElement(int elem)
Checks if a given integer is within the range of a Field4 element.
Returns:
is elem in the range of an Field4 element

isElement

public static boolean isElement(int[] elems)
Checks if a given vector consists only of Field4 elements.
Returns:
true iff all elements of the vector are Field4 elements.

isElement

public static boolean isElement(int[][] elems)
Checks if a given matrix consists only of Field4 elements.
Returns:
true iff all elements of the matrix are Field4 elements.

add

public static final int add(int ter1,
                            int ter2)
Adds two numbers using the xor function for intergers. Note: This works for any extionsion field over p=2.
Parameters:
ter1 - element of F_4
ter2 - element of F_4
Returns:
(ter1 + ter2) over F_4

sub

public static final int sub(int ter1,
                            int ter2)
Subtracts two numbers using the xor function for intergers. Note: This works for any extionsion field over p=2
Parameters:
ter1 - element of F_4
ter2 - element of F_4
Returns:
(ter1 - ter2) over F_4

mul

public static final int mul(int fac1,
                            int fac2)
Multiplies two numbers using finite field arithmetic in F_4. For the sake of speed I store the results in an lookup table.
Parameters:
fac1 - element of F_4
fac2 - element of F_4
Returns:
(fac1 * fac2) over F_4

div

public static final int div(int whom,
                            int by)
Divides two numbers using finite field arithmetic in F_4. For the sake of speed I store the results in an lookup table
Parameters:
whom - which number should be divised
by - which number divides
Returns:
(whom/by) over F_4

rnd

public static final int rnd(java.util.Random rnd)
returns a random element from Field4.

testIt

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

main

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