Class EthereumEncoding

java.lang.Object
com.hedera.hashgraph.sdk.EthereumEncoding

final class EthereumEncoding extends Object
Helpers for Ethereum RLP canonical integer encoding: big-endian, no leading zeros, zero is the empty byte string.
  • Method Details

    • uint64ToEthBytes

      static byte[] uint64ToEthBytes(long v)
      Encode v as canonical minimal big-endian bytes. Zero is encoded as an empty byte array.
      Parameters:
      v - the unsigned value to encode
      Returns:
      the canonical big-endian byte representation
    • ethBytesToLong

      static long ethBytesToLong(byte[] b)
      Decode canonical bytes to a long. An empty array decodes to 0. Input longer than 8 bytes is truncated to the low 8 bytes.
      Parameters:
      b - the canonical big-endian bytes
      Returns:
      the decoded value
    • bigIntToEthBytes

      static byte[] bigIntToEthBytes(BigInteger v)
      Encode v as canonical minimal big-endian bytes. Null and zero are encoded as an empty byte array. Negative values encode their absolute value.
      Parameters:
      v - the value to encode
      Returns:
      the canonical big-endian byte representation
    • ethBytesToBigInt

      static BigInteger ethBytesToBigInt(byte[] b)
      Decode canonical bytes to a BigInteger. An empty array decodes to 0.
      Parameters:
      b - the canonical big-endian bytes
      Returns:
      the decoded value