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
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_signRPC 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/sare 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 thesoffset. 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) inv, not the legacy EIP-155-encoded value (recId + chainId*2 + 35). Passing the typed-txvthrough 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/sovermessageHashfor the givenrecoveryId(0/1), ornullifrecoveryIddoesn't yield a valid point. This lets a verifier check a signature against a known address/pubkey instead of only checkingr/s/vare in range. -
verify(
String message, Uint8List publicKey, String signature) → bool -
Verify a raw
r||ssignature: the first 32 bytes arer, the next 32 ares. Any bytes beyond that are ignored — some callers (e.g. CKB, HNS) append a trailing recovery id that this check doesn't need. Returnsfalse(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. Returnsfalsefor malformed DER instead of throwing.
Constants
- SIGN_LENGTH → const int