net.i2p.crypto.eddsa.math.bigint

## Class BigIntegerLittleEndianEncoding

- java.lang.Object
- - net.i2p.crypto.eddsa.math.Encoding
  - - net.i2p.crypto.eddsa.math.bigint.BigIntegerLittleEndianEncoding

- All Implemented Interfaces:
    Serializable

      public class BigIntegerLittleEndianEncoding
      extends Encoding
      implements Serializable

  Little-endian encoding implementation for EdDSA field elements using BigInteger. This class provides encoding and decoding operations for EdDSA field elements, converting between BigInteger values and their little-endian byte representations. It handles the specific encoding requirements for EdDSA operations including bit masking and constant-time conversions.
  See Also:
    Serialized Form

- - ### Field Summary

    - ### Fields inherited from class net.i2p.crypto.eddsa.math.Encoding

      `f`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `BigIntegerLittleEndianEncoding()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `FieldElement` | `decode(byte[] in)` Decode a FieldElement from its $(b-1)$-bit encoding.
    `byte[]` | `encode(BigInteger x)` Convert $x$ to little endian.
    `byte[]` | `encode(FieldElement x)` Encode a FieldElement in its $(b-1)$-bit encoding.
    `boolean` | `isNegative(FieldElement x)` From the Ed25519 paper: $x$ is negative if the $(b-1)$-bit encoding of $x$ is lexicographically larger than the $(b-1)$-bit encoding of $-x$.
    `void` | `setField(Field f)`
    `BigInteger` | `toBigInteger(byte[] in)` Convert in to big endian

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

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### BigIntegerLittleEndianEncoding

          public BigIntegerLittleEndianEncoding()

  - ### Method Detail

    - #### decode

          public FieldElement decode(byte[] in)

      Decode a FieldElement from its $(b-1)$-bit encoding. The highest bit is masked out.
      Specified by:
        `decode` in class `Encoding`
      Parameters:
        `in` - the $(b-1)$-bit encoding of a FieldElement.
      Returns:
        the FieldElement represented by 'val'.
      Throws:
        `IllegalStateException` - if field not set
        `IllegalArgumentException` - if encoding is invalid

    - #### encode

          public byte[] encode(BigInteger x)

      Convert $x$ to little endian. Constant time.
      Parameters:
        `x` - the BigInteger value to encode
      Returns:
        array of length $b/8$
      Throws:
        `IllegalStateException` - if field not set

    - #### encode

          public byte[] encode(FieldElement x)

      Description copied from class: `Encoding`
      Encode a FieldElement in its $(b-1)$-bit encoding.
      Specified by:
        `encode` in class `Encoding`
      Parameters:
        `x` - the FieldElement to encode
      Returns:
        the $(b-1)$-bit encoding of this FieldElement.

    - #### isNegative

          public boolean isNegative(FieldElement x)

      From the Ed25519 paper:
      $x$ is negative if the $(b-1)$-bit encoding of $x$ is lexicographically larger than the $(b-1)$-bit encoding of $-x$. If $q$ is an odd prime and the encoding is the little-endian representation of $\{0, 1,\dots, q-1\}$ then the negative elements of $F_q$ are $\{1, 3, 5,\dots, q-2\}$.
      Specified by:
        `isNegative` in class `Encoding`
      Parameters:
        `x` - the FieldElement to check
      Returns:
        true if negative

    - #### setField

          public void setField(Field f)

      Overrides:
        `setField` in class `Encoding`

    - #### toBigInteger

          public BigInteger toBigInteger(byte[] in)

      Convert in to big endian
      Parameters:
        `in` - the $(b-1)$-bit encoding of a FieldElement.
      Returns:
        the decoded value as a BigInteger