Unit 5: Bitcoin Data
Bitcoin uses a variety of encoding methods, including some unique methods, checksums, and other techniques. Understanding how Bitcoin stores and transmits data will help you to understand why these methods were chosen. From hexadecimal to base58, these various techniques help minimize data usage, ensure immutability, and prevent errors.
In this unit, you'll learn the various encoding and data storage methods used in Bitcoin, the utility these methods provide, how to convert between encoding, and how these encoding methods improve security and efficiency.
Completing this unit should take you approximately 3 hours.
Upon successful completion of this unit, you will be able to:
- explain various encoding methods used in Bitcoin;
- summarize the error prevention benefits provided by base58 and address checksums;
- describe the data in a Bitcoin block; and
- convert data between hex and base58.
5.1: How Bitcoin Transmits Data on the Network
- To obtain a deeper understanding of how data is transmitted on the Bitcoin network, we'll first need to learn Bitcoin's Peer-to-Peer network architecture by understanding nodes and how they communicate with each other.
This section dives into what Bitcoin calls SPV nodes and how they transmit data. Read this section to understand what data is most vital, as well as the trade-offs between security and convenience when it comes to Bitcoin blockchain data.
5.2: Bitcoin Addresses and Keys
Bitcoin uses some unique encoding methods, specifically Base58 and Base58Check encoding. This is done largely to prevent errors in transactions. The way that Bitcoin generates addresses, and the formats that they are displayed in, has been given a lot of thought to prevent confusion and errors. This section covers, base58, key formats, various types of Bitcoin addresses, and more.
Bitcoin and Bitcoin interfaces use not only unique encoding methods, but also some fairly esoteric ones. Unless you've been working with cryptography, you probably are not familiar with ASN.1 and DER encoding. However, as these are formats that you are likely to need to deal with when working with Bitcoin, we'll cover these formats, as well as PEM, here briefly.
5.3: Hex Encoding
Hex is a data encoding format that is often used in Bitcoin and Bitcoin applications. When working with this tech, you will often find data displayed in hex format. If you're not already familiar with hex, now is the time, since you'll certainly run into it while working with Bitcoin.
5.4: How Bitcoin Stores Data in the Block Structure
Now, let's take a look at how all this data, that was calculated and transmitted efficiently with the use of a variety of formats, is stored in the blockchain. As you may suspect, efficiency and security are also priorities.
5.5: Exercise: View Block Data
We've covered how data is formatted, transmitted, and stored in Bitcoin. Now, let's see it in action by looking at some real blockchain data.
5.6: Exercise: Convert Data between Decimal, Base58, and Hex
Let's practice using the encoding methods we've just covered. In this exercise, we'll convert data including keys between binary, DER, hex, and base58.