Class Secp256k1.EcdsaSignature

java.lang.Object
com.codename1.security.Secp256k1.EcdsaSignature
Enclosing class:
Secp256k1

public static final class Secp256k1.EcdsaSignature extends Object
An ECDSA signature: r and s as 32-byte big-endian integers, and the recovery id a signer knows and a verifier does not need.
  • Constructor Details

    • EcdsaSignature

      public EcdsaSignature(byte[] r, byte[] s, int recoveryId)

      Creates a signature from its parts.

      Parameters
      • r: 32 bytes

      • s: 32 bytes

      • recoveryId: 0 to 3, or -1 when it is not known

      Throws
      • CryptoException: if a part has the wrong length or the recovery id is out of range
  • Method Details

    • fromCompact

      public static Secp256k1.EcdsaSignature fromCompact(byte[] compact, int recoveryId)

      Creates a signature from the 64-byte r || s encoding.

      Parameters
      • compact: 64 bytes, r then s

      • recoveryId: 0 to 3, or -1 when it is not known

    • r

      public byte[] r()
      The r component, 32 big-endian bytes.
    • s

      public byte[] s()
      The s component, 32 big-endian bytes.
    • recoveryId

      public int recoveryId()
      The recovery id, 0 to 3, or -1 when the signature was built without one. Ethereum's v is this plus 27, or plus chainId * 2 + 35 under EIP-155.
    • toCompact

      public byte[] toCompact()
      The 64-byte r || s encoding.
    • isLowS

      public boolean isLowS()
      Tells whether s is in the lower half of the range, the form Secp256k1.sign(byte[], byte[]) produces and Secp256k1.verify(byte[], Secp256k1.EcdsaSignature, byte[]) accepts.
    • normalize

      public Secp256k1.EcdsaSignature normalize()
      Returns the signature with s lowered to the other half of the range when it is high, flipping the recovery id to match; a signature that is already low-S is returned as it is. Both forms are valid for the same key and hash, which is why networks accept only one of them.