Skip to main content

Book: Bitcoin from theory to practice

Alessio Barnini
Author
Alessio Barnini
Senior Software Engineer • Cybersecurity • Bitcoin Enthusiast
Bitcoin Script Bash Cryptography P2P Reverse Engineering

This manual was born from a long and meticulous reverse-engineering effort on the Bitcoin protocol. To demonstrate the true nature of the system, I chose to ban all external libraries: all cryptographic and network operations were explored and reproduced manually by writing scripts in Bash, analyzing the source code and the official documentation line by line.

The practical (Hands-On) curriculum includes:

  • Direct Node Interaction: RPC calls to a real Bitcoin Core Full Node to query blocks and transactions.
  • Cryptography & Mining: Algorithmic calculation of the Proof of Work Difficulty and manual recalculation of the Merkle Root starting from the raw block message.
  • Cryptographic Wallet Management: Hierarchical key derivation (HD Wallets), Seed Phrase entropy management, Child Key Derivation (Hardened/Non-Hardened), and parsing xpub/xprv formats.
  • Raw Transactions: Manual construction of the UTXO model, definition of Inputs/Outputs, study of Locking Scripts (Coinbase), and digital signature from scratch.

The chosen approach is purely low-level: getting our hands dirty with the CLI and the terminal. This meticulous work allowed me to deeply internalize the logic of digital signatures, understand the consensus dynamics of trustless and peer-to-peer networks, master the stack-based Bitcoin Script language, and acquire the ability to read and parse cryptographic structures byte by byte.