Class GF2nONBElement
java.lang.Object
org.bouncycastle.pqc.legacy.math.linearalgebra.GF2nElement
org.bouncycastle.pqc.legacy.math.linearalgebra.GF2nONBElement
- All Implemented Interfaces:
GFElement
This class implements an element of the finite field GF(2n ).
It is represented in an optimal normal basis representation and holds the
pointer mField to its corresponding field.
- See Also:
-
Field Summary
Fields inherited from class org.bouncycastle.pqc.legacy.math.linearalgebra.GF2nElement
mDegree, mField -
Constructor Summary
ConstructorsConstructorDescriptionGF2nONBElement(GF2nONBElement gf2n) Copy constructor.GF2nONBElement(GF2nONBField gf2n, byte[] e) Construct a new GF2nONBElement from its encoding.GF2nONBElement(GF2nONBField gf2n, BigInteger val) Construct the element of the field gf2n with the specified value val.GF2nONBElement(GF2nONBField gf2n, SecureRandom rand) Construct a random element over the field gf2n, using the specified source of randomness. -
Method Summary
Modifier and TypeMethodDescriptionCompute the sum of this element and addend.voidCompute this + addend (overwrite this).clone()Create a new GF2nONBElement by cloning this GF2nPolynomialElement.booleanCompare this element with another object.inthashCode()increase()returns this element + 1.voidincreases this element.invert()Compute the multiplicative inverse of this element.voidMultiplicatively invert of this element (overwrite this).booleanisOne()Checks whether this element is one.booleanisZero()Checks whether this element is zero.Compute the product of this element and factor.voidmultiplyThisBy(GFElement factor) Compute this * factor (overwrite this).static GF2nONBElementONE(GF2nONBField gf2n) Create the one element.Solves a quadratic equation.
Let z2 + z = this.square()returns this element to the power of 2.returns the root ofthis element.voidsquare roots this element.voidsquares this element.booleanReturns whether the highest bit of the bit representation is setbyte[]Returns this element as byte array.Returns this element as FlexiBigInt.toString()Returns a String representation of this element.toString(int radix) Returns a String representation of this element.inttrace()Returns the trace of this element.static GF2nONBElementZERO(GF2nONBField gf2n) Create the zero element.Methods inherited from class org.bouncycastle.pqc.legacy.math.linearalgebra.GF2nElement
convert, getField, subtract, subtractFromThis
-
Constructor Details
-
GF2nONBElement
Construct a random element over the field gf2n, using the specified source of randomness.- Parameters:
gf2n- the fieldrand- the source of randomness
-
GF2nONBElement
Construct a new GF2nONBElement from its encoding.- Parameters:
gf2n- the fielde- the encoded element
-
GF2nONBElement
Construct the element of the field gf2n with the specified value val.- Parameters:
gf2n- the fieldval- the value represented by a BigInteger
-
GF2nONBElement
Copy constructor.- Parameters:
gf2n- the field
-
-
Method Details
-
clone
Create a new GF2nONBElement by cloning this GF2nPolynomialElement.- Specified by:
clonein interfaceGFElement- Specified by:
clonein classGF2nElement- Returns:
- a copy of this element
-
ZERO
Create the zero element.- Parameters:
gf2n- the finite field- Returns:
- the zero element in the given finite field
-
ONE
Create the one element.- Parameters:
gf2n- the finite field- Returns:
- the one element in the given finite field
-
isZero
public boolean isZero()Checks whether this element is zero.- Returns:
- true if this is the zero element
-
isOne
public boolean isOne()Checks whether this element is one.- Returns:
- true if this is the one element
-
equals
Compare this element with another object. -
hashCode
public int hashCode() -
testRightmostBit
public boolean testRightmostBit()Returns whether the highest bit of the bit representation is set- Specified by:
testRightmostBitin classGF2nElement- Returns:
- true, if the highest bit of mPol is set, false, otherwise
-
add
Compute the sum of this element and addend.- Parameters:
addend- the addend- Returns:
- this + other (newly created)
- Throws:
RuntimeException
-
addToThis
Compute this + addend (overwrite this).- Parameters:
addend- the addend- Throws:
RuntimeException
-
increase
returns this element + 1.- Specified by:
increasein classGF2nElement- Returns:
- this + 1
-
increaseThis
public void increaseThis()increases this element.- Specified by:
increaseThisin classGF2nElement
-
multiply
Compute the product of this element and factor.- Parameters:
factor- the factor- Returns:
- this * factor (newly created)
- Throws:
RuntimeException
-
multiplyThisBy
Compute this * factor (overwrite this).- Parameters:
factor- the factor- Throws:
RuntimeException
-
square
returns this element to the power of 2.- Specified by:
squarein classGF2nElement- Returns:
- this2
-
squareThis
public void squareThis()squares this element.- Specified by:
squareThisin classGF2nElement
-
invert
Compute the multiplicative inverse of this element.- Returns:
- this-1 (newly created)
- Throws:
ArithmeticException- if this is the zero element.
-
invertThis
Multiplicatively invert of this element (overwrite this).- Throws:
ArithmeticException- if this is the zero element.
-
squareRoot
returns the root ofthis element.- Specified by:
squareRootin classGF2nElement- Returns:
- this1/2
-
squareRootThis
public void squareRootThis()square roots this element.- Specified by:
squareRootThisin classGF2nElement
-
trace
public int trace()Returns the trace of this element.- Specified by:
tracein classGF2nElement- Returns:
- the trace of this element
-
solveQuadraticEquation
Solves a quadratic equation.
Let z2 + z = this. Then this method returns z.- Specified by:
solveQuadraticEquationin classGF2nElement- Returns:
- z with z2 + z = this
- Throws:
RuntimeException
-
toString
Returns a String representation of this element. -
toString
Returns a String representation of this element. radix specifies the radix of the String representation.
NOTE: ONLY radix = 2 or radix = 16 IS IMPLEMENTED- Parameters:
radix- specifies the radix of the String representation- Returns:
- String representation of this element with the specified radix
-
toFlexiBigInt
Returns this element as FlexiBigInt. The conversion is P1363-conform.- Returns:
- this element as BigInteger
-
toByteArray
public byte[] toByteArray()Returns this element as byte array. The conversion is P1363-conform.- Returns:
- this element as byte array
-