Study notesWeek 10: Wallets, Security And Custody
Week 10 / Blockchain from zero

Wallets, Security And Custody

Week 10 · Blockchain

What You Can Do By The End

Week 10 · Blockchain

Whoever Holds The Key Holds The Asset

Week 10 · Blockchain

Seed Phrases

Week 10 · Blockchain

Backing Up A Phrase

Custody

Who Holds The Keys?

ModelKeys held by
ExchangeThe company
Software walletYou
Hardware walletYou, offline
MultisigSeveral parties
Week 10 · Blockchain

Hardware Wallets

computer:  builds transaction
device:    shows to, amount, fee
you:       press confirm
device:    signs, key never leaves
Week 10 · Blockchain

Multisignature Wallets

Week 10 · Blockchain

How Phishing Works

Week 10 · Blockchain

Connect, Sign, Approve

Week 10 · Blockchain

Reduce The Damage

Contract bug

Reentrancy: The Vulnerable Vault

function withdraw() external {
    uint256 amount = balances[msg.sender];
    require(amount > 0, "nothing");
    (bool ok, ) = msg.sender.call{value: amount}("");
    require(ok, "send failed");
    balances[msg.sender] = 0;
}
Week 10 · Blockchain

Reentrancy: The Fix

function withdraw() external {
    uint256 amount = balances[msg.sender];
    require(amount > 0, "nothing");
    balances[msg.sender] = 0;
    (bool ok, ) = msg.sender.call{value: amount}("");
    require(ok, "send failed");
}
Week 10 · Blockchain

Other Common Bugs

BugIdea
ReentrancyCall back before state update
Access controlMissing owner check
OverflowNumber wraps around
Week 10 · Blockchain

What An Audit Can And Cannot Say

Week 10 · Blockchain

Recap

Week 10 · Blockchain

Next Week: Real-World Use And Regulation

Week 10 · Blockchain

Questions And Exercise