Class Secp256k1.EcdsaSignature
java.lang.Object
com.codename1.security.Secp256k1.EcdsaSignature
- Enclosing class:
Secp256k1
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 Summary
ConstructorsConstructorDescriptionEcdsaSignature(byte[] r, byte[] s, int recoveryId) Creates a signature from its parts. -
Method Summary
Modifier and TypeMethodDescriptionstatic Secp256k1.EcdsaSignaturefromCompact(byte[] compact, int recoveryId) Creates a signature from the 64-byter || sencoding.booleanisLowS()Tells whethersis in the lower half of the range, the formSecp256k1.sign(byte[], byte[])produces andSecp256k1.verify(byte[], Secp256k1.EcdsaSignature, byte[])accepts.Returns the signature withslowered 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.byte[]r()Thercomponent, 32 big-endian bytes.intThe recovery id, 0 to 3, or -1 when the signature was built without one.byte[]s()Thescomponent, 32 big-endian bytes.byte[]The 64-byter || sencoding.
-
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
Creates a signature from the 64-byte
r || sencoding.Parameters
-
compact: 64 bytes,rthens -
recoveryId: 0 to 3, or -1 when it is not known
-
-
r
public byte[] r()Thercomponent, 32 big-endian bytes. -
s
public byte[] s()Thescomponent, 32 big-endian bytes. -
recoveryId
public int recoveryId()The recovery id, 0 to 3, or -1 when the signature was built without one. Ethereum'svis this plus 27, or pluschainId * 2 + 35under EIP-155. -
toCompact
public byte[] toCompact()The 64-byter || sencoding. -
isLowS
public boolean isLowS()Tells whethersis in the lower half of the range, the formSecp256k1.sign(byte[], byte[])produces andSecp256k1.verify(byte[], Secp256k1.EcdsaSignature, byte[])accepts. -
normalize
Returns the signature withslowered 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.
-