ECDSA Signature Verification in Script

We have implemented ECDSA signature verification algorithm in Script. It can verify if an arbitrary message is signed by a private key corresponding to a given public key, while OP_CHECKSIG can only verify signatures when the message is the current spending transaction¹. Surprisingly, this is done without introducing any new opcode such as OP_CHECKSIGFROMSTACK on BTC or OP_DATASIGVERIFY (aka, OP_CHECKDATASIG) on BCH.

Credit

Elliptic Curve Digital Signature Algorithm (ECDSA)

ECDSA is the algorithm used in Bitcoin for signature generation and verification. The verification algorithm is listed below.

ECDSA Signature Verification

Implementation

We have implemented the algorithm as shown below, using the elliptic curve library we released before.

First, we need to extract r and s components from the signature, which is encoded in DER format. Since they are big-endian, we have to convert to little-endian, which is how data is encoded in Script/sCrypt.

DER

After r and s are retrieved, we simply run the standard ECDSA verification algorithm.

ECDSA Contract

[1] More precisely, it verifies signature against sighash.

--

--

--

sCrypt Inc (https://scrypt.io) is a company with a mission to provide integrated on-chain smart contracting solutions using the original BitCoin Protocol on BSV

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

MoonSwap Weekly Report (Nov 16th to Nov 22nd) | Three New Assets Listed & Kepler Protocol &…

Buy Steam Vouchers with Bitcoin, Litecoin, & More

CRV Token: Is Curve DAO’s Governance Token Set To The Moon?

ProBit Exchange Lists MS Token (MST)

Samoyedcoin — Solana’s Cutest Ambassador!

Recap: The 26th Class of RARA NFT School

QNT(Quant ) Get Listed on XT.COM Trade to Share a Reward Pool of $10,000

NFTs and The Adult Content Industry: The Good, the Bad and The Ugly

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
sCrypt

sCrypt

sCrypt Inc (https://scrypt.io) is a company with a mission to provide integrated on-chain smart contracting solutions using the original BitCoin Protocol on BSV

More from Medium

Pay.Party: A tool for democratically allocating funds between team members

New Era Defined by the Idea of Decentralization

Monolith Spotlights: The Graph, Web3’s data search engine and query layer

Tokenized Bitcoins on Ethereum: Part 4