COM S COM S 453X – Spring 2017 Privacy Preserving Algorithms and Data Security Lecture 21: The Block Chain Prof. EWD Rozier 2 COM S Bitcoin today • Bitcoin is a combination of several things: a currency, a payment system, and a collection of algorithms and software implementations. • The goal of bitcoin is to enable payments with low transaction costs. Bitcoin can also sometimes provide anonymity. • One bitcoin (BTC) is worth about $1292. (Two years ago: $162.) • Over 16 million bitcoins have been created (mined) to date. COM S Double spending: why ecash is hard SignA(Transfer X to Bob) Bob Redeem X? BANK Alice SignA(Transfer X to Charlie) Charli e Redeem X? SignZ(Transfer X to Alice) COM S Solution: Maintain a global public append-only log The block chain –a public ledger of all transactions. SignA(Transfer X to B) (In Bitcoin, the log is extended in increments of blocks, each of which may contain thousands of transactions.) SignA(Transfer X to C) COM S Spending a Bitcoin • A transaction is of the form “send these Bitcoins from address Y to address Z” • Specific Bitcoins are described as outputs of previous transactions. • The transaction is signed with the private key of address Y and broadcast, along with the public key of Y, to the payment network • A transaction might also include a transaction fee COM S Bitcoin mining • Every ten minutes, one lucky Bitcoin miner earns a reward for extending the block chain by one block. • In 2009, the reward was 50 BTC. Today it is 25 BTC. (See https://blockchain.info/q to issue queries about the block chain.) • Mining is the only mechanism for creating new bitcoins. The total number of Bitcoins will never exceed 21M. • The rewarded miner also receives all (optional) transaction fees in the block. COM S How is a new block created? • A Bitcoin miner creates a block by Gathering a set of pending transactions, prioritizing those with transaction fees (2) Verifying the transactions (3) Solving a hashing problem (1) https://blockchain.info/q bmm COM S How is a transaction verified? • “send these Bitcoins from address Y to address Z” • The miner first checks the signature using the public key for address Y. compute hash of public key for Y, which should be Y check signature of transaction using public key for Y • • • Then the miner checks the public ledger to verify that Y hasn’t already sent these Bitcoins to someone else. bmm COM S The Hashing Problem • (1) (2) (3) (4) To extend the blockchain, a miner creates a new block, containing: hash of previous block new transactions to include in the blockchain creation of reward bitcoins (e.g., 25 new BTC) nonce • Block is valid if hash of (1)-(4) ends in enough zeroes, as determined by current difficulty. Miner has to find the right nonce by trial and error! • Difficulty chosen so that the time until the first miner wins is about ten minutes, on average. COM S Difficulty adjustment 2 weeks JB COM S bitcoinwisdom Transaction Confirmations • A transaction is said to have received k confirmations if it has been published in a block that has been added to the blockchain, and k-1 more blocks have also been added. • A transactions is typically considered “confirmed” once it has 6 confirmations. • Newly minted Bitcoins are typically considered confirmed once they have received 100 confirmations. bmm COM S A fork can occur when two miners publish blocks simultaneously. Such blocks are almost always in conflict. Give reward to X. Give reward to Y. Give reward to Z. COM S Effort spent on a fork that eventually loses is wasted. Give reward to X. Give reward to Y. Give reward to Z. COM S To break ties, choose branch with greater number of zeros in hash. SHA-256(BlockN-1, n) = 0x00000000000000008c71 Give reward to X. Give reward to Y. SHA-256(BlockN-1, n) = 0x00000000000046a3f89... Give reward to Z. COM S More generally, longest chain wins. SignA(Transfer X to B) Where length is measured in terms of sum of difficulties of blocks in chain. COM S Focusing on the Blockchain • More generally the blockchain is a special kind of distributed database. • Continuously growing list of ordered records (blocks). • Blocks contain timestamps, and link to prior block. COM S Focusing on the Blockchain • • Requirements: • Peer-to-peer network • Distributed timestamping server Forms an “open distributed ledger” COM S Focusing on the Blockchain • Blockchain properties: • Verifiable • Permanent • Distributed COM S Stigmergy • Stigmergy is the underlying mechanism of the blockchain • Provide consensus for indirect coordination. • Avoids need of central coordinator • Potential pitfalls? • Potential benefits? 20 COM S Bitcoin Whitepaper – 2008.10.31* COM S Arriving at Consensus • • • Although the accepted chain can be considered a list, the block chain is best represented with a tree. The longest path represents the accepted chain. A participant choosing to extend an existing path in the block chain indicates a vote towards consensus on that path. The longer the path, the more computation was expended building it. COM S Consensus Process = Mining • • • • Originally the digital wallet could also participate in the consensus process by attempting to secure the network directly This process is known as “mining” Mining involves attempting to find a numerical value, known as a “nonce” that when combined with all open transactions can be “hashed” into a value that satisfies a certain “difficulty” Custom, purpose built-hardware has long since replaced the function such that its no longer productive for simple CPU based systems to compete in the mining process, and thus it was removed COM S Hashcash (Or How to Pay a Byzantine Generals Salary) • • • • • Like many great ideas to become realized, it takes a confluence of other great ideas Based on the idea of HashCash, a Proof of Work concept invented by Adam Back in 1997 (http://www.hashcash.org/papers/hashcash.pdf) Originally proposed as an anti-spam throttling mechanism The core idea is that before accepting a transaction, the sender must first demonstrate a “cost” via a computationally “hard” problem that can simultaneously be easily verified. This generally referred to as a “Proof of Work” COM S The Role of Hashing • • • A hash function is any function that can be used to map digital data of arbitrary size to digital data of fixed size, with slight differences in input data producing very big differences in output data. MD5, SHA1, SHA256 For example, the MD5 hashes of ‘abc’ compared to ‘abC’ abc 0bee89b07a248e27c83fc3d5951213c1 abC 2217c53a2f88ebadd9b3c1a79cde2638 “The Quick Brown Fox Jumped Over the Lazy Dog” 2dfd75162490ed3b4c893141f9ab37cf COM S Proof of Work • • • A publicly auditable cost-function can be efficiently verified by any third party without access to any trapdoor or secret information. A fixed cost cost-function takes a fixed amount of resources to compute. The fastest algorithm to mint a fixed cost token is a deterministic algorithm. A probabilistic cost cost-function is one where the cost to the client of minting a token has a predictable expected time, but a random actual time as the client can most efficiently compute the cost-function by starting at a random start value. Sometimes the client will get lucky and start close to the solution. COM S The Hash Lottery • • • • • Hashing is straightforward, but not challenging Unless the goal is to say, find me a hash value that satisfies a certain level of “difficulty” For example, let’s say the challenge is find a hash-value that begins with a number of zeros, for a given input The Proof of Work comes from finding a number (known as a NONCE) that when added to the input changes the output of the hash value to satisfy the difficulty. In the Bitcoin world this is what “mining” is and in effect is little more than a lot of hash-power spent on guessing winning lottery numbers that satisfy the difficulty of the problem in order to obtain the reward from the network COM S The Payout • • • • The node that finds the best solution to the challenge is provisionally granted a reward Originally in Bitcoin it was 50 new coins Competing solutions are evaluated based on which node offers the higher number of transactions included in the candidate block as well as the level of over-satisfying the difficulty. For example, if two nodes offer a solution to the challenge and both have the same number of transactions, the reward will go to the node that found a NONCE that beat the challenge • E.G. Find a hash that begins with 4 zeros • The node that supplies a hash that has 5 zeros beats the node that only finds the minimum COM S Transaction Confirmation • • • • • Having a transaction provisionally accepted into a candidate block signals that the network has verified that the inputs were viable Every new block accepted into the chain after the transaction was accepted is considered a confirmation Coins are not considered mature until there have been 6 confirmations (basically an hour assuming a 10 minute block cadence) New Coins created by the mining process are not valid until about 120 confirmations This is to assure that a node with more than 51% of the total hash-power does not pull off fraudulent transactions COM S Why 51% Matters • “When does 1 + 1 = 3 ?” * • In the case of Bitcoin “consensus” goes to the chain with the highest number of blocks • Not just in theory, but in practice several large mining pools have generated six blocks in a row • To date the network has voluntarily shifted its mining power around or faced Distributed Denial of Service attacks * When everyone says it does! COM S Other Uses of Blockchain Technology • • • • • Registeries Authoritative Systems of Record Directory Services Timestamping Services (“Proof of Existence”) Counter-party Exchanges COM S Registries COM S What the Blockchain enables • Collaboration without particular confidence. • No trusted 3rd party. • No trusted central authority. 33 COM S Network Structures 34 COM S What the Blockchain enables • • • • Shared Trusted Public Compromising the Blockchain requires manipulation of data on the majority of machines, over a number of blocks. • Progressive trust. 35 COM S What the Blockchain enables • • Free inspection/auditing of the public ledger. No single user controls the ledger • Fault-tolerance • Tamper evidence • Non-revocation 36 COM S COM S
© Copyright 2026 Paperzz