CS120 Study Guide

Site: Saylor Academy
Course: CS120: Bitcoin for Developers I
Book: CS120 Study Guide
Printed by: Guest user
Date: Saturday, April 20, 2024, 9:54 AM

Navigating this Study Guide

Study Guide Structure

In this study guide, the sections in each unit (1a., 1b., etc.) are the learning outcomes of that unit. 

Beneath each learning outcome are:

  • questions for you to answer independently;
  • a brief summary of the learning outcome topic; and
  • and resources related to the learning outcome. 

At the end of each unit, there is also a list of suggested vocabulary words.


How to Use this Study Guide

  1. Review the entire course by reading the learning outcome summaries and suggested resources.
  2. Test your understanding of the course information by answering questions related to each unit learning outcome and defining and memorizing the vocabulary words at the end of each unit.

By clicking on the gear button on the top right of the screen, you can print the study guide. Then you can make notes, highlight, and underline as you work.

Through reviewing and completing the study guide, you should gain a deeper understanding of each learning outcome in the course and be better prepared for the final exam!

Unit 1: Introduction to Bitcoin Technology

1a. Describe the structure of a peer-to-peer network

  • How would you describe the structure of the Bitcoin network?

The Bitcoin network has a flat structure meaning that no node, or computer, on the network has more control than any other node. The network is peer-to-peer, where all nodes can communicate with no intermediary or coordinator. Some nodes on the network are mining nodes, or miners, who do some work to record transactions in the blockchain, but all nodes communicate and exchange data on the same flat network.

The whitepaper states that "a purely peer-to-peer version of electronic cash would allow online payments to be sent directly from one party to another without going through a financial institution". Bitcoin is a network without a central authority.

To review, see Bitcoin: A Peer-to-Peer Electronic Cash SystemWhat is Bitcoin?, and The Bitcoin Network.


1b. Describe how Bitcoin keeps track of value on the network

  • Bitcoin doesn't use the concept of accounts, nor does it keep track of "coins", so how is value exchanged and recorded on the network?

The Bitcoin blockchain is a shared ledger that keeps track of the inputs and outputs of transactions. The Bitcoin software does not include the concept of accounts. Instead, the software keeps track of unspent transaction outputs or UTXOs. A Bitcoin wallet doesn't hold coins but rather keeps track of UTXOs.

Instead of transfers between accounts, Bitcoin operates in terms of transaction inputs and outputs. Every transaction consumes one or more UTXOs as inputs and creates one or more outputs that become UTXOs themselves.

To review, see Bitcoin Transactions.


1c. Explain how a balance of power is maintained in Bitcoin to keep the system open and decentralized

  • Who controls the Bitcoin network? Which groups or entities influence the development of the software or the network?

No one person, group, or entity controls Bitcoin. Several groups influence the Bitcoin network and the software. They include miners, developers, wallets, merchants, users, etc. As no one entity controls Bitcoin, but many people have some influence, a balance of power is maintained.

One group cannot force a change in the software or network without cooperation from the other influential groups.

To review, see Understanding Consensus.


1d. Discuss what makes a blockchain "open"

  • Who can join the Bitcoin network, and what do they need to do to join?

Anyone with an internet connection and a computer can join the Bitcoin network. As no one controls the Bitcoin network, no one entity can control access to the network. All Bitcoin network data is public.

No entity grants access to the network. Anyone who is technically capable of accessing the public network can participate. The network itself will allow all valid transactions to be propagated. Miners will include all transactions they have an incentive to include regardless of who sent the transaction, as they likely will not even have that information.

To review, see Why Open Blockchains Matter.


1e. Look up a transaction and explain its current status on the network

  • How are transactions, or ledger entries, on the Bitcoin network viewed?

The most basic way to view Bitcoin transaction data is via the command line when running the Bitcoin software. However, there are some user-friendly options. Block explorer websites offer an easy-to-use option for exploring blockchain data. There are explorers available, and transaction data can be found quickly in various ways, such as by searching a block hash or a transaction ID.

To review, see Bitcoin Transactions.


Unit 1 Vocabulary

This vocabulary list includes terms you will need to know to successfully complete the final exam.

  • miner
  • node
  • peer-to-peer network 
  • UTXO 

Study Session Unit 1

Unit 2: Cryptographic Algorithms

2a. Differentiate between the cryptographic functions that are used in Bitcoin

  • What are two types of cryptographic functions that Bitcoin uses, and what are they used for?

Bitcoin primarily uses two types of cryptographic functions: digital signatures and hashing. Digital or cryptographic signatures are used to sign transactions, and hashing algorithms, or hash functions, are used to create transaction IDs, verify blockchain data, create addresses, etc.
However, it is important to understand that Bitcoin does not use encryption to encrypt data. The network and all blockchain data are public. The blockchain being public is one of the most important features of the Bitcoin network.
To review, see Keys and Addresses and Cryptographic Hash Functions.

2b. Differentiate between symmetric and asymmetric encryption 

  • What type of encryption involves the use of a shared secret key? Which type of encryption involves the use of public and private key pairs?

Symmetric encryption uses shared secret keys. Asymmetric encryption uses public and private key pairs, which is a critical feature in Bitcoin.
Asymmetric encryption allows nodes on the network to validate transaction signatures by checking that the signatures match the public keys without needing access to the corresponding private keys. Asymmetric encryption allows us to avoid a major issue with symmetric encryption: how to securely transfer the shared secret key. With asymmetric encryption, private keys are never shared, and instead, public keys can be shared openly without compromising the security of the encryption algorithms.
To review, see Keys and Addresses and Exercise: Encrypt and Decrypt Data.

2c. Explain the difference between public and private keys 

  • Which type of key is meant to be kept secret, public or private? Is it acceptable to share public keys? When is it acceptable to share private keys?

A private key is a random number that allows the owner to sign transactions spending funds on the Bitcoin network. It must be kept secret, as anyone in possession of the key can move the associated funds.
Public keys are generated from private keys using a hashing algorithm via an irreversible process called elliptic curve multiplication. A bitcoin address is then derived from the public key again using hashing.
Although sharing public keys (rather than addresses) will not result in loss of funds, it is still considered best practice to share a little data as necessary.
To review, see Keys and Addresses and Keys and Bitcoin Addresses.

2d. Explain the significance of private keys in asymmetric cryptography and in Bitcoin 

  • Describe how a Bitcoin address is derived from a private key and which type of key (public or private) is used to sign a transaction?

Private keys are used in asymmetric cryptography and Bitcoin to sign transactions authorizing spending funds. Once the transaction is constructed and signed, asymmetric cryptography is again used to verify that the entity making the transaction is the same entity that has the private keys.
To review, see Keys and Addresses and Keys and Bitcoin Addresses.

2e. Summarize the relationship between keys and Bitcoin addresses 

  • What type of cryptographic function generates a public key from a private key?

Once a public key has been generated from a private key, what type of cryptographic function is used to generate a Bitcoin address?
Elliptic curve multiplication generates a public key from a private key.
This is the process by which we can start with a private key and get to a Bitcoin address:

  1. A public key is derived from the private key using elliptic curve multiplication
  2. The public key is processed via a "double hash" function (a combination of SHA256 and RIPEMD160) to generate a public key hash
  3. The public key hash is encoded in Base58 to generate a Bitcoin address

To review, see Can Someone Guess My Crypto Private Key?.

2f. Use a public and private key pair to encrypt and decrypt data 

  • What tools would a developer need to generate encryption keys? What is the general process for encrypting and decrypting data?

Developers use standard encryption code libraries to generate the encryption keys used in Bitcoin. Bitcoin uses elliptic curve cryptography and, more specifically, the SECP256k1 curve.
The general process is:

  1. A key pair is generated from a very large random number to serve as a private key, and a public key is derived from the private key using elliptical curve multiplication
  2. These keys are often converted to specific formats
  3. The keys are used to encrypt data
  4. The private key is used to decrypt the data back into its original form

To review, see Exercise: Encrypt and Decrypt Data.


Unit 2 Vocabulary

This vocabulary list includes terms you will need to know to successfully complete the final exam.

  • asymmetric encryption
  • Bitcoin address
  • cryptographic signatures
  • hash functions
  • public and private keys
  • symmetric encryption

Study Session Unit 2

Unit 3: Cryptographic Signatures

3a. Summarize the security benefits of cryptographic signatures

  • Why do Bitcoin transactions include signatures?

A signature provides authentication and nonrepudiation. It is proof that the data came from a specific entity in control of a specific key and that the data has not been altered since that entity signed it. Without this security feature, anyone would be able to alter Bitcoin transactions to send funds to their chosen addresses.
To review, see More on Bitcoin Transactions and What are Cryptographic Primitives?.

3b. Identify the components needed to create and validate a signature 

  • How are digital signatures created?

To create a digital signature (also called a cryptographic signature), you'll need the data to be signed and the private key used to create the signature. This will create a signature with two numbers commonly referred to as the R and S values. Once created, cryptographic signatures can be validated using the data, the signature, and the public key associated with the private key used to create the signature.
To review, see Exercise: Sign and Validate Data.

3c. Explain how signatures are used in Bitcoin transactions 

  • What is a SIGHASH?

A signature on a Bitcoin transaction may not be signing all the transaction data. It's possible that a signature only covers a portion of the transaction, or more specifically, a hash of a part of the transaction data. Bitcoin signatures indicate which part of a transaction's data is included in the signature using a SIGHASH flag. The SIGHASH flag is a single byte that is appended to the signature. Every signature has a SIGHASH flag, and the flag can be different from input to input. A transaction with three signed inputs may have three signatures with different SIGHASH flags, each signature signing (committing) different parts of the transaction.
To review, see More on Bitcoin Transactions.

3d. Sign data and validate signatures cryptographically 

  • What is ECDSA?

ECDSA stands for Elliptic Curve Digital Signature Algorithm. It is the type of digital signature algorithm that Bitcoin currently uses in various script functions such as OP_CHECKSIG, OP_CHECKSIGVERIFY, OP_CHECKMULTISIG, OP_CHECKMULTISIGVERIFY, etc.
To review, see Exercise: Sign and Validate Data and Elliptic Curve Signatures.

Unit 3 Vocabulary

This vocabulary list includes terms you will need to know to successfully complete the final exam.

  • cryptographic signature
  • digital signature
  • elliptic curve cryptography

Study Session Unit 3

Unit 4: Hashing

4a. Explain the utility of hashing data 

  • What is the most important attribute of a hash function, and what are hashes used for?

The most important attributes of hashing functions are their uniqueness and one-way functions, essentially making a "digital fingerprint" of the input that is infeasible to reverse engineer. Any changes to the data represented by the hash will completely transform the hash of the data and, therefore, can be used to verify that no data has been altered.
Hash functions are used in Bitcoin to summarize transaction data, conduct mining proof of work, and generate addresses.
To review, see Hash Functions, Mining, and Addresses and Hashing Algorithms.

4b. Describe how hashing is used in Bitcoin mining 

  • How are the number of zeros required in a hash important for Bitcoin mining?

The number of zeros required in a hash is proportional to the difficulty of mining on the network. The more leading zeros required in the hash of a bitcoin block, the harder it is to find a hash that fits.
Therefore, the amount of leading zeros required in a hash represents the current level of mining difficulty in the network, a critical feature in proof-of-work.
To review, see Mining Fees, Block Data, Block Headers, and Proof-of-Work and How Is the Number of Zeros in the Target Hash Determined?.

4c. Differentiate between the different uses of hashing in Bitcoin

  • What are some of Bitcoin's main processes and components that rely on hashing?

Hash functions are used extensively in Bitcoin. Some of the main components and processes that rely on hashing are generating Bitcoin addresses from public keys, identifying Bitcoin blocks, identifying Bitcoin transactions, and Bitcoin mining proof of work.
To review, see Hashing Algorithms and Mining and Consensus.

4d. Hash data and verify that a hash was produced from that data 

  • Is there only one standard hashing algorithm?

There are many standard cryptographic hashing algorithms. However, Bitcoin uses one in particular, called SHA256, as it has distinct advantages for the Bitcoin Network.
SHA256 hashing produces easily verifiable values, is hard to guess at random via a brute force attack, and is unlikely to create collisions (two distinct inputs producing the same output).
To review, see Hash Functions, Mining, and Addresses and Merkle Trees.

4e. Describe the utility of a Merkle tree 

  • What is the main attribute of a Merkle Tree used in Bitcoin?

The main attribute of Merkle Trees that makes them useful in the Bitcoin Network is their ability to efficiently summarize large amounts of data in an easily verifiable manner. Remember, a Merkle Tree is a tree data structure containing cryptographic hashes.
Bitcoin uses Merkle Trees for this reason: a Merkle tree structure is used to summarize all the transactions in each blockchain block, producing an easily verifiable digital "fingerprint" of all the transactions in the block.
To review, see Merkle Trees.

Unit 4 Vocabulary

This vocabulary list includes terms you will need to know to successfully complete the final exam.

  • cryptographic hash function
  • Merkle tree
  • SHA256 algorithm

Study Session Unit 4

Unit 5: Bitcoin Data

5a. Explain various encoding methods used in Bitcoin 

  • What are some of the benefits of using hex as an encoding system in Bitcoin?

Hexadecimal is a base 16 system rather than the base 10 decimal system that most of us are very familiar with. Hexadecimal uses the decimal numbers 0 through 9 and six additional symbols, the letters a through f. This makes hex easier for humans to work with binary data as it provides a human-friendly way to represent binary values. Each hexadecimal digit represents 4 bits, half a byte, which means that a single byte can have values ranging from 00000000 to 11111111 in binary, which can be much more compactly represented in hex as 00 to FF.
Hexadecimal numbers, or hex, can shorten the number of digits required to the large numbers used in Bitcoin keys and make binary data more easily readable to humans.
To review, see Hex and Base58.

5b. Summarize the error prevention benefits provided by base58 and address checksums 

  • How does base58 encoding differ from base64, and what benefit does this difference provide?

Base58 encoding differs from base64 format by eliminating easily confused characters (by humans) from the set. The characters removed are: the number zero (0), the capital letter "O", the lowercase letter "L" (l), the capital "I", the left and right quotation marks ("") and the backslash "/" symbol.
The benefit of removing these characters is that it makes the transcription of keys in Bitcoin more accurate when performed by humans.
To review, see Base58.

5c. Describe the data in a Bitcoin block 

  • What are the main components of the data found in every Bitcoin block?

A block in Bitcoin is the fundamental component of the blockchain and, therefore, a critical component of the network's infrastructure that every Bitcoin developer needs to be familiar with.
Each block in the Bitcoin blockchain consists of the block header, which contains metadata about the block and the transactions which compose the majority of the data in the block.
The block header always references the block hash of the previous block (the parent), thus forming a chain from the present block back to the first block mined in 2009 (the Genesis Block).
To review, see The Blockchain.

5d. Convert data between hex and base58 

  • What are the primary uses in Bitcoin for the following data formats: DER, hex, and base58

Hex and base58 data formats are primarily used to make the numbers used in Bitcoin more compact and easily readable by humans and prevent errors in transcription.
DER, or Distinguished Encoding Rules format, is needed for encoding the binary numbers that represent digital signatures with the precision required for accurately generating and verifying digital signatures.
To review, see Base58.

Unit 5 Vocabulary

This vocabulary list includes terms you will need to know to successfully complete the final exam.

  • base58 encoding
  • DER encoding
  • hexadecimal encoding

Study Session Unit 5

Unit 6: Bitcoin Nodes and Wallets

6a. Describe the functions of a full node 

  • What is the definition of a full Bitcoin node, and how does it compare to a mining node?

A Bitcoin node is a computer that participates in the Bitcoin network. A Bitcoin node can consist of a combination of the following functions: a miner, a wallet, a network router, and storage of the Bitcoin Blockchain, although to be considered a Bitcoin node, it is necessary that the computer participates in network routing.
A Bitcoin full node keeps a complete and up-to-date record of the entire Bitcoin blockchain and can independently and authoritatively verify Bitcoin transactions.
A mining node, by comparison, needs only to run the mining protocol and may defer the other functions of a full bitcoin node to a pool protocol.
To review, see What is the Role of Nodes? and Running Your Own Node.

6b. Experience Bitcoin node and wallet functionality by setting up a regtest node and using it to perform basic functions 

  • What are some of the primary functions of Bitcoin nodes, and what types of Bitcoin networks are available for testing purposes?

Bitcoin nodes are used for mining, verifying transactions, communicating with the network, and making and receiving Bitcoin transactions in the case of a node that is also a wallet.
There are three main network types:

  1. Mainnet, where the actual Bitcoin blockchain runs
  2. Testnet, an equivalent Bitcoin network that uses test Bitcoin to allow for testing by developers and Bitcoin users without the need to risk real bitcoin.
  3. Regtest, a completely local version of the Bitcoin network, allows simple and lightweight developer testing and testing modifications to network protocols.

To review, see Exercise: Set Up a Regtest Node and Running Your Own Node.

6c. Distinguish between the different functions of a Bitcoin wallet 

  • What are the primary functions of a Bitcoin wallet from the developers' point of view? And from the point of view of an end-user?

From the developer's point of view, the primary function of a Bitcoin wallet is a key storage and management system.
From the end user's point of view, the primary function of a Bitcoin wallet is a user interface that allows them to interact with the Bitcoin network, that is, to send and receive Bitcoin and track the balance of the bitcoin they control,
Remember: a Bitcoin wallet does not store bitcoin, but rather the private keys that allow bitcoin to be spent.
To review, see Wallets.

6d. Retrieve wallet data from a node 

  • What are some of the industry best practices for Bitcoin wallets that have improved interoperability and security?

As Bitcoin wallet technology developed, an unofficial set of best practices has developed, greatly improving standardization, interoperability, and security. Here are some of the most important best practices and a brief refresher on their purpose:

  • Mnemonic code words (BIP-39: makes transcribing private keys much easier and more accurate for end-users)
  • Hierarchical Deterministic - HD - (BIP-32/BIP-44: allows for wallets to continuously generate new addresses and public keys, improving security and making backups more reliable)
  • Multipurpose HD wallet structure (BIP-43: defines the structure of an HD wallet for standardization)
  • Multicurrency and multi-account wallets (BIP-44: allowing for wallets to track different currency conversions and organize transactions into different accounts)

To review, see Wallets.

Unit 6 Vocabulary

This vocabulary list includes terms you will need to know to successfully complete the final exam.

  • full node
  • Mainnet
  • Regtest
  • Testnet

Study Session Unit 6

Unit 7: Transactions and Scripting

7a. List the elements of a valid transaction 

  • Why does the Bitcoin network include transaction fees and how are they added to a Bitcoin transaction?

Transaction fees play a very important role on the Bitcoin network. They provide incentives to ensure that the network is used well and maintained. They serve as incentives to miners, encouraging them to continue the work of creating blocks, and transition fees offer a disincentive against abuse of the system by imposing a small cost on every transaction, discouraging spam.
How transaction fees are calculated is different than you might suspect. Rather than being based upon the value of a transaction, fees are calculated based on the size in kilobytes (and thus complexity) of a transaction. This protects the functioning of the network as it makes it expensive to send a large amount of big and complex transactions, which take up valuable resources on the network.
How fees are included in transactions has also been a point of confusion. Fees are not directly stated. Rather, they are inferred from the difference between inputs and outputs. Fees = Sum(Inputs) – Sum(Outputs)
To review, see What's in a Transaction?.

7b. Describe and understand the structure of unspent transaction outputs, or UTXOs 

  • Describe the Bitcoin scripting language used when locking and unlocking(spending) an Unspent Transaction Output, or UTXO.

The bitcoin transaction script language, called Script, is a Forth-like reverse-polish notation stack-based execution language. Unspent Transaction Outputs, or UTXOs, are locked using this script. When a transaction is broadcast to the network, it is validated by executing the unlocking Script in each input alongside the corresponding locking script. If this process satisfies the spending condition, the transaction is considered valid.
To understand this process, you'll need to be familiar with stack-based execution of a program. This process uses push and pop functions that add and remove items from the stack whose data structure is also called a Last-In-First-Out, or "LIFO" queue. This image can help you visualize how the transaction validation process works through a script.

Via this process, transaction inputs and outputs go through a locking and unlocking process. It is also important to note that the bitcoin transaction script language is stateless, as all the information needed to execute a script is contained within the script.
To review, see Scripts and Script Language.

7c. Describe the Bitcoin transaction timeline 

What is the Bitcoin mempool, and when would a transaction be in the mempool?
The mempool can be thought of as the transaction waiting room. It lists all broadcast and valid transactions that have yet to be "confirmed" or included in the blockchain. What is a bit confusing is that we often reference "the" mempool, it would be more accurate to say "a" mempool as each node maintains its own mempool.
A transaction is created by wallet software, signed using a private key controlled by the wallet, broadcast to peers on the network, validated by peers receiving the transaction, then sits in the mempool waiting to be included in a block. Once a miner has found a block that includes that transaction, we say that the transaction has one confirmation. Each time a block is added to the chain on top of that block that includes that transaction, we say that the transaction has another confirmation. Once the transaction has six confirmations, we consider it final.
To review, see Transactions and Multisig.

7d. Work with Bitcoin scripts

  • What are OP codes, and what are their roles in Bitcoin transactions?

Op codes are operators that push or pop one or more parameters from the stack, act on them, and perhaps push a result onto the stack.
To review, see Scripts and Script Language and Transactions and Multisig.

Unit 7 Vocabulary

This vocabulary list includes terms you will need to know to successfully complete the final exam.

  • Op codes
  • stack-based
  • transaction fees

Study Session Unit 7

Unit 8: Reaching Consensus

8a. Understand the transaction validation process 

  • Which nodes on the Bitcoin network do the job of checking the validity of transactions broadcast to the network?

Every full node on the Bitcoin network validates every transaction. This is important to the peer-to-peer structure of the network. Every node will see incoming transactions and run the full checks to determine if the transaction is valid. These checks include the basics, such as confirming that the inputs being used have not yet been spent and that the amount of satoshis in the inputs is equal to or greater than the satoshis in the outputs, all the way to validating the signatures included.
If a transaction passes all the checks, the node has confirmed that it meets the consensus rules and is valid. Valid transactions are forwarded to the node's peers, while invalid transactions are not propagated through the network.
To review, see The Consensus Process.

8b. Explain how Bitcoin is updated while maintaining consensus 

  • If no one controls Bitcoin, who can implement updates to the software?

Bitcoin's balance of power means that it is difficult for one entity to control it, but it also means that implementing changes can be very difficult. For a change in the code/network to be implemented, there needs to be a near-complete consensus between the participants in the network and ecosystem. The developers working on the code changes need to cooperate, node operators need to be willing to update to the new software, merchants accepting Bitcoin need to accept the resulting version of Bitcoin, wallets need to build support for the changes, etc.
If some of the nodes on the network enact changes that are not backward compatible while others don't, the network may be split in two. This type of network partition is called a hard fork, as, after the fork, the chains evolve independently. Those attempting to implement changes on the Bitcoin network generally work hard to avoid this scenario. Many strategies are enacted to ensure that changes are either backward compatible(a soft fork) or have near-complete consensus.
To review, see Validating Blocks.

8c. Explain how "double spends" are prevented 

  • What prevents a miner from cheating and including a double spend or an invalid transaction in a block?

Miners are incentivized to do the work of mining by the possibility of receiving mining rewards. The Bitcoin software allows for a special transaction, called the coinbase transaction, to be included in each block, giving the miner their mining reward. However, those funds can not be spent until that new block has 100 confirmations. This means that the miner who found the block can not use their reward until the network has accepted that block for over half a day. If that miner were to include an invalid transaction in that block, it would quickly be recognized as an invalid block by other nodes on the network and rejected.
To sum it up, a miner will not include invalid transactions in their blocks as they would get no benefit from doing so. The network would reject the block, and the work they put into making it would go to waste.
To review, see The Consensus Process.

8d. Summarize the Bitcoin mining process and how consensus is achieved 

  • What is the most cumulative Proof-of-Work, and what role does it play in consensus?

It sometimes occurs on the Bitcoin network that two new blocks are found at roughly the same time. From the perspective of a mining node, this looks like a fork in the blockchain, and they need to decide which of these different chains to build on top of. A node will choose the chain or fork with the most cumulative proof-of-work. This is generally the chain with the most blocks. Where there are two equal-length chains, a mining node will choose to build on the one which has the most Proof-of-Work.
Remember that proof-of-work is proof that computing power was put into finding hashes to data that meet certain criteria. Specifically, a block hash with more zeros is proof of more work than one with fewer zeros. A node will follow the chain with the blocks with hashes that were essentially the hardest to find, as that is good proof that more work went into "mining" those blocks.
To review, see The Consensus Process and Validating Blocks.

Unit 8 Vocabulary

This vocabulary list includes terms you will need to know to successfully complete the final exam.

  • hard fork
  • soft fork

Study Session Unit 8