1. Describe a Bitcoin block
Bitcoin¶
Quick summary¶
peer-to-peer network of cooperating nodes. These nodes listen for transactions, order them into subsequent blocks and then publish these blocks on the network. Digital signatures of transactions are used to verify the ownership of funds, and a Proof-of-Work system based on hashing is used to rule out double-spending
Bitcoin protocol¶
- No need for trust because of Proof-of-Work
Workflow¶
- New transactions are broadcast in the network by clients.
- Nodes gather incoming transactions into a block.
- Each node starts finding a Proof-of-Work for the block being currently created.
- Once any node finds the Proof-of-Work for the block, the node broadcasts the block in the network.
- Other nodes accept this block only if all transactions in it are valid and not already spent.
- Nodes express their acceptance of the block by starting to create another block on top of the received one, using the hash of the received block in the one currently being created.
Wallet¶
- Public and private key pair
- User can generate the wallet without any confirmation from the blockchain
- Public key is wallet address
- Private key is used to sign transactions
- Modern bitcoin clients generate public/private key pair using a deterministic algorithm using a seed.
Privacy¶
Public¶
- All transaction are public
- If an identity is tied to an address we can track all of the users transaction history
Private¶
- Some (not Bitcoin) cryptocurrencies implement zero-knowladge cryptography for all transaction to be untraceable. This is done using ephemeral addresses
Transaction structure (simplified)¶
- hash of itself
- Every transaction is identified by its hash.
- The implementation uses SHA-256.
- Hash is comprised of the owners private key and the hash of the previous block.
- input Contains the following:
- previous transaction A hash referencing the previous transaction.
- signature The hash of the current transaction is signed with the private key of the owner.
- output Contains the following:
- value The amount of bitcoins that the sender is willing to send.
- receiver’s address The public key of the receiver’s Bitcoin address.
Bitcoin block structure (simplified)¶
- transactions: A list of new transactions recently broadcasted by the network.
- hash of itself: Each block is referenced by this hash. The implementation uses SHA-256.
- previous block hash: A hash referencing the previous block.
- time: A timestamp of the time when the block was created.
- target: A number that determines the difficulty for the Proof-of-Work - explained below.
- nonce: A 32-bit number that serves as the Proof-of-Work - explained below.
Nonce¶
After receiving some transactions (the amount is currently arbitrary), nodes start looking for a value of the nonce such that the hash of the whole block (containing the nonce) is less than the value specified in the current target.
Block validity¶
- Block is valid if all transactions in it are valid
Double spending¶
- A person should wait for a couple of block to make shure that the transaction is valid. Becouse there can be multiple valid blocks and only one of them will "win"