CS120 Study Guide

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