A from-scratch tour of Bitcoin in Python
A developer tutorial walks through creating, signing, and broadcasting a Bitcoin transaction in pure Python from scratch, covering elliptic curve cryptography and how Bitcoin represents value.
I find blockchain fascinating because it extends open source software development to open source + state. This seems to be a genuine/exciting innovation in computing paradigms; We don't just get to share code, we get to share a running computer, and anyone anywhere can use it in an open and permissionless manner. The seeds of this revolution arguably began with Bitcoin, so I became curious to drill into it in some detail to get an intuitive understanding of how it works. And in the spirit of "what I cannot create I do not understand", what better way to do this than implement it from scratch? We are going to create, digitally sign, and broadcast a Bitcoin transaction in pure Python, from scratch, and with zero dependencies.
In the process we're going to learn quite a bit about how Bitcoin represents value. Let's get it. (btw if the visual format of this post annoys you, see the jupyter notebook version, which has identical content). Step 1: generating a crypto identity First we want to generate a brand new cryptographic identity, which is just a private, public keypair. Bitcoin uses Elliptic Curve Cryptography instead of something more common like RSA to secure the transactions…
- karpathy.github.ioA from-scratch tour of Bitcoin in Pythonprimary