GF2nPolynomialElement, GF2nField
| Modifier and Type | Field and Description |
|---|---|
| private static final int[] | |
| private int | |
| private int | |
| private static final boolean[] | |
| private static Random | |
| private static final int[] | |
| private static final short[] | |
| private int[] |
| Access | Constructor and Description |
|---|---|
| public | GF2Polynomial(int
the desired number of bits to store length)Creates a new GF2Polynomial of the given length and value zero. |
| public | GF2Polynomial(int
the desired number of bits to store length, Random SecureRandom to use for randomization rand)Creates a new GF2Polynomial of the given length and random value. |
| public | GF2Polynomial(int
the desired number of bits to store length, String the value described by a String value)Creates a new GF2Polynomial of the given length and value selected by value:
|
| public | GF2Polynomial(int
the desired number of bits to store length, int[] contains the desired value, LSB in bs[0] bs)Creates a new GF2Polynomial of the given length using the given int[]. |
| public | GF2Polynomial(int
the intended length of this polynomial length, byte[] the octet string to assign to this polynomial os)Creates a new GF2Polynomial by converting the given byte[] os according to 1363 and using the given length. |
| public | GF2Polynomial(int
the intended length of this polynomial length, BigInteger the FlexiBigInt to assign to this polynomial bi)Creates a new GF2Polynomial by converting the given FlexiBigInt bi according to 1363 and using the given length. |
| public | GF2Polynomial(GF2Polynomial
the GF2Polynomial to clone b)Creates a new GF2Polynomial by cloneing the given GF2Polynomial b. |
| Modifier and Type | Method and Description |
|---|---|
| public GF2Polynomial | Returns: a new GF2Polynomial (this + b)a GF2Polynomial b)Adds two GF2Polynomials, this and b, and returns the result. |
| public void | addToThis(GF2Polynomial
GF2Polynomial to add to this GF2Polynomial b)Adds b to this GF2Polynomial and assigns the result to this GF2Polynomial. |
| public void | |
| public void | |
| public void | |
| public void | |
| public Object | Returns: a copy of this GF2PolynomialOverrides java. |
| public GF2Polynomial[] | Returns: a new GF2Polynomial[2] containing quotient and remainderGF2Polynomial != 0 g)Divides this by g and returns the quotient and remainder in a new GF2Polynomial[2], quotient in [0], remainder in [1]. |
| private void | doShiftBlocksLeft(int
shift amount (in blocks) b)Shifts left this GF2Polynomial's value blockwise b blocks resulting in a shift-left by b*32. |
| public boolean | Returns: true if this GF2Polynomial equals b (this == b)the other GF2Polynomial other)Overrides java. |
| public void | |
| public GF2Polynomial | Returns: a new GF2Polynomial gcd(this,g)GF2Polynomial != 0 g)Returns the greatest common divisor of this and g in a new GF2Polynomial. |
| public int | Returns: the bit at position i if i is a valid position, 0 otherwise.int i)Returns the bit at position i. |
| public int | |
| public int | Returns: the hash code of this polynomialOverrides java. |
| public GF2Polynomial | Returns: this + 1Toggles the LSB of this GF2Polynomial, increasing the value by 'one' and returns the result in a new GF2Polynomial. |
| public void | |
| public boolean | Returns: true if this is irreducibleChecks if this is irreducible, according to IEEE P1363, A.5.5, p103. |
| public boolean | Returns: true if this GF2Polynomial equals 'one' (this == 1)Tests if all bits are reset to 0 and LSB is set to 1. |
| public boolean | |
| private GF2Polynomial | |
| private GF2Polynomial | Returns: a new GF2Polynomial containing the lower k bytes of this GF2PolynomialReturns a new GF2Polynomial containing the lower k bytes of this GF2Polynomial. |
| private static int[] | |
| private static int[] | |
| private static int[] | |
| private static int[] | |
| private static int[] | |
| public GF2Polynomial | Returns: a new GF2Polynomial (this * b)a GF2Polynomial b)Multiplies this GF2Polynomial with b and returns the result in a new GF2Polynomial. |
| public GF2Polynomial | Returns: a new GF2Polynomial (this * b)a GF2Polynomial b)Multiplies this GF2Polynomial with b and returns the result in a new GF2Polynomial. |
| public GF2Polynomial | Returns: a new GF2Polynomial |_ this / g _|GF2Polynomial != 0 g)Returns the absolute quotient of this divided by g in a new GF2Polynomial. |
| public void | |
| public void | |
| public void | |
| pack-priv void | reducePentanomial(int
the degree of the used field m, int[] degrees of the middle x's in the pentanomial pc)Reduces this GF2Polynomial using the pentanomial x^m + x^pc[2] + x^pc[1] + x^pc[0] + 1. |
| pack-priv void | reduceTrinomial(int
the degree of the used field m, int degree of the middle x in the trinomial tc)Reduces this GF2Polynomial using the trinomial x^m + x^tc + 1. |
| public GF2Polynomial | Returns: a new GF2Polynomial (this % g)GF2Polynomial != 0 g)Returns the remainder of this divided by g in a new GF2Polynomial. |
| public void | |
| public void | |
| pack-priv void | shiftBlocksLeft()
Shifts-left this GF2Polynomial's value blockwise 1 block resulting in a shift-left by 32. |
| public GF2Polynomial | Returns: a new GF2Polynomial (this << 1)Returns this GF2Polynomial shift-left by 1 in a new GF2Polynomial. |
| public GF2Polynomial | Returns: a new GF2Polynomial (this << k)int k)Returns this GF2Polynomial shift-left by k in a new GF2Polynomial. |
| public void | shiftLeftAddThis(GF2Polynomial
GF2Polynomial to shift and add to this b, int the amount to shift k)Shifts left b and adds the result to Its a fast version of this = add(b.shl(k)); |
| public void | |
| public GF2Polynomial | Returns: a new GF2Polynomial (this << 1)Returns this GF2Polynomial shift-right by 1 in a new GF2Polynomial. |
| public void | |
| public void | |
| public void | |
| public GF2Polynomial | Returns: a new GF2Polynomial (this - b)a GF2Polynomial b)Subtracts two GF2Polynomials, this and b, and returns the result in a new GF2Polynomial. |
| public void | subtractFromThis(GF2Polynomial
a GF2Polynomial b)Subtracts b from this GF2Polynomial and assigns the result to this GF2Polynomial. |
| public boolean | Returns: true if the bit at position i is set (a(i) == 1). False if (i < 0) || (i > (len - 1))the position of the bit to be tested i)Tests the bit at position i. |
| public byte[] | Returns: a byte[] representing the value of this polynomialConverts this polynomial to a byte[] (octet string) according to 1363. |
| public BigInteger | Returns: a FlexiBigInt representing the value of this polynomialConverts this polynomial to an integer according to 1363. |
| public int[] | Returns: the value of this GF2Polynomial in a new int[], LSB in int[0]Returns the value of this GF2Polynomial in an int[]. |
| public String | Returns: a String representing this GF2Polynomials value.the radix to use (2 or 16, otherwise 2 is used) radix)Returns a string representing this GF2Polynomials value using hexadecimal or binary radix in MSB-first order. |
| private GF2Polynomial | Returns: a new GF2Polynomial containing the upper k bytes of this GF2PolynomialReturns a new GF2Polynomial containing the upper k bytes of this GF2Polynomial. |
| public boolean | Returns: this x b as boolean (1->true, 0->false)GF2Polynomial b)Does a vector-multiplication modulo 2 and returns the result as boolean. |
| public GF2Polynomial | Returns: a new GF2Polynomial (this ^ b)GF2Polynomial b)Returns the bitwise exclusive-or of this and b in a new GF2Polynomial. |
| public void | |
| public void | xorThisBy(GF2Polynomial
GF2Polynomial b)Computes the bitwise exclusive-or of this GF2Polynomial and b and stores the result in this GF2Polynomial. |
| private void | zeroUnusedBits()
If |
| bitMask | back to summary |
|---|---|
| private static final int[] bitMask | |
| blocks | back to summary |
|---|---|
| private int blocks | |
| len | back to summary |
|---|---|
| private int len | |
| parity | back to summary |
|---|---|
| private static final boolean[] parity | |
| rand | back to summary |
|---|---|
| private static Random rand | |
| reverseRightMask | back to summary |
|---|---|
| private static final int[] reverseRightMask | |
| squaringTable | back to summary |
|---|---|
| private static final short[] squaringTable | |
| value | back to summary |
|---|---|
| private int[] value | |
| GF2Polynomial | back to summary |
|---|---|
| public GF2Polynomial(int length) Creates a new GF2Polynomial of the given length and value zero.
| |
| GF2Polynomial | back to summary |
|---|---|
| public GF2Polynomial(int length, Random rand) Creates a new GF2Polynomial of the given length and random value.
| |
| GF2Polynomial | back to summary |
|---|---|
| public GF2Polynomial(int length, String value) Creates a new GF2Polynomial of the given length and value selected by value:
| |
| GF2Polynomial | back to summary |
|---|---|
| public GF2Polynomial(int length, int[] bs) Creates a new GF2Polynomial of the given length using the given int[]. LSB is contained in bs[0].
| |
| GF2Polynomial | back to summary |
|---|---|
| public GF2Polynomial(int length, byte[] os) Creates a new GF2Polynomial by converting the given byte[] os according to 1363 and using the given length.
| |
| GF2Polynomial | back to summary |
|---|---|
| public GF2Polynomial(int length, BigInteger bi) Creates a new GF2Polynomial by converting the given FlexiBigInt bi according to 1363 and using the given length.
| |
| GF2Polynomial | back to summary |
|---|---|
| public GF2Polynomial(GF2Polynomial b) Creates a new GF2Polynomial by cloneing the given GF2Polynomial b.
| |
| add | back to summary |
|---|---|
| public GF2Polynomial add(GF2Polynomial b) Adds two GF2Polynomials, this and b, and returns the result. this and b can be of different size.
| |
| addToThis | back to summary |
|---|---|
| public void addToThis(GF2Polynomial b) Adds b to this GF2Polynomial and assigns the result to this GF2Polynomial. b can be of different size.
| |
| assignAll | back to summary |
|---|---|
| public void assignAll() Sets all Bits to 1. | |
| assignOne | back to summary |
|---|---|
| public void assignOne() Sets the LSB to 1 and all other to 0, assigning 'one' to this GF2Polynomial. | |
| assignX | back to summary |
|---|---|
| public void assignX() Sets Bit 1 to 1 and all other to 0, assigning 'x' to this GF2Polynomial. | |
| assignZero | back to summary |
|---|---|
| public void assignZero() Resets all bits to zero. | |
| clone | back to summary |
|---|---|
| public Object clone() Overrides java. Doc from java. Creates and returns a copy of this object. The precise meaning
of "copy" may depend on the class of the object. The general
intent is that, for any object will be true, and that the expression:x.clone() != x will bex.clone().getClass() == x.getClass() true, but these are not absolute requirements.
While it is typically the case that:
will bex.clone().equals(x) true, this is not an absolute requirement.
By convention, the returned object should be obtained by calling
By convention, the object returned by this method should be independent
of this object (which is being cloned). To achieve this independence,
it may be necessary to modify one or more fields of the object returned
by
| |
| divide | back to summary |
|---|---|
| public GF2Polynomial[] divide(GF2Polynomial g) throws RuntimeException Divides this by g and returns the quotient and remainder in a new GF2Polynomial[2], quotient in [0], remainder in [1].
| |
| doShiftBlocksLeft | back to summary |
|---|---|
| private void doShiftBlocksLeft(int b) Shifts left this GF2Polynomial's value blockwise b blocks
resulting in a shift-left by b*32. This method assumes that
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object other) Overrides java. Returns true if two GF2Polynomials have the same size and value and thus are equal.
| |
| expandN | back to summary |
|---|---|
| public void expandN(int i) Expands len and int[] value to i. This is useful before adding two GF2Polynomials of different size.
| |
| gcd | back to summary |
|---|---|
| public GF2Polynomial gcd(GF2Polynomial g) throws RuntimeException Returns the greatest common divisor of this and g in a new GF2Polynomial.
| |
| getBit | back to summary |
|---|---|
| public int getBit(int i) Returns the bit at position i.
| |
| getLength | back to summary |
|---|---|
| public int getLength() Returns the length of this GF2Polynomial. The length can be greater than the degree. To get the degree call reduceN() before calling getLength().
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for the object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| increase | back to summary |
|---|---|
| public GF2Polynomial increase() Toggles the LSB of this GF2Polynomial, increasing the value by 'one' and returns the result in a new GF2Polynomial.
| |
| increaseThis | back to summary |
|---|---|
| public void increaseThis() Toggles the LSB of this GF2Polynomial, increasing its value by 'one'. | |
| isIrreducible | back to summary |
|---|---|
| public boolean isIrreducible() Checks if this is irreducible, according to IEEE P1363, A.5.5,
p103. Note The algorithm from IEEE P1363, A5.5 can be used to check a polynomial with coefficients in GF(2^r) for irreducibility. As this class only represents polynomials with coefficients in GF(2), the algorithm is adapted to the case r=1.
| |
| isOne | back to summary |
|---|---|
| public boolean isOne() Tests if all bits are reset to 0 and LSB is set to 1.
| |
| isZero | back to summary |
|---|---|
| public boolean isZero() Tests if all bits equal zero.
| |
| karaMult | back to summary |
|---|---|
| private GF2Polynomial karaMult(GF2Polynomial b) Does the recursion for Karatzuba multiplication. | |
| lower | back to summary |
|---|---|
| private GF2Polynomial lower(int k) Returns a new GF2Polynomial containing the lower k bytes of this GF2Polynomial.
| |
| mult128 | back to summary |
|---|---|
| private static int[] mult128(int[] a, int[] b) 4-Integer Version of Karatzuba multiplication. | |
| mult256 | back to summary |
|---|---|
| private static int[] mult256(int[] a, int[] b) 8-Integer Version of Karatzuba multiplication. | |
| mult32 | back to summary |
|---|---|
| private static int[] mult32(int a, int b) 4-Byte Version of Karatzuba multiplication. Here the actual work is done. | |
| mult512 | back to summary |
|---|---|
| private static int[] mult512(int[] a, int[] b) 16-Integer Version of Karatzuba multiplication. | |
| mult64 | back to summary |
|---|---|
| private static int[] mult64(int[] a, int[] b) 2-Integer Version of Karatzuba multiplication. | |
| multiply | back to summary |
|---|---|
| public GF2Polynomial multiply(GF2Polynomial b) Multiplies this GF2Polynomial with b and returns the result in a new GF2Polynomial. This method does not reduce the result in GF(2^N). This method uses Karatzuba multiplication.
| |
| multiplyClassic | back to summary |
|---|---|
| public GF2Polynomial multiplyClassic(GF2Polynomial b) Multiplies this GF2Polynomial with b and returns the result in a new GF2Polynomial. This method does not reduce the result in GF(2^N). This method uses classic multiplication (schoolbook).
| |
| quotient | back to summary |
|---|---|
| public GF2Polynomial quotient(GF2Polynomial g) throws RuntimeException Returns the absolute quotient of this divided by g in a new GF2Polynomial.
| |
| randomize | back to summary |
|---|---|
| public void randomize() Fills all len bits of this GF2Polynomial with random values. | |
| randomize | back to summary |
|---|---|
| public void randomize(Random rand) Fills all len bits of this GF2Polynomial with random values using the specified source of randomness.
| |
| reduceN | back to summary |
|---|---|
| public void reduceN() Reduces len by finding the most significant bit set to one and reducing len and blocks. | |
| reducePentanomial | back to summary |
|---|---|
| pack-priv void reducePentanomial(int m, int[] pc) Reduces this GF2Polynomial using the pentanomial x^m + x^pc[2] + x^pc[1] + x^pc[0] + 1.
| |
| reduceTrinomial | back to summary |
|---|---|
| pack-priv void reduceTrinomial(int m, int tc) Reduces this GF2Polynomial using the trinomial x^m + x^tc + 1.
| |
| remainder | back to summary |
|---|---|
| public GF2Polynomial remainder(GF2Polynomial g) throws RuntimeException Returns the remainder of this divided by g in a new GF2Polynomial.
| |
| resetBit | back to summary |
|---|---|
| public void resetBit(int i) throws RuntimeException Resets the bit at position i.
| |
| setBit | back to summary |
|---|---|
| public void setBit(int i) throws RuntimeException Sets the bit at position i.
| |
| shiftBlocksLeft | back to summary |
|---|---|
| pack-priv void shiftBlocksLeft() Shifts-left this GF2Polynomial's value blockwise 1 block resulting in a shift-left by 32.
| |
| shiftLeft | back to summary |
|---|---|
| public GF2Polynomial shiftLeft() Returns this GF2Polynomial shift-left by 1 in a new GF2Polynomial.
| |
| shiftLeft | back to summary |
|---|---|
| public GF2Polynomial shiftLeft(int k) Returns this GF2Polynomial shift-left by k in a new GF2Polynomial.
| |
| shiftLeftAddThis | back to summary |
|---|---|
| public void shiftLeftAddThis(GF2Polynomial b, int k) Shifts left b and adds the result to Its a fast version of this = add(b.shl(k));
| |
| shiftLeftThis | back to summary |
|---|---|
| public void shiftLeftThis() Shifts-left this by one and enlarges the size of value if necesary. | |
| shiftRight | back to summary |
|---|---|
| public GF2Polynomial shiftRight() Returns this GF2Polynomial shift-right by 1 in a new GF2Polynomial.
| |
| shiftRightThis | back to summary |
|---|---|
| public void shiftRightThis() Shifts-right this GF2Polynomial by 1. | |
| squareThisBitwise | back to summary |
|---|---|
| public void squareThisBitwise() Squares this GF2Polynomial and expands it accordingly. This method does not reduce the result in GF(2^N). There exists a faster method for squaring in GF(2^N).
| |
| squareThisPreCalc | back to summary |
|---|---|
| public void squareThisPreCalc() Squares this GF2Polynomial by using precomputed values of squaringTable. This method does not reduce the result in GF(2^N). | |
| subtract | back to summary |
|---|---|
| public GF2Polynomial subtract(GF2Polynomial b) Subtracts two GF2Polynomials, this and b, and returns the result in a new GF2Polynomial. this and b can be of different size.
| |
| subtractFromThis | back to summary |
|---|---|
| public void subtractFromThis(GF2Polynomial b) Subtracts b from this GF2Polynomial and assigns the result to this GF2Polynomial. b can be of different size.
| |
| testBit | back to summary |
|---|---|
| public boolean testBit(int i) Tests the bit at position i.
| |
| toByteArray | back to summary |
|---|---|
| public byte[] toByteArray() Converts this polynomial to a byte[] (octet string) according to 1363.
| |
| toFlexiBigInt | back to summary |
|---|---|
| public BigInteger toFlexiBigInt() Converts this polynomial to an integer according to 1363.
| |
| toIntegerArray | back to summary |
|---|---|
| public int[] toIntegerArray() Returns the value of this GF2Polynomial in an int[].
| |
| toString | back to summary |
|---|---|
| public String toString(int radix) Returns a string representing this GF2Polynomials value using hexadecimal or binary radix in MSB-first order.
| |
| upper | back to summary |
|---|---|
| private GF2Polynomial upper(int k) Returns a new GF2Polynomial containing the upper k bytes of this GF2Polynomial.
| |
| vectorMult | back to summary |
|---|---|
| public boolean vectorMult(GF2Polynomial b) throws RuntimeException Does a vector-multiplication modulo 2 and returns the result as boolean.
| |
| xor | back to summary |
|---|---|
| public GF2Polynomial xor(GF2Polynomial b) Returns the bitwise exclusive-or of this and b in a new GF2Polynomial. this and b can be of different size.
| |
| xorBit | back to summary |
|---|---|
| public void xorBit(int i) throws RuntimeException Xors the bit at position i.
| |
| xorThisBy | back to summary |
|---|---|
| public void xorThisBy(GF2Polynomial b) Computes the bitwise exclusive-or of this GF2Polynomial and b and stores the result in this GF2Polynomial. b can be of different size.
| |
| zeroUnusedBits | back to summary |
|---|---|
| private void zeroUnusedBits() If | |