public class GF2nPolynomialElement extends GF2nElement
GF2nPolynomialField
,
GF2nONBElement
,
GF2Polynomial
mDegree, mField
Constructor and Description |
---|
GF2nPolynomialElement(GF2nPolynomialElement other)
Creates a new GF2nPolynomialElement by cloning the given
GF2nPolynomialElement b.
|
GF2nPolynomialElement(GF2nPolynomialField f,
byte[] os)
Creates a new GF2nPolynomialElement using the given field f and
byte[] os as value.
|
GF2nPolynomialElement(GF2nPolynomialField f,
GF2Polynomial bs)
Creates a new GF2nPolynomialElement using the given field and Bitstring.
|
GF2nPolynomialElement(GF2nPolynomialField f,
int[] is)
Creates a new GF2nPolynomialElement using the given field f and
int[] is as value.
|
GF2nPolynomialElement(GF2nPolynomialField f,
java.util.Random rand)
Create a new random GF2nPolynomialElement using the given field and
source of randomness.
|
Modifier and Type | Method and Description |
---|---|
GFElement |
add(GFElement addend)
Compute the sum of this element and addend.
|
void |
addToThis(GFElement addend)
Compute this + addend (overwrite this).
|
java.lang.Object |
clone()
Creates a new GF2nPolynomialElement by cloning this
GF2nPolynomialElement.
|
boolean |
equals(java.lang.Object other)
Compare this element with another object.
|
int |
hashCode() |
GF2nElement |
increase()
Returns this element + 'one".
|
void |
increaseThis()
Increases this element by 'one'.
|
GFElement |
invert()
Compute the multiplicative inverse of this element.
|
GF2nPolynomialElement |
invertEEA()
Calculates the multiplicative inverse of this and returns the
result in a new GF2nPolynomialElement.
|
GF2nPolynomialElement |
invertMAIA()
Calculates the multiplicative inverse of this using the modified
almost inverse algorithm and returns the result in a new
GF2nPolynomialElement.
|
GF2nPolynomialElement |
invertSquare()
Calculates the multiplicative inverse of this and returns the
result in a new GF2nPolynomialElement.
|
boolean |
isOne()
Tests if the GF2nPolynomialElement has 'one' as value.
|
boolean |
isZero()
Checks whether this element is zero.
|
GFElement |
multiply(GFElement factor)
Compute the product of this element and factor.
|
void |
multiplyThisBy(GFElement factor)
Compute this * factor (overwrite this).
|
static GF2nPolynomialElement |
ONE(GF2nPolynomialField f)
Create the one element.
|
GF2nPolynomialElement |
power(int k)
Calculates this to the power of k and returns the result
in a new GF2nPolynomialElement.
|
GF2nElement |
solveQuadraticEquation()
Solves the quadratic equation z2 + z = this if
such a solution exists.
|
GF2nElement |
square()
This method is used internally to map the square()-calls within
GF2nPolynomialElement to one of the possible squaring methods.
|
GF2nPolynomialElement |
squareBitwise()
Squares this GF2nPolynomialElement by shifting left its Bitstring and
reducing.
|
GF2nPolynomialElement |
squareMatrix()
Squares this GF2nPolynomialElement using GF2nField's squaring matrix.
|
GF2nPolynomialElement |
squarePreCalc()
Squares this GF2nPolynomialElement by using precalculated values and
reducing.
|
GF2nElement |
squareRoot()
Compute the square root of this element and return the result in a new
GF2nPolynomialElement . |
void |
squareRootThis()
Compute the square root of this element.
|
void |
squareThis()
This method is used internally to map the square()-calls within
GF2nPolynomialElement to one of the possible squaring methods.
|
void |
squareThisBitwise()
Squares this GF2nPolynomialElement by shifting left its Bitstring and
reducing.
|
void |
squareThisMatrix()
Squares this GF2nPolynomialElement using GF2nFields squaring matrix.
|
void |
squareThisPreCalc()
Squares this GF2nPolynomialElement by using precalculated values and
reducing.
|
boolean |
testRightmostBit()
Returns whether the rightmost bit of the bit representation is set.
|
byte[] |
toByteArray()
Converts this GF2nPolynomialElement to a byte[] according to 1363.
|
java.math.BigInteger |
toFlexiBigInt()
Converts this GF2nPolynomialElement to an integer according to 1363.
|
java.lang.String |
toString()
Returns a string representing this Bitstrings value using hexadecimal
radix in MSB-first order.
|
java.lang.String |
toString(int radix)
Returns a string representing this Bitstrings value using hexadecimal or
binary radix in MSB-first order.
|
int |
trace()
Returns the trace of this GF2nPolynomialElement.
|
static GF2nPolynomialElement |
ZERO(GF2nPolynomialField f)
Create the zero element.
|
convert, getField, subtract, subtractFromThis
public GF2nPolynomialElement(GF2nPolynomialField f, java.util.Random rand)
f
- the GF2nField to userand
- the source of randomnesspublic GF2nPolynomialElement(GF2nPolynomialField f, GF2Polynomial bs)
f
- the GF2nPolynomialField to usebs
- the desired value as Bitstringpublic GF2nPolynomialElement(GF2nPolynomialField f, byte[] os)
f
- the GF2nField to useos
- the octet string to assign to this GF2nPolynomialElementpublic GF2nPolynomialElement(GF2nPolynomialField f, int[] is)
f
- the GF2nField to useis
- the integer string to assign to this GF2nPolynomialElementpublic GF2nPolynomialElement(GF2nPolynomialElement other)
other
- the GF2nPolynomialElement to clonepublic java.lang.Object clone()
clone
in interface GFElement
clone
in class GF2nElement
public static GF2nPolynomialElement ZERO(GF2nPolynomialField f)
f
- the finite fieldpublic static GF2nPolynomialElement ONE(GF2nPolynomialField f)
f
- the finite fieldpublic boolean isZero()
public boolean isOne()
public boolean equals(java.lang.Object other)
public int hashCode()
public boolean testRightmostBit()
testRightmostBit
in class GF2nElement
public GFElement add(GFElement addend) throws java.lang.RuntimeException
addend
- the addendjava.lang.RuntimeException
public void addToThis(GFElement addend) throws java.lang.RuntimeException
addend
- the addendjava.lang.RuntimeException
public GF2nElement increase()
increase
in class GF2nElement
public void increaseThis()
increaseThis
in class GF2nElement
public GFElement multiply(GFElement factor) throws java.lang.RuntimeException
factor
- the factorjava.lang.RuntimeException
public void multiplyThisBy(GFElement factor) throws java.lang.RuntimeException
factor
- the factorjava.lang.RuntimeException
public GFElement invert() throws java.lang.ArithmeticException
java.lang.ArithmeticException
- if this is the zero element.invertMAIA()
,
invertEEA()
,
invertSquare()
public GF2nPolynomialElement invertEEA() throws java.lang.ArithmeticException
java.lang.ArithmeticException
- if this equals zeropublic GF2nPolynomialElement invertSquare() throws java.lang.ArithmeticException
java.lang.ArithmeticException
- if this equals zeropublic GF2nPolynomialElement invertMAIA() throws java.lang.ArithmeticException
java.lang.ArithmeticException
- if this equals zeropublic GF2nElement square()
square
in class GF2nElement
squarePreCalc()
public void squareThis()
squareThis
in class GF2nElement
public GF2nPolynomialElement squareMatrix()
GF2Polynomial.vectorMult(org.bouncycastle.pqc.legacy.math.linearalgebra.GF2Polynomial)
,
squarePreCalc()
,
squareBitwise()
public void squareThisMatrix()
public GF2nPolynomialElement squareBitwise()
squareMatrix()
,
squarePreCalc()
,
GF2Polynomial.squareThisBitwise()
public void squareThisBitwise()
public GF2nPolynomialElement squarePreCalc()
squareMatrix()
,
GF2Polynomial.squareThisPreCalc()
public void squareThisPreCalc()
squareMatrix()
,
GF2Polynomial.squareThisPreCalc()
public GF2nPolynomialElement power(int k)
k
- the powerpublic GF2nElement squareRoot()
GF2nPolynomialElement
.squareRoot
in class GF2nElement
public void squareRootThis()
squareRootThis
in class GF2nElement
public GF2nElement solveQuadraticEquation() throws java.lang.RuntimeException
solveQuadraticEquation
in class GF2nElement
java.lang.RuntimeException
public int trace()
trace
in class GF2nElement
public java.lang.String toString()
public java.lang.String toString(int radix)
radix
- the radix to use (2 or 16, otherwise 2 is used)public byte[] toByteArray()
public java.math.BigInteger toFlexiBigInt()