Often when someone hears the word "cryptography", they think only of encrypting or hiding data. However, the branch of math that is cryptography includes a wide variety of functions that serve many purposes besides just hiding or encrypting data. In fact, Bitcoin doesn't encrypt any of its blockchain data. What Bitcoin does do is hash and sign data.
In this unit, we'll cover the basics of cryptography, including hashing and signing data, and explain the field's evolution from symmetric to asymmetric encryption. We'll then dig into public and private keys and how Bitcoin uses them in addresses and transactions.
Completing this unit should take you approximately 2 hours.
Bitcoin is called a cryptocurrency because of its heavy use of cryptography. Here we'll take a quick look at symmetric and asymmetric encryption, as well as the two cryptographic functions that Bitcoin uses: digital signatures and hashing.
Now that we've covered the basics of public and private keys, let's dive in a bit deeper and take a look at how Bitcoin generates these keys.
Hashing is used extensively in Bitcoin, from data structures to mining, transaction IDs, and more. Hashing algorithms have many properties that make them very useful. But not all hashing algorithms are the same. SHA256, the algorithm that Bitcoin uses, is well suited to Bitcoin's needs.
This brief video will introduce you to the basics of hashing.
A Bitcoin transaction isn't valid without a signature. Signatures are a big component in preventing fraud on the network. And where do these signatures come from? Yup, private keys! Your private keys give you the ability to transfer your Bitcoin. This short video will introduce you to the basics of cryptographic signatures.
One of the ways that Bitcoin uses cryptographic keys is in generating Bitcoin addresses, which are often derived from public keys. This chapter covers public keys and how they are used to generate addresses.
The security and integrity of Bitcoin depend largely on private keys, and these keys are randomly generated large numbers. This often feels a bit insecure. You may worry that someone may coincidentally generate the same private key as you. It can be a bit difficult to comprehend the magnitude of the numbers being dealt with here. Since this is such an important piece of the Bitcoin system, let's take a few minutes to appreciate the incredible unlikelihood of generating the same private key as someone else on the network.
While Bitcoin doesn't actually encrypt any data, it relies upon public and private keys pairs. Working with Bitcoin requires familiarity with these keys and the best way to get familiar with technology is to use it! In this exercise, we'll generate a key pair and use those keys to encrypt and decrypt data with a bit of Python.
Take this assessment to see how well you understood this unit.