Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.
public static final class Secp256k1.EcdsaSignature
- Object
- Secp256k1.EcdsaSignature
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.Constructors
public EcdsaSignature(byte[] r, byte[] s, int recoveryId) | Creates a signature from its parts. |
Methods
public static Secp256k1.EcdsaSignature fromCompact(byte[] compact, int recoveryId) | Creates a signature from the 64-byte r || s encoding. |
public byte[] r() | The r component, 32 big-endian bytes. |
public byte[] s() | The s component, 32 big-endian bytes. |
public int recoveryId() | The recovery id, 0 to 3, or -1 when the signature was built without one. |
public byte[] toCompact() | The 64-byte r || s encoding. |
public boolean isLowS() | Tells whether s is in the lower half of the range, the form Secp256k1.sign produces and Secp256k1.verify accepts. |
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. |
Inherited methods
Constructor details
EcdsaSignature
public EcdsaSignature(byte[] r, byte[] s, int recoveryId)Creates a signature from its parts.
Parameters
rbyte[]- 32 bytes
sbyte[]- 32 bytes
recoveryIdint- 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
compactbyte[]- 64 bytes,
rthens recoveryIdint- 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 produces and Secp256k1.verify 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.