Bitcoin Developers Basics 02: Crypto + Digital Signatures
What you'll learn
- Developers looking to learn about Bitcoin basics
- Learn how elliptic curves and private keys work
- Understand the parameters for secp256k1
- Implement ECDSA in Python
- Learn about Bitcoin Sighash flags
- Write P2PK, P2PKH, and P2WPKH scripts
- Make and spend a multisig Bitcoin transaction
Requirements
- No prior blockchain or cryptography experience necessary.
- It's assumed that you're familiar with the material in the Base58 Developer Basics: Transactions, Scripts + SegWit
- Some basic Python and algebra knowledge will be useful
Description
So you've heard about bitcoin? Ever wondered what's going on with the data in a transaction, or how bitcoin gets locked up and transferred from one holder to another?
This course by Base58 instructor niftynei, will take you on a deep dive of the fields, bytes, and scripts that make up the bitcoin blockchain data. In an software engineer focused manner, we'll go over everything you need to know to build your own bitcoin transaction parser, write your very own custom bitcoin locking scripts, and adapt your transactions to the modern SegWit format.
Step 1: Let's learn about Elliptic Curve Cryptogaphy
First we figure out what the building blocks for making digital signatures on blockchains are: elliptic curves! We'll do a very basic walk through of how these work and work through where Bitcoin's secp256k1 curve comes from. Finally we'll pick some private keys and learn how to find the public key version of it.
Topics: elliptic curves over finite fields, secp256k1, public and private keys
Step 2: P2PK, P2PKH: Locking Bitcoin up to Public Keys
Now that we've got some private and public keys, we're ready to learn about standard Bitcoin scripts with signatures. We'll write some P2PK, P2PKH, and P2WPKH scripts and lock bitcoin up to them (so we can unlock it later).
Topics: compressed keys, P2PK, P2PKH, P2WPKH
Step 3: Digital Signatures
Now that we've got Bitcoin locked up to some public keys, we need to learn how to make signatures to unlock it. We'll walk through how ECDSA works.
Topics: digital siganatures, ECDSA
Step 4: Sighashes
Now that we've got ECDSA under our belt, we're ready to make signatures to spend the bitcoin we locked to our public keys. Here we use sighashes to build the message to sign with ECDSA. Sighashes are how we commit to data in a transaction, to prevent anyone else from tampering with the data on its way into a block.
Topics: sighashes, SegWit, legacy, SIGHASH_ALL, SIGHASH_NONE, SIGHASH_SINGLE
Step 5: Multisig
Finally, we'll take a look at how you can lock bitcoin up to threshold signatures using OP_CHECKMULTISIG.
Topics: multisigs, OP_CHECKMULTISIG, Script
Who this course is for:
- Developers that want to learn more about the cryptography used in blockchains
- Bitcoiners that want to really understand how Bitcoin works
- Cryptocurrency curious devs!
- Protocol designers that want an in-depth course on bitcoin design decisions
- Cryptographers that want an engineer-focused understanding of bitcoin transactions
- Beginning blockchain developers
Instructor
niftynei is a lightning protocol engineer at Blockstream and the lead instructor and curriculum writer at Base58, the premier bitcoin protocol school. With over a decade of experience in writing and engineering software applications, she's excited to bring her 4 years of experience working in bitcoin to curious learners and software engineers across the globe.