java.lang.Object
net.i2p.crypto.eddsa.math.Field
All Implemented Interfaces:
Serializable

public class Fieldextends Object implements Serializable
An EdDSA finite field. Includes several pre-computed values.
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      Pinned for serialized-form compatibility.
      See Also:
    • ZERO

      public final FieldElement ZERO
      The field's additive identity.
    • ONE

      public final FieldElement ONE
      The field's multiplicative identity.
    • TWO

      public final FieldElement TWO
      The field element two.
    • FOUR

      public final FieldElement FOUR
      The field element four.
    • FIVE

      public final FieldElement FIVE
      The field element five.
    • EIGHT

      public final FieldElement EIGHT
      The field element eight.
    • b

      private final int b
      The bit length of field elements.
    • q

      private final FieldElement q
      The field prime q.
    • qm2

      private final FieldElement qm2
      The value q - 2.
    • qm5d8

      private final FieldElement qm5d8
      (q-5) / 8.
    • enc

      private final Encoding enc
      The encoding for field elements.
  • Constructor Details

    • Field

      public Field(int b, byte[] q, Encoding enc)
      Create a finite field.
      Parameters:
      b - the bit length
      q - the field prime
      enc - the Encoding that converts field elements to and from bytes
  • Method Details

    • fromByteArray

      public final FieldElement fromByteArray(byte[] x)
      Create a field element from a byte array.
      Parameters:
      x - the byte array
      Returns:
      the field element
    • getb

      public int getb()
      Return the bit length.
      Returns:
      the bit length
    • getQ

      public FieldElement getQ()
      Return the field prime.
      Returns:
      the field prime
    • getQm2

      public FieldElement getQm2()
      Return q - 2.
      Returns:
      q - 2
    • getQm5d8

      public FieldElement getQm5d8()
      Return (q - 5) / 8.
      Returns:
      (q - 5) / 8
    • getEncoding

      public Encoding getEncoding()
      Return the encoding for field elements, which converts them to and from bytes.
      Returns:
      the Encoding that converts field elements to and from bytes
    • hashCode

      public int hashCode()
      Return the hash code.
      Overrides:
      hashCode in class Object
      Returns:
      the hash code
    • equals

      public boolean equals(Object obj)
      Compare for equality.
      Overrides:
      equals in class Object
      Parameters:
      obj - the object
      Returns:
      true if equal