Episode 5: How Do Digital Signatures Work?
Episode 5: How Do Digital Signatures Work?### How a Bitcoin Wallet Works
In Episode 3, we used a simplified representation of Anna’s wallet:
Anna’s wallet
Bitcoin 1.0 BTCThat was sufficient to explain a Bitcoin payment.
Now we take a closer look: How does Bitcoin get into Anna’s wallet — and how can Anna spend it again?
Anna Creates a Wallet
When Anna creates her wallet, a key pair and an associated Bitcoin address are generated.
Anna’s wallet
Bitcoin address
Public key
Private keyEach component has its own purpose:
Bitcoin address Receive Bitcoin
Private key Sign a transaction
Public key Verify a signatureAnna can share her Bitcoin address.
The private key remains in her wallet and must never be shared with anyone.
Anna Receives Bitcoin
Anna gives Anne her Bitcoin address.
Anne uses this address as the recipient of a transaction:
New transaction
Amount 1.0 Bitcoin
Recipient Anna’s Bitcoin addressAfter the transaction has been verified and stored in a block, the blockchain contains an available amount for Anna’s address:
Available amount
Address Anna’s Bitcoin address
Amount 1.0 BitcoinAnna’s wallet recognizes that this address belongs to it and displays the amount:
Anna’s wallet
Bitcoin 1.0 BTCThe Bitcoin was not transferred to Anna’s device as a file. The amount remains recorded in the blockchain.
The wallet displays it because it manages the associated address and the corresponding keys.
Anna Wants to Spend Bitcoin
Anna now wants to send 0.3 Bitcoin to Paul.
Her wallet creates a new transaction:
New transaction
Uses 1.0 Bitcoin from Anna
To Paul 0.3 Bitcoin
Back to Anna 0.6999 Bitcoin
Fee 0.0001 BitcoinBefore the network can accept this transaction, it must answer one question:
*Was the transaction authorized by the wallet that belongs to Anna’s address?*Anna’s wallet uses the private key for this purpose.
The Digital Signature
Anna’s wallet uses the transaction and her private key to calculate a digital signature.
Transaction
- private key ↓ Digital signatureThe signature is valid only for this exact transaction.
Anna’s wallet then sends the following information to the Bitcoin network:
Transaction
Digital signature
Public keyThe private key is not transmitted. It remains in Anna’s wallet.
The First Check
The Bitcoin was previously sent to Anna’s address.
The node must therefore first verify that the included public key belongs to this address.
There is a verifiable connection between Anna’s public key and her Bitcoin address. In simplified terms, the address is created from a hash of the public key.
Public key
↓
Calculate hash
↓
Bitcoin addressThe node performs this calculation itself.
Included public key
↓
Calculate Bitcoin address
↓
Compare with the existing addressIf the addresses match, the node knows:
This public key belongs to the address to which the amount was assigned.### The Second Check
The node now uses the public key to verify the digital signature.
Transaction
- digital signature
- public key ↓ Verify signatureIf the signature is valid, the node knows:
*The wallet containing the associated private key authorized this transaction.*Both necessary connections have now been verified:
Public key
belongs to Anna’s address
↓
Digital signature
belongs to the transaction
↓
Anna may spend the amount### Two Keys That Belong Together
The private key and public key form a key pair.
The public key can be used to verify a signature. A new signature can only be created with the private key.
The private key cannot be calculated from the public key. Anna’s wallet can therefore send the public key together with the transaction without revealing the private key.
This method of using two different but related keys is called asymmetric cryptography.
Is There a Key Server?
Bitcoin does not require a key server or a central directory of public keys.
When Anna receives Bitcoin, she shares only her Bitcoin address:
Receive Bitcoin
Anna shares her addressWhen she later spends the amount, her wallet sends the public key and digital signature with the transaction:
Spend Bitcoin
Public key is included
Digital signature is includedEvery node can perform the necessary checks independently.
A Wallet Can Have Many Addresses
For our explanation, we use only one address and one key pair.
A modern wallet can manage multiple addresses and their associated keys.
Anna’s wallet
Address 1 Key pair 1
Address 2 Key pair 2
Address 3 Key pair 3The wallet determines the available amounts belonging to all of its addresses and displays the total to Anna.
What Happens If the Wallet Is Lost?
If Anna’s device breaks, the Bitcoin does not disappear. The amounts remain recorded in the blockchain.
However, Anna needs her private keys to spend those amounts.
When a wallet is created, it therefore usually displays a sequence of twelve or 24 words. This is called a recovery phrase or seed phrase.
A wallet can derive its keys and addresses again from this phrase.
Recovery phrase
↓
Restore keys
↓
Restore accessAnyone who possesses the recovery phrase can restore the wallet on another device and spend the associated Bitcoin.
There is no central authority that can reset a lost recovery phrase.
Signing Is Not Encryption
Encryption is intended to hide content.
A digital signature is intended to prove that specific data was authorized with the corresponding private key.
Bitcoin transactions are not normally secret. They are distributed across the network and stored in the public blockchain.
The digital signature does not hide the transaction. It allows the nodes to verify that the wallet containing the corresponding private key authorized the transaction.
We now know what Anna’s wallet actually does: It manages the addresses and keys that allow Anna to receive and spend Bitcoin.
In Episode 6, we see how Beaver Proof uses the Bitcoin blockchain to prove that a file already existed at a particular time and has not been changed since.
Top comments (0)