Interface UInt256


public interface UInt256
Utility methods for handling UInt256 (32-byte unsigned) values.

Note that SecpFieldElement values are a subset of UInt256 because they cannot exceed P-1.

  • Field Details

    • MIN_VALUE

      static final BigInteger MIN_VALUE
    • MAX_VALUE

      static final BigInteger MAX_VALUE
      The maximum unsigned 32-byte / 256-bit value. (2^256 - 1)
    • ZERO_VALUE

      static final byte[] ZERO_VALUE
  • Method Details

    • integerTo32Bytes

      static byte[] integerTo32Bytes(BigInteger i)
      Convert a BigInteger to a 32-byte fixed-length byte array (UInt256).
      Parameters:
      i - an unsigned BigInteger in the range MIN_VALUE to MAX_VALUE
      Returns:
      a 32-byte, big-endian unsigned integer value
    • isInRange

      static boolean isInRange(BigInteger e)
      Check if an integer is in the inclusive range MIN_VALUE to MAX_VALUE
      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 MIN_VALUE to MAX_VALUE.
      Parameters:
      e - unvalidated integer
      Returns:
      a validated integer