ECDSA — How to programmatically sign a transaction

Cryptography series IV — ECDSA explained: we are going to grab a message and do all the steps for ECDSA signing — the most commonly used digital signature algorithm in blockchains

Henrique Centieiro & Bee Lee
Level Up Coding
Published in
8 min readJun 20, 2021

--

If you are in the blockchain space, almost for sure, you have heard about ECDSA. ECDSA stands for Elliptic Curve Digital Signature Algorithm and uses the elliptic curve cryptography.

ECDSA is the signature scheme used in Bitcoin. Every Bitcoin address (the one you use to send and receive funds) is a cryptographic hash of the ECDSA public key. You can check this article to learn more about cryptographic hashing.

For this ECDSA article, we will follow Ethereum’s method with Ethereum libraries.

ECDSA is also used in many other applications other than blockchains. For example, the Apple ecosystem widely uses ECDSA, and it is one of the main signing mechanisms of iOS; it’s used in iMessage, iCloud and so on.

ECDSA VS RSA

Why we need ECDSA when we have already RSA, which is the gold standard for asymmetric cryptography?

Well, it happens that to break an RSA key requires to factor 2 large prime numbers (we have talked about the prime number factorization for RSA here). We are getting better and better at doing this, which requires having larger and larger RSA keys.

On the other hand, breaking ECDSA requires solving the Elliptic Curve Discrete Logarithm Problem (ECDLP), which is much harder. This means that with ECDSA, we can have the same level of security as RSA but with smaller keys which means less data which translates into faster transactions (which is very important in blockchains). To crack ECDSA, you would have to guess a point in the elliptic curve that was generated from a large random number.

Let’s sign a transaction with ECDSA step-by-step!

Now please stick with me to navigate through transaction signing with ECDSA. I promise you will have fun reading this article 😇. This is an essential function in blockchain and cryptography. Not as critical as chocolate… but still essential.

Do you remember the previous Cryptography series article where we talked about RSA, Alice and Bob share and sign a message? Now we will do…

--

--