Package org.bouncycastle.pqc.math.linearalgebra

## Class GF2nONBElement

- java.lang.Object
- - org.bouncycastle.pqc.math.linearalgebra.GF2nElement
  - - org.bouncycastle.pqc.math.linearalgebra.GF2nONBElement

- All Implemented Interfaces:
    `GFElement`

      public class GF2nONBElement
      extends GF2nElement

  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

    - ### Fields inherited from class org.bouncycastle.pqc.math.linearalgebra.GF2nElement

      `mDegree, mField`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `GF2nONBElement​(GF2nONBElement gf2n)` | Copy constructor.
    `GF2nONBElement​(GF2nONBField gf2n, byte[] e)` | Construct a new GF2nONBElement from its encoding.
    `GF2nONBElement​(GF2nONBField gf2n, java.math.BigInteger val)` | Construct the element of the field `gf2n` with the specified value `val`.
    `GF2nONBElement​(GF2nONBField gf2n, java.security.SecureRandom rand)` | Construct a random element over the field `gf2n`, using the specified source of randomness.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | 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()` | Create a new GF2nONBElement by cloning this GF2nPolynomialElement.
    `boolean` | `equals​(java.lang.Object other)` | Compare this element with another object.
    `int` | `hashCode()` |
    `GF2nElement` | `increase()` | returns `this` element + 1.
    `void` | `increaseThis()` | increases `this` element.
    `GFElement` | `invert()` | Compute the multiplicative inverse of this element.
    `void` | `invertThis()` | Multiplicatively invert of this element (overwrite `this`).
    `boolean` | `isOne()` | Checks whether this element is one.
    `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 GF2nONBElement` | `ONE​(GF2nONBField gf2n)` | Create the one element.
    `GF2nElement` | `solveQuadraticEquation()` | Solves a quadratic equation. Let z2 + z = `this`.
    `GF2nElement` | `square()` | returns `this` element to the power of 2.
    `GF2nElement` | `squareRoot()` | returns the root of`this` element.
    `void` | `squareRootThis()` | square roots `this` element.
    `void` | `squareThis()` | squares `this` element.
    `boolean` | `testRightmostBit()` | Returns whether the highest bit of the bit representation is set
    `byte[]` | `toByteArray()` | Returns this element as byte array.
    `java.math.BigInteger` | `toFlexiBigInt()` | Returns this element as FlexiBigInt.
    `java.lang.String` | `toString()` | Returns a String representation of this element.
    `java.lang.String` | `toString​(int radix)` | Returns a String representation of this element.
    `int` | `trace()` | Returns the trace of this element.
    `static GF2nONBElement` | `ZERO​(GF2nONBField gf2n)` | Create the zero element.

    - ### Methods inherited from class org.bouncycastle.pqc.math.linearalgebra.GF2nElement

      `convert, getField, subtract, subtractFromThis`

    - ### Methods inherited from class java.lang.Object

      `finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### GF2nONBElement

          public GF2nONBElement​(GF2nONBField gf2n,
                                java.security.SecureRandom rand)

      Construct a random element over the field `gf2n`, using the specified source of randomness.
      Parameters:
        `gf2n` - the field
        `rand` - the source of randomness

    - #### GF2nONBElement

          public GF2nONBElement​(GF2nONBField gf2n,
                                byte[] e)

      Construct a new GF2nONBElement from its encoding.
      Parameters:
        `gf2n` - the field
        `e` - the encoded element

    - #### GF2nONBElement

          public GF2nONBElement​(GF2nONBField gf2n,
                                java.math.BigInteger val)

      Construct the element of the field `gf2n` with the specified value `val`.
      Parameters:
        `gf2n` - the field
        `val` - the value represented by a BigInteger

    - #### GF2nONBElement

          public GF2nONBElement​(GF2nONBElement gf2n)

      Copy constructor.
      Parameters:
        `gf2n` - the field

  - ### Method Detail

    - #### clone

          public java.lang.Object clone()

      Create a new GF2nONBElement by cloning this GF2nPolynomialElement.
      Specified by:
        `clone` in interface `GFElement`
      Specified by:
        `clone` in class `GF2nElement`
      Returns:
        a copy of this element

    - #### ZERO

          public static GF2nONBElement ZERO​(GF2nONBField gf2n)

      Create the zero element.
      Parameters:
        `gf2n` - the finite field
      Returns:
        the zero element in the given finite field

    - #### ONE

          public static GF2nONBElement ONE​(GF2nONBField gf2n)

      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

          public boolean equals​(java.lang.Object other)

      Compare this element with another object.
      Specified by:
        `equals` in interface `GFElement`
      Overrides:
        `equals` in class `java.lang.Object`
      Parameters:
        `other` - the other object
      Returns:
        `true` if the two objects are equal, `false` otherwise

    - #### hashCode

          public int hashCode()

      Specified by:
        `hashCode` in interface `GFElement`
      Overrides:
        `hashCode` in class `java.lang.Object`
      Returns:
        the hash code of this element

    - #### testRightmostBit

          public boolean testRightmostBit()

      Returns whether the highest bit of the bit representation is set
      Specified by:
        `testRightmostBit` in class `GF2nElement`
      Returns:
        true, if the highest bit of mPol is set, false, otherwise

    - #### add

          public GFElement add​(GFElement addend)
                        throws java.lang.RuntimeException

      Compute the sum of this element and `addend`.
      Parameters:
        `addend` - the addend
      Returns:
        `this + other` (newly created)
      Throws:
        `java.lang.RuntimeException`

    - #### addToThis

          public void addToThis​(GFElement addend)
                         throws java.lang.RuntimeException

      Compute `this + addend` (overwrite `this`).
      Parameters:
        `addend` - the addend
      Throws:
        `java.lang.RuntimeException`

    - #### increase

          public GF2nElement increase()

      returns `this` element + 1.
      Specified by:
        `increase` in class `GF2nElement`
      Returns:
        `this` + 1

    - #### increaseThis

          public void increaseThis()

      increases `this` element.
      Specified by:
        `increaseThis` in class `GF2nElement`

    - #### multiply

          public GFElement multiply​(GFElement factor)
                             throws java.lang.RuntimeException

      Compute the product of this element and `factor`.
      Parameters:
        `factor` - the factor
      Returns:
        `this * factor` (newly created)
      Throws:
        `java.lang.RuntimeException`

    - #### multiplyThisBy

          public void multiplyThisBy​(GFElement factor)
                              throws java.lang.RuntimeException

      Compute `this * factor` (overwrite `this`).
      Parameters:
        `factor` - the factor
      Throws:
        `java.lang.RuntimeException`

    - #### square

          public GF2nElement square()

      returns `this` element to the power of 2.
      Specified by:
        `square` in class `GF2nElement`
      Returns:
        `this`2

    - #### squareThis

          public void squareThis()

      squares `this` element.
      Specified by:
        `squareThis` in class `GF2nElement`

    - #### invert

          public GFElement invert()
                           throws java.lang.ArithmeticException

      Compute the multiplicative inverse of this element.
      Returns:
        `this-1` (newly created)
      Throws:
        `java.lang.ArithmeticException` - if `this` is the zero element.

    - #### invertThis

          public void invertThis()
                          throws java.lang.ArithmeticException

      Multiplicatively invert of this element (overwrite `this`).
      Throws:
        `java.lang.ArithmeticException` - if `this` is the zero element.

    - #### squareRoot

          public GF2nElement squareRoot()

      returns the root of`this` element.
      Specified by:
        `squareRoot` in class `GF2nElement`
      Returns:
        `this`1/2

    - #### squareRootThis

          public void squareRootThis()

      square roots `this` element.
      Specified by:
        `squareRootThis` in class `GF2nElement`

    - #### trace

          public int trace()

      Returns the trace of this element.
      Specified by:
        `trace` in class `GF2nElement`
      Returns:
        the trace of this element

    - #### solveQuadraticEquation

          public GF2nElement solveQuadraticEquation()
                                             throws java.lang.RuntimeException

      Solves a quadratic equation.
      Let z2 + z = `this`. Then this method returns z.
      Specified by:
        `solveQuadraticEquation` in class `GF2nElement`
      Returns:
        z with z2 + z = `this`
      Throws:
        `java.lang.RuntimeException`

    - #### toString

          public java.lang.String toString()

      Returns a String representation of this element.
      Specified by:
        `toString` in interface `GFElement`
      Overrides:
        `toString` in class `java.lang.Object`
      Returns:
        String representation of this element with the specified radix

    - #### toString

          public java.lang.String toString​(int radix)

      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

          public java.math.BigInteger 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