Interface SecpFieldElement

All Known Implementing Classes:
SecpFieldElementImpl

public interface SecpFieldElement
A number that is a valid element of the P256K1 field. We use this instead of BigInteger so we can use a fixed-length, unsigned representation for simplicity and performance.
  • Method Summary

    Modifier and Type
    Method
    Description
    static BigInteger
    Throw IllegalArgumentException if an integer is not in the inclusive range 0 to P - 1, where P is the prime of the SECP256K1 prime finite field.
    static boolean
    Check if an integer is in the inclusive range 0 to P - 1, where P is the prime of the SECG P256K1 prime finite field.
    boolean
    Get the parity of the field value
    of(byte[] bytes)
    Construct a field element from a big-endian byte-array of 32 bytes
    Construct a SecpFieldElement from a BigInteger
    byte[]
    Get serialized (big-endian) field element (32 bytes unsigned)
    Get the field element as a BigInteger
  • Method Details

    • toBigInteger

      BigInteger toBigInteger()
      Get the field element as a BigInteger
      Returns:
      field element value
    • serialize

      byte[] serialize()
      Get serialized (big-endian) field element (32 bytes unsigned)
      Returns:
      serialized field element
    • isOdd

      boolean isOdd()
      Get the parity of the field value
      Returns:
      true if odd, false if even
    • of

      Construct a SecpFieldElement from a BigInteger
      Parameters:
      i - integer
      Returns:
      valid element
    • of

      static SecpFieldElement of(byte[] bytes)
      Construct a field element from a big-endian byte-array of 32 bytes
      Parameters:
      bytes - array containing a valid field element
      Returns:
      field element
    • isInRange

      static boolean isInRange(BigInteger e)
      Check if an integer is in the inclusive range 0 to P - 1, where P is the prime of the SECG P256K1 prime finite field.
      Parameters:
      e - A possible field element to validate
      Returns:
      true if valid
    • checkInRange

      static BigInteger checkInRange(BigInteger e)
      Throw IllegalArgumentException if an integer is not in the inclusive range 0 to P - 1, where P is the prime of the SECP256K1 prime finite field.
      Parameters:
      e - unvalidated integer
      Returns:
      a validated integer