Top Description Fields Constructors Methods
org.bouncycastle.pqc.legacy.math.linearalgebra

public Class GF2nONBElement

extends GF2nElement
Class Inheritance
Imports
java.math.BigInteger, java.security.SecureRandom, org.bouncycastle.util.Arrays

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
GF2nField, GF2nElement

Field Summary

Modifier and TypeField and Description
private static final int
private int
mBit

holds the value of mDeg % MAXLONG.

private static final long[]
private static final int[]
private int
mLength

holds the length of the polynomial with 64 bit sized fields.

private static final long[]
private long[]
mPol

holds this element in ONB representation.

Inherited from org.bouncycastle.pqc.legacy.math.linearalgebra.GF2nElement:
mDegreemField

Constructor Summary

AccessConstructor and Description
public
GF2nONBElement(GF2nONBField
the field
gf2n
,
SecureRandom
the source of randomness
rand
)

Construct a random element over the field gf2n, using the specified source of randomness.

public
GF2nONBElement(GF2nONBField
the field
gf2n
,
byte[]
the encoded element
e
)

Construct a new GF2nONBElement from its encoding.

public
GF2nONBElement(GF2nONBField
the field
gf2n
,
BigInteger
the value represented by a BigInteger
val
)

Construct the element of the field gf2n with the specified value val.

private
GF2nONBElement(GF2nONBField
the field
gf2n
,
long[]
the value in ONB representation
val
)

Construct the element of the field gf2n with the specified value val.

public
GF2nONBElement(GF2nONBElement
the field
gf2n
)

Copy constructor.

Method Summary

Modifier and TypeMethod and Description
public GFElement

Returns:

this + other (newly created)
add
(GFElement
the addend
addend
)

Implements org.bouncycastle.pqc.legacy.math.linearalgebra.GFElement.add.

Compute the sum of this element and addend.
public void
addToThis(GFElement
the addend
addend
)

Implements org.bouncycastle.pqc.legacy.math.linearalgebra.GFElement.addToThis.

Compute this + addend (overwrite this).
private void
assign(BigInteger
the value represented by a BigInteger
val
)

assigns to this element the value val.

private void
assign(long[]
the value in ONB representation
val
)

assigns to this element the value val.

private void
assign(byte[]
the value in ONB representation
val
)

assigns to this element the value val.

pack-priv void
assignOne()

Implements abstract org.bouncycastle.pqc.legacy.math.linearalgebra.GF2nElement.assignOne.

assigns to this element the one element
pack-priv void
assignZero()

Implements abstract org.bouncycastle.pqc.legacy.math.linearalgebra.GF2nElement.assignZero.

assigns to this element the zero element
public Object

Returns:

a copy of this element
clone
()

Implements abstract org.bouncycastle.pqc.legacy.math.linearalgebra.GF2nElement.clone.

Implements org.bouncycastle.pqc.legacy.math.linearalgebra.GFElement.clone.

Create a new GF2nONBElement by cloning this GF2nPolynomialElement.
public boolean

Returns:

true if the two objects are equal, false otherwise
equals
(Object
the other object
other
)

Overrides java.lang.Object.equals.

Implements org.bouncycastle.pqc.legacy.math.linearalgebra.GFElement.equals.

Compare this element with another object.
private long[]

Returns:

this element in its ONB representation
getElement
()

private long[]

Returns:

this element in its representation and reverse bit-order
getElementReverseOrder
()

Returns the ONB representation of this element.

public int

Returns:

the hash code of this element
hashCode
()

Overrides java.lang.Object.hashCode.

Implements org.bouncycastle.pqc.legacy.math.linearalgebra.GFElement.hashCode.

Returns a hash code value for the object.
public GF2nElement

Returns:

this + 1
increase
()

Implements abstract org.bouncycastle.pqc.legacy.math.linearalgebra.GF2nElement.increase.

returns this element + 1.
public void
public GFElement

Returns:

this-1 (newly created)
invert
()

Implements org.bouncycastle.pqc.legacy.math.linearalgebra.GFElement.invert.

Compute the multiplicative inverse of this element.
public void
invertThis()

Multiplicatively invert of this element (overwrite this).

public boolean

Returns:

true if this is the one element
isOne
()

Implements org.bouncycastle.pqc.legacy.math.linearalgebra.GFElement.isOne.

Checks whether this element is one.
public boolean

Returns:

true if this is the zero element
isZero
()

Implements org.bouncycastle.pqc.legacy.math.linearalgebra.GFElement.isZero.

Checks whether this element is zero.
public GFElement

Returns:

this * factor (newly created)
multiply
(GFElement
the factor
factor
)

Implements org.bouncycastle.pqc.legacy.math.linearalgebra.GFElement.multiply.

Compute the product of this element and factor.
public void
multiplyThisBy(GFElement
the factor
factor
)

Implements org.bouncycastle.pqc.legacy.math.linearalgebra.GFElement.multiplyThisBy.

Compute this * factor (overwrite this).
public static GF2nONBElement

Returns:

the one element in the given finite field
ONE
(GF2nONBField
the finite field
gf2n
)

Create the one element.

pack-priv void
reverseOrder()

Reverses the bit-order in this element(according to 1363).

public GF2nElement

Returns:

z with z2 + z = this
solveQuadraticEquation
()

Implements abstract org.bouncycastle.pqc.legacy.math.linearalgebra.GF2nElement.solveQuadraticEquation.

Solves a quadratic equation.
public GF2nElement

Returns:

this2
square
()

Implements abstract org.bouncycastle.pqc.legacy.math.linearalgebra.GF2nElement.square.

returns this element to the power of 2.
public GF2nElement

Returns:

this1/2
squareRoot
()

Implements abstract org.bouncycastle.pqc.legacy.math.linearalgebra.GF2nElement.squareRoot.

returns the root ofthis element.
public void
public void
pack-priv boolean

Returns:

true if the indexed bit of mPol is set, false otherwise.
testBit
(int
the index of the bit to test
index
)

Implements abstract org.bouncycastle.pqc.legacy.math.linearalgebra.GF2nElement.testBit.

Checks whether the indexed bit of the bit representation is set.
public boolean

Returns:

true, if the highest bit of mPol is set, false, otherwise
testRightmostBit
()

Implements abstract org.bouncycastle.pqc.legacy.math.linearalgebra.GF2nElement.testRightmostBit.

Returns whether the highest bit of the bit representation is set
public byte[]

Returns:

this element as byte array
toByteArray
()

Implements org.bouncycastle.pqc.legacy.math.linearalgebra.GFElement.toByteArray.

Returns this element as byte array.
public BigInteger

Returns:

this element as BigInteger
toFlexiBigInt
()

Implements org.bouncycastle.pqc.legacy.math.linearalgebra.GFElement.toFlexiBigInt.

Returns this element as FlexiBigInt.
public String

Returns:

String representation of this element with the specified radix
toString
()

Overrides java.lang.Object.toString.

Implements org.bouncycastle.pqc.legacy.math.linearalgebra.GFElement.toString.

Returns a String representation of this element.
public String

Returns:

String representation of this element with the specified radix
toString
(int
specifies the radix of the String representation
radix
)

Implements org.bouncycastle.pqc.legacy.math.linearalgebra.GFElement.toString.

Returns a String representation of this element.
public int

Returns:

the trace of this element
trace
()

Implements abstract org.bouncycastle.pqc.legacy.math.linearalgebra.GF2nElement.trace.

Returns the trace of this element.
public static GF2nONBElement

Returns:

the zero element in the given finite field
ZERO
(GF2nONBField
the finite field
gf2n
)

Create the zero element.

Inherited from org.bouncycastle.pqc.legacy.math.linearalgebra.GF2nElement:
convertgetFieldsubtractsubtractFromThis

Field Detail

MAXLONGback to summary
private static final int MAXLONG
mBitback to summary
private int mBit

holds the value of mDeg % MAXLONG.

mBitmaskback to summary
private static final long[] mBitmask
mIBY64back to summary
private static final int[] mIBY64
mLengthback to summary
private int mLength

holds the length of the polynomial with 64 bit sized fields.

mMaxmaskback to summary
private static final long[] mMaxmask
mPolback to summary
private long[] mPol

holds this element in ONB representation.

Constructor Detail

GF2nONBElementback to summary
public GF2nONBElement(GF2nONBField gf2n, SecureRandom rand)

Construct a random element over the field gf2n, using the specified source of randomness.

Parameters
gf2n:GF2nONBField

the field

rand:SecureRandom

the source of randomness

GF2nONBElementback to summary
public GF2nONBElement(GF2nONBField gf2n, byte[] e)

Construct a new GF2nONBElement from its encoding.

Parameters
gf2n:GF2nONBField

the field

e:byte[]

the encoded element

GF2nONBElementback to summary
public GF2nONBElement(GF2nONBField gf2n, BigInteger val)

Construct the element of the field gf2n with the specified value val.

Parameters
gf2n:GF2nONBField

the field

val:BigInteger

the value represented by a BigInteger

GF2nONBElementback to summary
private GF2nONBElement(GF2nONBField gf2n, long[] val)

Construct the element of the field gf2n with the specified value val.

Parameters
gf2n:GF2nONBField

the field

val:long[]

the value in ONB representation

GF2nONBElementback to summary
public GF2nONBElement(GF2nONBElement gf2n)

Copy constructor.

Parameters
gf2n:GF2nONBElement

the field

Method Detail

addback to summary
public GFElement add(GFElement addend) throws RuntimeException

Implements org.bouncycastle.pqc.legacy.math.linearalgebra.GFElement.add.

Compute the sum of this element and addend.

Parameters
addend:GFElement

the addend

Returns:GFElement

this + other (newly created)

addToThisback to summary
public void addToThis(GFElement addend) throws RuntimeException

Implements org.bouncycastle.pqc.legacy.math.linearalgebra.GFElement.addToThis.

Compute this + addend (overwrite this).

Parameters
addend:GFElement

the addend

assignback to summary
private void assign(BigInteger val)

assigns to this element the value val.

Parameters
val:BigInteger

the value represented by a BigInteger

assignback to summary
private void assign(long[] val)

assigns to this element the value val.

Parameters
val:long[]

the value in ONB representation

assignback to summary
private void assign(byte[] val)

assigns to this element the value val. First: inverting the order of val into reversed[]. That means: reversed[0] = val[length - 1], ..., reversed[reversed.length - 1] = val[0]. Second: mPol[0] = sum{i = 0, ... 7} (val[i]<<(i*8)) .... mPol[1] = sum{i = 8, ... 15} (val[i]<<(i*8))

Parameters
val:byte[]

the value in ONB representation

assignOneback to summary
pack-priv void assignOne()

Implements abstract org.bouncycastle.pqc.legacy.math.linearalgebra.GF2nElement.assignOne.

assigns to this element the one element

assignZeroback to summary
pack-priv void assignZero()

Implements abstract org.bouncycastle.pqc.legacy.math.linearalgebra.GF2nElement.assignZero.

assigns to this element the zero element

cloneback to summary
public Object clone()

Implements abstract org.bouncycastle.pqc.legacy.math.linearalgebra.GF2nElement.clone.

Implements org.bouncycastle.pqc.legacy.math.linearalgebra.GFElement.clone.

Create a new GF2nONBElement by cloning this GF2nPolynomialElement.

Returns:Object

a copy of this element

equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.equals.

Implements org.bouncycastle.pqc.legacy.math.linearalgebra.GFElement.equals.

Compare this element with another object.

Parameters
other:Object

the other object

Returns:boolean

true if the two objects are equal, false otherwise

getElementback to summary
private long[] getElement()
Returns:long[]

this element in its ONB representation

getElementReverseOrderback to summary
private long[] getElementReverseOrder()

Returns the ONB representation of this element. The Bit-Order is exchanged (according to 1363)!

Returns:long[]

this element in its representation and reverse bit-order

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Implements org.bouncycastle.pqc.legacy.math.linearalgebra.GFElement.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

the hash code of this element

increaseback to summary
public GF2nElement increase()

Implements abstract org.bouncycastle.pqc.legacy.math.linearalgebra.GF2nElement.increase.

returns this element + 1.

Returns:GF2nElement

this + 1

increaseThisback to summary
public void increaseThis()

Implements abstract org.bouncycastle.pqc.legacy.math.linearalgebra.GF2nElement.increaseThis.

increases this element.

invertback to summary
public GFElement invert() throws ArithmeticException

Implements org.bouncycastle.pqc.legacy.math.linearalgebra.GFElement.invert.

Compute the multiplicative inverse of this element.

Returns:GFElement

this-1 (newly created)

Exceptions
ArithmeticException:
if this is the zero element.
invertThisback to summary
public void invertThis() throws ArithmeticException

Multiplicatively invert of this element (overwrite this).

Exceptions
ArithmeticException:
if this is the zero element.
isOneback to summary
public boolean isOne()

Implements org.bouncycastle.pqc.legacy.math.linearalgebra.GFElement.isOne.

Checks whether this element is one.

Returns:boolean

true if this is the one element

isZeroback to summary
public boolean isZero()

Implements org.bouncycastle.pqc.legacy.math.linearalgebra.GFElement.isZero.

Checks whether this element is zero.

Returns:boolean

true if this is the zero element

multiplyback to summary
public GFElement multiply(GFElement factor) throws RuntimeException

Implements org.bouncycastle.pqc.legacy.math.linearalgebra.GFElement.multiply.

Compute the product of this element and factor.

Parameters
factor:GFElement

the factor

Returns:GFElement

this * factor (newly created)

multiplyThisByback to summary
public void multiplyThisBy(GFElement factor) throws RuntimeException

Implements org.bouncycastle.pqc.legacy.math.linearalgebra.GFElement.multiplyThisBy.

Compute this * factor (overwrite this).

Parameters
factor:GFElement

the factor

ONEback to summary
public static GF2nONBElement ONE(GF2nONBField gf2n)

Create the one element.

Parameters
gf2n:GF2nONBField

the finite field

Returns:GF2nONBElement

the one element in the given finite field

reverseOrderback to summary
pack-priv void reverseOrder()

Reverses the bit-order in this element(according to 1363). This is a hack!

solveQuadraticEquationback to summary
public GF2nElement solveQuadraticEquation() throws RuntimeException

Implements abstract org.bouncycastle.pqc.legacy.math.linearalgebra.GF2nElement.solveQuadraticEquation.

Solves a quadratic equation.
Let z2 + z = this. Then this method returns z.

Returns:GF2nElement

z with z2 + z = this

squareback to summary
public GF2nElement square()

Implements abstract org.bouncycastle.pqc.legacy.math.linearalgebra.GF2nElement.square.

returns this element to the power of 2.

Returns:GF2nElement

this2

squareRootback to summary
public GF2nElement squareRoot()

Implements abstract org.bouncycastle.pqc.legacy.math.linearalgebra.GF2nElement.squareRoot.

returns the root ofthis element.

Returns:GF2nElement

this1/2

squareRootThisback to summary
public void squareRootThis()

Implements abstract org.bouncycastle.pqc.legacy.math.linearalgebra.GF2nElement.squareRootThis.

square roots this element.

squareThisback to summary
public void squareThis()

Implements abstract org.bouncycastle.pqc.legacy.math.linearalgebra.GF2nElement.squareThis.

squares this element.

testBitback to summary
pack-priv boolean testBit(int index)

Implements abstract org.bouncycastle.pqc.legacy.math.linearalgebra.GF2nElement.testBit.

Checks whether the indexed bit of the bit representation is set.

Warning

GF2nONBElement currently stores its bits in reverse order (compared to 1363) !!!

Parameters
index:int

the index of the bit to test

Returns:boolean

true if the indexed bit of mPol is set, false otherwise.

testRightmostBitback to summary
public boolean testRightmostBit()

Implements abstract org.bouncycastle.pqc.legacy.math.linearalgebra.GF2nElement.testRightmostBit.

Returns whether the highest bit of the bit representation is set

Returns:boolean

true, if the highest bit of mPol is set, false, otherwise

toByteArrayback to summary
public byte[] toByteArray()

Implements org.bouncycastle.pqc.legacy.math.linearalgebra.GFElement.toByteArray.

Returns this element as byte array. The conversion is P1363-conform.

Returns:byte[]

this element as byte array

toFlexiBigIntback to summary
public BigInteger toFlexiBigInt()

Implements org.bouncycastle.pqc.legacy.math.linearalgebra.GFElement.toFlexiBigInt.

Returns this element as FlexiBigInt. The conversion is P1363-conform.

Returns:BigInteger

this element as BigInteger

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Implements org.bouncycastle.pqc.legacy.math.linearalgebra.GFElement.toString.

Returns a String representation of this element.

Returns:String

String representation of this element with the specified radix

toStringback to summary
public String toString(int radix)

Implements org.bouncycastle.pqc.legacy.math.linearalgebra.GFElement.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:int

specifies the radix of the String representation

Returns:String

String representation of this element with the specified radix

traceback to summary
public int trace()

Implements abstract org.bouncycastle.pqc.legacy.math.linearalgebra.GF2nElement.trace.

Returns the trace of this element.

Returns:int

the trace of this element

ZEROback to summary
public static GF2nONBElement ZERO(GF2nONBField gf2n)

Create the zero element.

Parameters
gf2n:GF2nONBField

the finite field

Returns:GF2nONBElement

the zero element in the given finite field