Bitcoin Whitepaper13 Jun 2018 • Leave Comments
p2p timestamp system
- chronological cryptography vs trust on 3rd party institution;
- solve double-spending issue;
- depends on the fact that honest nodes collectively outpace attacker nodes;
- we mine a block (and get coin reward) istead of a coin; bitcoins are created each time a user discovers a new block.
- coin is defined as a set of transactions digitally signed; payee can verify the payer and cannot verify whether it's the earliest transaction, thus cannot exclude double-spending;
- all transactions are publicly announced;
- a transaction has inputs (several) and outputs (at most 2). Inputs are existing outputs from other transactions for you. Hence, transaction actually takes outputs for you and then generate new outputs, one of which is for payee and the other is for change. The remaining (sum of inputs minus sum of outputs) is Bitcoin fee.
- we need 'change' because outputs cannot be partially spent. You can only spend your output as a whole, which explains why we could have 'change' output.
- wallet (account balance) of a peer (identified by private key) is derived from all transaction outputs for his public key, namely 'pay-to-pubkey-hash' transactions.
- To get the concept of transactoin, read https://bitcoin.stackexchange.com/a/20623 and https://bitcoin.stackexchange.com/q/736
block reward = block subsidy + transactions fees
- another hash on the whole transaction block;
- each item in the block consists of a transaction and timestamp thereof; transaction items in a block are usually unrelated.
- payee can verify it is the earliest and not a double-spending transaction. kick out double-spending transaction.
- announce the hash and timestamp together.
- how to hash? simple sha-256 is not enough! Add nonce to find a special hash value that starts with a number of zero bits. The number is increased overtime (more and more difficult).
- proof-of-work is where our 'mining resources' are invested and represented by 'minining resources' invested.
- proof-of-work is deliberately designed to avoid double-spending such that attacker cannot catch up.
- Nodes compete to confirm a transaction, namely compete to tally!
p2p networking process
- new transaction is simply hashed and signed before announcement.
- a block (local copy) comprises a set of transaction items, previous hash, nounce. received transaction along with timestamp are inserted into the transaction set.
- difficult hash computational work for block, namely proof-of-work.
- success! a peer announces hash and the block.
- other peers verify and accept the block.
- other peers create a new block by replacing the 'Prev Hash' field and announce it.
Conceptually, there is only one valid (of course longest) blockchain over the network. But techniquely, there exist mutiple blockchains simutaneouly due to node joining/leaving, network latency, forks etc.
- Timestamp is acutally not critical element since attacker node can forge local time. Instead, the longest blockchain is accepted while other candidates are discarded.
- Currently, user confirm a transaction if it buried over 6 (included) blocks. 6 blockes are enough to avoid catching up by powerful attacker. If an attacker double-spends coins by signing second transaction immediately (say one to Alice and another to Bob), only one of them (say that to Bob) is accepted when it is buried in a longer blockchain.
- It is not really the Proof of Work which prevents double spends but rather the blockchain itself which prevents double spends. The Proof of Work is just one aspect of the blockchain.
Freshly-mined coins cannot be spent for 100 blocks. It is advisable to wait some additional time for a better chance that the transaction will be propagated by all nodes. Some older bitcoin clients won't show generated coinsas confirmed until they are 120 blocks deep.
Blockchain forks might cause oprphan blocks. Suppose a block owner spends the subsidy and rewards (newly coins), and get 6 confirmations. However, 6 is too small to guarantee that the new block would finally merged into mainnet. Maybe this block will be orphaned and newly coins disappear as well.
The key is that transaction with coinbase coins input has no source! We cannot track back! For transaction with old coins input, we can track back to other transaction output. Even though the block container become orphan, it will be confirmed by other block afterwards.
- the first transaction in a block is a special transaction that starts a new coin owned by the creator of the block; the transaction set is empty.
- transaction fees; fee is given to the peer that achieve 'proof-of-work' - the one that find a block. Bitcoin fee is fixed independently of the amount of coins.
- attacker with more mining resources probably chooses to be honest as that would earn more coins than stealing.
- peer public key is anonymous though transactions are public.
- Bitcoin amount limit would fail in deflation spiral. But that is not a problem as Bitcoin cannot be global currency.
- Currently, miners mine bitcoins assuming price increase in the future.
- People use bitcoins to bypass censorship.
- 矿池，asic hwardware node;
- 挖矿，mine, proof-of-work, hash with leading zeros;
- asic hardware;
- testnet for fun;
- p2p timestamp? what if fake node time?
- centralized Bitcoin exchange?
- how many bits of a hash is required?
- Bitcoin: A Peer-to-Peer Electronic Cash System