Bitcoin Programming

Working through BUIDL Bootcamp: ECDSA Coin

Overview of Lesson

In my opinion, this lesson makes a lot of sense once you finish it. You’re kept a little bit in the dark while working through it, and even at the end, you can be a little confused about what is going on.

The fundamental thought of this lesson is this: We’re building a coin that can only be issued by using our “Bank Private Key”.

Next, we’ll build a validate function. This checks all the transfers in the list, to see if anyone wrongly executed the Transfer class.

This is an important function to run, because you can still use a coin that is wrongly transferred, and transfer it yourself. But, if you know the coin is stolen, you know it is not under valid ownership, therefore you should probably just leave it alone.

I would recommend playing around with the procedurally written code towards the end of the lesson, when we’re transferring the coin between Alice and Bob. Try and write a function that encapsulates the logic and still returns valid. I tried, and it kept throwing errors, but I had a better understanding of what I was doing and how the coin worked.

Notes: Overview of Digital Signatures

We generate a random number, called p. This is the private key.

We have a pair of huge numbers called G. We use special multiplications p * G. This returns our public key.

This special multiplication is called elliptic curve multiplication. It make sure that people cannot easily solve for our private key.

Signing a Message

If we wanted to sign a message, with our private key, we would:

  • generate R
  • Perform calculation to produce S

This calculation shows that we have possession of our private key, through a derivation.

However, this does not “show” the private key.

Overview of ECDSACoin

Key Structure:

We create the coin from the bank. Then we transfer to a particular person.

We write a function called issue():

def issue(public_key):
    message = serialize(public_key)

    signature = bank_private_key.sign(message)
    transfer = Transfer(
    coin = ECDSACoin([transfer])
    return coin

The important part here, is passing in the public key. This allows us to issue it to a particular person.


We want to make sure that every coin is issued from the bank. If it is not issued from our bank, we need to throw an error.

We write a function called validate():

def validate(coin):
    transfer = coin.transfers[0]
    message = serialize(transfer.public_key)
    bank_public_key.verify(transfer.signature, message)

Leave a Reply