|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--HFE.Field2_n
This class encapsulates the operations for a finite field
with 2^n elements.
The generating polynomials are
Field Summary | |
static int |
degree
Degree of the underlying irreducible polynomial. |
(package private) static Field2_n |
div_A
static registers for division |
(package private) static Field2_n |
div_B
static registers for division |
(package private) static Field2_n |
div_tmp
static register for division |
(package private) static Field2_n |
div_V
static registers for division |
private static Field2_n |
mul_tmp
static register for multiplication |
private int[] |
number
Allocats memory for elements of this class |
static int |
reductionTerm
Stores the reduction term as bit vector. |
static int |
size
determinates the size of elements of this class. |
Constructor Summary | |
(package private) |
Field2_n()
Standart Constructor to obtain an element with all bits = 0 |
(package private) |
Field2_n(Field2_n father)
Constructor to produce a copy of another Field2_n element |
(package private) |
Field2_n(int init)
Constructor to obtain an element with least significant integer set and the rest being 0 |
(package private) |
Field2_n(java.util.Random rnd)
Constructor to obtain a random element |
Method Summary | |
void |
add(Field2_n ter)
this += ter Adds two numbers using the xor function for intergers. |
void |
add(Field2_n ter1,
Field2_n ter2)
this = ter1 + ter2 Adds two numbers using the xor function for intergers. |
private void |
addModul()
this += generating polynomial Adds the modul to this. |
void |
addOne()
this += 1 - adds one to this |
private boolean |
checkBit(int where)
Checks if the bit at position where is set. |
private void |
clearBit(int where)
Clears bit at position where. |
private int |
cntDegree()
find the degree of this - i.e. |
void |
copy(Field2_n father)
this = ter - copies father integerwise into this |
void |
div(Field2_n fac)
this /= fac - divides this by fac usind finite field arithmetic in GF(2^n) and stores the result in this. |
void |
div(Field2_n whom,
Field2_n by)
this = whom / by in GF(2^n) - divides two numbers using finite field arithmetic in GF(2^n). |
boolean |
even()
Checks if bit[0] is _not_ set, i.e. |
void |
getElement(int[] bitVec)
copies this to a bit vector |
private boolean |
isElement()
Checks if the current element is from Field2_n |
static boolean |
isElement(Field2_n elem)
Checks if a given integer is within the range of a GF(2^n) element. |
static boolean |
isElement(Field2_n[] elems)
Checks if a given vector consists only of Field2_n elements. |
static boolean |
isElement(Field2_n[][] elems)
Checks if a given matrix consists only of Field2_n elements. |
boolean |
isEqual(Field2_n who)
Checks if this and who are bitwise equal |
boolean |
isZero()
Checks if the element is the zero element |
static void |
main(java.lang.String[] args)
Tests everything in this class |
void |
mul(Field2_n fac)
this *= fac - multiplies two numbers using finite field arithmetic in GF(2^n) and stores the result in this. |
void |
mul(Field2_n fac1,
Field2_n fac2)
this = fac1 * fac2 - multiplies two numbers using finite field arithmetic in GF(2^n) and stores the result in this. |
void |
mulX()
this *= x assumes that there is no reduction necessary |
void |
rnd(java.util.Random rnd)
sets this to a random element from Field2_2. |
static int |
rndBit(java.util.Random rnd)
returns a random position within current Field2_n |
private void |
setBit(int where)
Sets bit at position where. |
void |
setElement(int[] bitVec)
sets field element regarding to a bit vector. |
void |
setOne()
sets this to 1 |
void |
setZero()
sets this to zero |
private void |
shiftL()
this <<= 1 - therefore computes a left shift of this by one bit. |
private void |
shiftLMod()
this <<= 1 % i(t) - therefore computes a left shift of this by one bit and reduces the result by the generating polynomials i(t). |
private void |
shiftR()
this >>= 1 - therefore computes a right shift of this by one bit. |
java.lang.String |
stringIt()
converts this to a string |
void |
sub(Field2_n ter)
this -= ter Adds two numbers using the xor function for intergers. |
void |
sub(Field2_n ter1,
Field2_n ter2)
this = ter1 - ter2 Subtracts two numbers using the xor function for intergers. |
static void |
testIt()
Tests the functionality of the whole class. |
private void |
xorBit(int where)
xors the bit at position where. |
Methods inherited from class java.lang.Object |
|
Field Detail |
public static final int degree
public static final int size
public static final int reductionTerm
private int[] number
private static Field2_n mul_tmp
static Field2_n div_A
static Field2_n div_B
static Field2_n div_V
static Field2_n div_tmp
Constructor Detail |
Field2_n()
Field2_n(Field2_n father)
Field2_n(int init)
Field2_n(java.util.Random rnd)
Method Detail |
public boolean even()
public boolean isZero()
private boolean checkBit(int where)
where
- position in this which should be checkedprivate void setBit(int where)
where
- position in this which should be setprivate void clearBit(int where)
where
- position in this which should be clearedprivate void xorBit(int where)
where
- position in this which should be xoredpublic final void copy(Field2_n father)
father
- element of Field2_nprivate void shiftL()
private void shiftLMod()
private void shiftR()
private boolean isElement()
public static boolean isElement(Field2_n elem)
public static boolean isElement(Field2_n[] elems)
public static boolean isElement(Field2_n[][] elems)
public boolean isEqual(Field2_n who)
public void setZero()
public void setOne()
public void addOne()
public void setElement(int[] bitVec)
bitVec
- elements from GF(2) for field elementspublic void getElement(int[] bitVec)
bitVec
- element in form of bit vectorprivate int cntDegree()
public final void add(Field2_n ter1, Field2_n ter2)
ter1
- element of Field2_nter2
- element of Field2_npublic final void add(Field2_n ter)
ter
- element of Field2_nprivate final void addModul()
public final void sub(Field2_n ter1, Field2_n ter2)
ter1
- element of Field2_nter2
- element of Field2_npublic final void sub(Field2_n ter)
ter
- element of Field2_npublic final void mul(Field2_n fac1, Field2_n fac2)
fac1
- element of GF(2^n)fac2
- element of GF(2^n)public final void mulX()
public final void mul(Field2_n fac)
fac
- element of GF(2^n)public final void div(Field2_n whom, Field2_n by)
whom
- which number should be divisedby
- which number dividespublic final void div(Field2_n fac)
fac
- element of GF(2^n)public final void rnd(java.util.Random rnd)
public static final int rndBit(java.util.Random rnd)
public java.lang.String stringIt()
public static final void testIt()
public static void main(java.lang.String[] args)
testIt()
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |