Bitcoin
ecdsa – How to verify signature with JavaScript/TypeScript after signing message?
On the frontend, the user signs an arbitrary message (e.g. “Prove that you own this wallet by signing this message”). For example, UniSat’s signMessage
Features (see here).
I want to check this message in the backend. I want something like this:
function verifySignature(message: string, address: string, signature: string): boolean
How to achieve this? address
Instead of publicKey
This is in the function parameter list.
I know that my Bitcoin wallet app or browser extension uses ECDSA to sign messages (or more precisely, the SHA256 digest of the message), but the signing process is different for different types of Bitcoin addresses (P2PKH, P2SH, P2WPKH, P2WSH, P2TR). So instead of implementing it myself, I’d like a JavaScript/TypeScript package that can do this robustly.