RateLimited°C
09-22-2024
BSV
$47.87
Vol 14.38m
-3.63%
BTC
$62594
Vol 15169.23m
-1.06%
BCH
$337.5
Vol 172.11m
-1.23%
LTC
$67
Vol 292.64m
1.01%
DOGE
$0.1
Vol 550.07m
-3.26%

This post was first published on Medium.

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_DATASIGVERIFY (aka, OP_CHECKDATASIG) on BCH.

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

***

NOTE:

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

Recommended for you

Blockchain enables autonomous AI agents to learn
Utilizing blockchain tech, a group of Belgian scientists enabled autonomous AI agents to learn and communicate securely, contributing to the...
September 17, 2024
WhatsOnChain gets own UTXO endpoints for BSV blockchain services
With ElectrumX set to retire in October, WhatsOnChain is gearing up to implement a new UTXO set of API endpoints,...
September 16, 2024
Advertisement