Beginner’s Guide: What Are Bitcoin Private Keys, Accounts, and Wallets?

0
7

For Bitcoin users, the most directly relevant concepts are private keys, accounts, and wallets. Let’s dive into these three concepts and their details. First, a quick primer on public-key cryptography.

Public-key cryptography consists of three components: a public key, a private key, and encryption/decryption algorithms. The public key and algorithms are openly shared (hence the name “public-key cryptography”), while the private key remains confidential. Depending on the use case, either the public key or private key can be used for encryption, with the corresponding private or public key used for decryption. This system serves three main functions:

  • Encryption and decryption
  • Signature verification
  • Key negotiation

In the Bitcoin system, public-key cryptography creates a key pair to control Bitcoin transactions. The key pair includes a private key and a unique public key derived from it. The public key receives Bitcoins, while the private key signs transactions during Bitcoin payments. The mathematical relationship between the public and private keys allows the private key to generate signatures for specific messages. These signatures can be verified using the public key without revealing the private key. When paying with Bitcoin, the current owner submits their public key and signature (a unique signature generated for each transaction from the same private key). Everyone on the Bitcoin network can verify the transaction’s validity using the submitted public key and signature, confirming the payer’s ownership of the transacted Bitcoins at that moment.

What Is a Private Key?Free analytics information innovation illustration

A private key is simply a randomly selected number. Control over all funds in a Bitcoin address hinges on ownership and control of the corresponding private key. In Bitcoin transactions, the private key generates the signatures needed to prove ownership of funds. The private key must remain confidential, as sharing it with a third party effectively hands over the Bitcoins it protects. Additionally, private keys must be backed up to prevent accidental loss, as a lost private key is nearly impossible to recover, and the Bitcoins it secures are lost forever.

How is this random number chosen? Typically, it’s generated using a random number generator, but we won’t delve into those details here.

What Is a Bitcoin Account?Free bitcoin cryptocurrency crypto illustration

The diagram above outlines the rough process of generating a Bitcoin account (or address): private key → public key → Bitcoin address. Let’s break down the detailed steps. The process involves two cryptographic hash functions: SHA256 and RIPEMD160.

  1. A 256-bit random number is generated using a random number generator, serving as the account’s private key.
  2. Bitcoin uses the Elliptic Curve Digital Signature Algorithm (ECDSA), specifically the secp256k1 curve, to sign and verify data. The corresponding public key is calculated using elliptic curve multiplication.
  3. The public key undergoes two hash operations to produce a public key hash.
  4. A double hash is performed on the combination of the Bitcoin address prefix (0x00) and the public key hash, with the first 4 bytes taken as a checksum.
  5. The combination of the Bitcoin address prefix (0x00), public key hash, and checksum is encoded using Base58 to generate the final address.

What Is a Bitcoin Wallet?Free cryptocurrency digital wallet blockchain illustration

A Bitcoin wallet is an application providing a user interface. It manages access permissions, keys, and addresses, tracks balances, and creates and signs transactions. The most critical function is safeguarding the private key—losing or exposing it risks theft or permanent loss of Bitcoins.

Does a wallet contain Bitcoins? No, a wallet only holds keys, not the Bitcoins themselves.

So, where are your Bitcoins? Your Bitcoins are the unspent transaction outputs (UTXOs) tied to your account addresses. The wallet monitors outputs sent to your public key addresses. For example, if Alice sends you 1 Bitcoin and Bob sends you 9 Bitcoins, and you haven’t spent them, your wallet calculates a balance of 10 Bitcoins. When you want to send Bitcoins to someone else, you create a transaction using your UTXOs as inputs, specify the recipient’s address as the output, set the transfer amount, include your public key, and sign the transaction with your private key. Once broadcast to the Bitcoin network and confirmed, the transfer is complete.