EcdaSignature class

Provide EcdaSignature sign and verify.

Constructors

EcdaSignature(Uint8List r, Uint8List s, int v)
EcdaSignature.fromRpcSig(String sig)
factory
EcdaSignature.sign(String message, Uint8List privateKey)
factory
EcdaSignature.signForEth(Uint8List message, Uint8List privateKey, {int chainId = -1})
factory

Properties

hashCode int
The hash code for this object.
no setterinherited
r Uint8List
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
s Uint8List
final
v int
final

Methods

getSignature() String
getSignatureWithRecId() String
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toRpcSig({int chainId = -1}) String
Convert signature parameters into the format of eth_sign RPC method.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

calculateEthSigRecovery(int v, {int chainId = -1}) int
decompressPublicKey(Uint8List publicKey) Uint8List
derToRaw(Uint8List der) Uint8List
Decode a DER-encoded ECDSA signature (optionally followed by one sighash byte) into fixed-width raw r||s (64 bytes total). r/s are decoded as plain big-endian integers rather than copied byte-for-byte, so a DER integer that is legitimately shorter than 32 bytes (or carries a sign-disambiguation 0x00 byte) is still re-encoded to the correct fixed width instead of shifting the s offset. Throws FormatException on structurally invalid DER.
getRecid(String pubHex, String message, ECSignature sig) int
getUnCompressedPublicKey(Uint8List privateKey) Uint8List
isValidEthSignature(BigInt r, BigInt s, int v, {bool homesteadOrLater = true, int chainId = -1, bool vIsBareRecoveryId = false}) bool
vIsBareRecoveryId: EIP-1559/EIP-7702 typed transactions store the bare y-parity (0/1) in v, not the legacy EIP-155-encoded value (recId + chainId*2 + 35). Passing the typed-tx v through the EIP-155 formula yields a bogus recovery id and rejects every valid signature; callers must set this for typed transactions.
isValidEthSigRecovery(int recoveryId) bool
privateAdd(Uint8List d, Uint8List tweak) Uint8List
privateKeyToPublicKey(Uint8List privateKey, {bool compress = true}) Uint8List
recoverPublicKey(BigInt r, BigInt s, int recoveryId, Uint8List messageHash) Uint8List?
Recover the 64-byte uncompressed public key (X‖Y, no 0x04 prefix) that produced r/s over messageHash for the given recoveryId (0/1), or null if recoveryId doesn't yield a valid point. This lets a verifier check a signature against a known address/pubkey instead of only checking r/s/v are in range.
verify(String message, Uint8List publicKey, String signature) bool
Verify a raw r||s signature: the first 32 bytes are r, the next 32 are s. Any bytes beyond that are ignored — some callers (e.g. CKB, HNS) append a trailing recovery id that this check doesn't need. Returns false (instead of throwing) for input shorter than 64 bytes or a public key that doesn't decode to a point on the curve, so a malformed signature fails closed rather than crashing the caller.
verifyDerWithHashType(String message, Uint8List publicKey, String signature) bool
Verify a DER-encoded signature with a trailing sighash byte — the format DOGE/LTC(non-Taproot)/BCH sign() actually produce. Returns false for malformed DER instead of throwing.

Constants

SIGN_LENGTH → const int