9 - Using Hash Functions for blockchain Flashcards
Permissionless Blockchain
Anybody can join, identity and number of users not required
Permissioned Blockchains
Users are checked/authorised
General principles of blockchain
- Decentralised database (all participants keep ledger copy of all data)
- Data organised in blocks
- Blocks form chain
- New data is collected in new block and added to end
- Blocks NEVER deleted
Each block has a hash of what?
The previous block
Creates agreement between blocks and tampering etc
If someone changes data in a block, what happens?
They need to change the hashes all the way forward in the blocks. (all blocks after).
Everyone else must also agree though either by collusion of more than 50% agreeing or proof of work
Typically, data put in blockchain is authenticated by…
digital signatures
Proof Of Work
Ensures a valid message can only be created by spending a certain amount of resources
Using a hash function H for proof of work
- message m, append a nonce r (random string of bits, small fixed length)
- Compute H(m||r)
- Check if resulting hash conforms to a pattern (eg 20 zeroes start). If not, repeat with another r.
Requires trying many nonces r.
Publish m||r with success
Bitcoin miner
- Takes list of transactions
- checks they are valid (sig genuine and bitcoin not spent)
- Builds new block
They compute a “proof-of work” for that block and write the successful nonce as a block field.
- Successful nonce is broadcast by whoever finds it first.
Bitcoin miner: what do other participants do when successful block found?
- Check it’s valid by checking the transactions and proof-of-work.
- Add block to their copy of blockchain
Using proof of work for anti spam
- sender must produce nonce r that H(m||| address || r) satisfies the condition (pattern etc)
- Required for each individual email address sent to, so cost is proportional to recipients