<<

Blockchain for Dummies Documentation

Nguyen Tran Ho Thanh Son

Jul 03, 2018

Contents

1 Contents 3 1.1 and ...... 3 1.1.1 What is a blockchain?...... 3 1.1.2 What is the difference between Bitcoin and Blockchain?...... 3 1.1.3 What is Bitcoin?...... 3 1.1.4 How Bitcoin works?...... 4 1.1.4.1 Transactions...... 4 1.1.4.2 Independent Verification of Transactions...... 5 1.1.4.3 Aggregation of Verified Transactions...... 5 1.1.4.4 Constructing a Block Header...... 6 1.1.4.5 Mining of a Block...... 7 1.1.4.6 Finding the Puzzle- Why is it hard?...... 7 1.1.4.7 Difficulty Representation...... 7 1.1.4.8 Successfully Mining the Block...... 8 1.1.4.9 Independent Confirmation of Each Block...... 8 1.1.4.10 Assembling and Selecting Chains of Blocks...... 8 1.1.4.11 Miners Reward...... 9 1.1.4.12 Several Branches...... 9 1.1.4.13 What if Someone tries to Hack the System?...... 11 1.1.5 Bitcoin’s network in one infographic...... 13 1.2 Frequently Asked Questions...... 14 1.2.1 Questions...... 14 1.2.1.1 Who is in control of Bitcoin?...... 14 1.2.1.2 How does one acquire ?...... 14 1.2.1.3 What does “synchronizing” mean and why does it take so long?...... 15 1.2.1.4 What is a consensus algorithm and why is it useful in blockchain?...... 15 1.2.1.5 What is the difference between a public and private/consortium ?.... 15 1.2.1.6 If the Bitcoin’s database is on my computer, can I add 1000 of BTC in my wallet?. 16 1.2.1.7 Why do I have to wait for confirmation?...... 16 1.2.1.8 How much will the transaction fee be?...... 16 1.2.1.9 What if I receive a bitcoin when my computer is powered off?...... 17 1.2.1.10 How does mining help secure Bitcoin?...... 17 1.2.1.11 What do I need to start mining?...... 17 1.2.1.12 Hasn’t Bitcoin been hacked in the past?...... 17 1.3 Glossary...... 18

i ii Blockchain for Dummies Documentation

The goal of this documentation is to introduce you to blockchain technology. The content of the document is copied and collected on internet. It’s just for study purpose.

Contents 1 Blockchain for Dummies Documentation

2 Contents CHAPTER 1

Contents

1.1 Blockchain and Bitcoin

1.1.1 What is a blockchain?

A Blockchain is a kind of database: while a normal database is located on a server, a blockchain is distributed among the software users. For example, the Facebook’s database is located on a protected server and no one can access the information. The Bitcoin’s blockchain instead is located on servers and computers (called nodes) of all the Bitcoin users. All the transactions that occur between ewallets are stored on the bitcoin’s blockchain. All the servers and the com- puters that are using bitcoin have the same copy of the blockchain stored on their hard disk. There are many kinds of blockchain with different features, like , , Ripple. Some of them are more suitable to handle currency, others are used to transfer the ownership of assets (eg supply chain). You don’t need to download all the blockchain to your computer in order to use Bitcoin (or any other blockchain technology) as the current size of Bitcoin’s blockchain is over 160 GB and it can easily drain the resources of your computer. To avoid this issue there are different types of e-wallets (we will talk about them later). Source: http://www.ledgerprojects.com/blockchain-for-dummies/

1.1.2 What is the difference between Bitcoin and Blockchain?

Blockchain is the technology behind Bitcoin: Bitcoin cannot exist without a blockchain. It is like Internet and Facebook: Facebook cannot exist without Internet. Source: http://www.ledgerprojects.com/blockchain-for-dummies/

1.1.3 What is Bitcoin?

Simply put, bitcoin is a . No bills to print or coins to mint. It’s decentralized – there’s no government, institution (like a bank) or other authority that controls it. Owners are anonymous; instead of using names, tax IDs, or

3 Blockchain for Dummies Documentation social security numbers, bitcoin connects buyers and sellers through keys. And it isn’t issued from the top down like traditional currency; rather, bitcoin is “mined” by powerful computers connected to the internet. Source: https://www.cnet.com/how-to/what-is-bitcoin/

1.1.4 How Bitcoin works?

1.1.4.1 Transactions

Let’s try to understand how blockchain works with a simple transaction over a Blockchain network.

Suppose James wants to send 5 BTC to his friend Kevin. Now, this transaction is broadcasted in the form of a digital message.

The digital message has a unique signature. Just like your signature provides the proof of ownership of the document, similarly, provides the proof that the transaction is genuine. Now this generated transaction is broadcasted to the network where it propagates peer to peer.

Suppose the above transaction is first received by node A in the network.

4 Chapter 1. Contents Blockchain for Dummies Documentation

1.1.4.2 Independent Verification of Transactions

Before sending transactions to its neighbors, each bitcoin node that gets the transaction will initially verify the trans- action.

This guarantees only valid transactions are propagated across the system while invalid transactions are disposed of at the first node which receives them. Every node confirms each transaction against a long agenda of criteria.

1.1.4.3 Aggregation of Verified Transactions

Independent aggregation of those transactions into new blocks by mining nodes combined with exhibited calculation through a proof-of-work algorithm.

1.1. Blockchain and Bitcoin 5 Blockchain for Dummies Documentation

• By autonomously confirming every transaction as it is received and before propagating it, each node fabricates a pool of valid (however unconfirmed) transactions known as the transaction pool, memory pool or mempool • Transaction reaches Mining nodes it collects, validates, and relays new transactions just like other nodes • Unlike other nodes, miner node will then aggregate these transactions into a candidate block Let’s understand this better with an example. Let’s say Andy is a miner. (A mining node maintains a local copy of the blockchain, the list of all blocks created since the beginning of the bitcoin system in 2009)

Now, after collecting all the transactions in a block, Andy needs to construct the block header. Now this step is important to understand how blockchain works

1.1.4.4 Constructing a Block Header

To construct the block header, the mining node needs to fill in six fields, as listed in the table:

Size Field Description 4 bytes Version To construct the block header, the mining node needs to fill in six fields, as listed 32 bytes Previous Block A reference to the hash of the previous (parent) block in the chain Hash 32 bytes Merkle Root A hash of the root of the Merkle tree of this block’s transactions 4 bytes Timestamp The approximate creation time of this block (seconds from Unix Epoch) 4 bytes Difficulty Target The proof-of-work algorithm difficulty target for this block 4 bytes Nonce A counter used for the proof-of-work algorithm

6 Chapter 1. Contents Blockchain for Dummies Documentation

Once Andy’s node has all the fields filled in the block header, Andy started Mining the block.

1.1.4.5 Mining of a Block

• With all the other fields filled, the block header is now complete and the process of mining can begin • The goal is now to find a value for the nonce that results in a block header hash that is less than the difficulty target • The mining node will need to test billions or trillions of nonce values before a nonce is found that satisfies the requirement Now that a candidate block has been constructed by Andy’s node, it is time for Andy’s hardware mining rig to “mine” the block, to find a solution to the proof-of-work algorithm that makes the block valid. is a piece of data which is difficult(costly, time-consuming) to produce but easy for others to verify and which satisfies certain requirements.

1.1.4.6 Finding the Puzzle- Why is it hard?

• The SHA-256 is a one-way function(hash) hence, brute force is the only way to a particular output value • On an average, it takes many random guesses to find a solution and thus the challenge is tough • It takes around 10 minutes on an average for someone to find the special to the solution To keep the coin distribution predictable, puzzles becoming increasingly difficult to solve when more people work on them. Now, to validate the block according to the proof-of-work algorithm, Andy’s mining node has to reach the difficulty target.

Let’s see how the difficulty is represented.

1.1.4.7 Difficulty Representation

• The block contains the difficulty target, in a notation called “difficulty bits” or just “bits“ • Let’s say a block has 0x1903a30c as the difficulty bits. This notation expresses the difficulty target as a coeffi- cient/exponent format, with the first two hexadecimal digits for the exponent and the next six hex digits as the coefficient

1.1. Blockchain and Bitcoin 7 Blockchain for Dummies Documentation

The formula to calculate the difficulty target from this representation is:

So, such is the difficulty coefficient that Andy’s mining node has worked really hard to reach the difficulty target. Let’s see what happens next.

1.1.4.8 Successfully Mining the Block

• Andy has several hardware mining rigs, each running the SHA256* algorithm in parallel at incredible speeds • The mining node running on Andy’s desktop transmits the block header to his mining hardware, which starts testing trillions of nonces per second • Almost 11 minutes after starting to mine block, one of the hardware mining machines finds a solution and sends it back to the mining node • Immediately, Andy’s mining node transmits the block to all its peers • They receive, validate, and then propagate the new block. As the block ripples out across the network Now that that block is propagated in the network, each full nodes independently verifies the block

1.1.4.9 Independent Confirmation of Each Block

• In bitcoin’s consensus mechanism, each new block is validated independently by every node on the network • This ensures that only valid blocks are propagated on the network • Nodes validate the block by checking it against a long list of criteria that must all be met

1.1.4.10 Assembling and Selecting Chains of Blocks

Once a node has validated a new block, it will then attempt to assemble a chain by connecting the block to the existing blockchain

In the network shown above, once the node (in orange) validates the block, it assembles the chain by connecting the block to the existing blockchain Once the block is verified by the network, it becomes the part of the blockchain and for successfully solving the block puzzle the miner is rewarded.

8 Chapter 1. Contents Blockchain for Dummies Documentation

1.1.4.11 Miners Reward

• Since Miners use their valuable resources to validate the block, they are given a monetary award • In case of Bitcoin, they get some newly created Bitcoins as a reward

Now, the question arises, what happens in the case when more than one block gets solved at the same time? Yes, this is possible indeed! In such case, several branches exist.

1.1.4.12 Several Branches

• Although the problem is tough, however, there are chances that more than one block will be solved at the same time • Several branches in the blockchain are possible in such cases • Everyone should simply build the blocks on top of the first block that they receive

• Other Nodes may have received the blocks in a different order • They will be building on the block they first receive

1.1. Blockchain and Bitcoin 9 Blockchain for Dummies Documentation

• The tie gets broken when someone solves the next block because it is very rare for this situation to happen multiple times in a row

• Blockchain quickly stabilizes in this situation • The general rule is to switch to the longest chain available

10 Chapter 1. Contents Blockchain for Dummies Documentation

The Blockchain quickly Stabilizes. Every node is in agreement with the current state of the .

Alright, so consensus rules save the blockchain network from such ambiguity. Now, another question arises here, what if someone tries to alter any transaction or records in the system?

1.1.4.13 What if Someone tries to Hack the System?

Once a block is solved the cryptographic hash output becomes the identifier of that block.

1.1. Blockchain and Bitcoin 11 Blockchain for Dummies Documentation

Since Blockchain is a back-linked distributed database of records. When a block is formed, the cryptographic hash output becomes the identifier of that block, which ties into the next block, creating a chain of blocks.

Hence, the blockchain is secured by the strong cryptographic algorithm and there is no way to alter any record. If someone tries to alter any transaction in any of the blocks, the hash of the block changes and consequently hash of all the previous blocks will change. The nodes will not arrive at **the consensus and hence, the fraud can easily be detected**

12 Chapter 1. Contents Blockchain for Dummies Documentation

Source: https://www.edureka.co/blog/how-blockchain-works/

1.1.5 Bitcoin’s network in one infographic

1.1. Blockchain and Bitcoin 13 Blockchain for Dummies Documentation

Source: https://bitsonblocks.net/2016/03/14/bitcoins-network-in-one-infographic/

1.2 Frequently Asked Questions

• Questions – Who is in control of Bitcoin? – How does one acquire bitcoins? – What does “synchronizing” mean and why does it take so long? – What is a consensus algorithm and why is it useful in blockchain? – What is the difference between a public and private/consortium blockchains? – If the Bitcoin’s database is on my computer, can I add 1000 of BTC in my wallet? – Why do I have to wait for confirmation? – How much will the transaction fee be? – What if I receive a bitcoin when my computer is powered off? – How does mining help secure Bitcoin? – What do I need to start mining? – Hasn’t Bitcoin been hacked in the past?

1.2.1 Questions

1.2.1.1 Who is in control of Bitcoin?

Nobody owns the much like no one owns the technology behind email. Bitcoin is controlled by all Bitcoin users around the world. While developers are improving the software, they can’t force a change in the Bitcoin protocol because all users are free to choose what software and version they use. In order to stay compatible with each other, all users need to use software complying with the same rules. Bitcoin can only work correctly with a complete consensus among all users. Therefore, all users and developers have a strong incentive to protect this consensus. Source: https://bitcoin.org/en/faq#who-controls-the-bitcoin-network

1.2.1.2 How does one acquire bitcoins?

• As payment for goods or services. • Purchase bitcoins at a Bitcoin exchange. • Exchange bitcoins with someone near you. • Earn bitcoins through competitive mining. While it may be possible to find individuals who wish to sell bitcoins in exchange for a credit card or PayPal payment, most exchanges do not allow funding via these payment methods. This is due to cases where someone buys bitcoins with PayPal, and then reverses their half of the transaction. This is commonly referred to as a chargeback. Source: https://bitcoin.org/en/faq#how-does-one-acquire-bitcoins

14 Chapter 1. Contents Blockchain for Dummies Documentation

1.2.1.3 What does “synchronizing” mean and why does it take so long?

Long synchronization time is only required with full node clients like Bitcoin Core. Technically speaking, synchro- nizing is the process of downloading and verifying all previous Bitcoin transactions on the network. For some Bitcoin clients to calculate the spendable balance of your Bitcoin wallet and make new transactions, it needs to be aware of all previous transactions. This step can be resource intensive and requires sufficient bandwidth and storage to accommo- date the full size of the block chain. For Bitcoin to remain secure, enough people should keep using full node clients because they perform the task of validating and relaying transactions. Source: https://support.bitxoxo.com/hc/en-us/articles/208411029-What-does-synchronizing-mean-and-why-does-it-take-so-long-

1.2.1.4 What is a consensus algorithm and why is it useful in blockchain?

A consensus algorithm is a process in computer science used to achieve agreement on a single data value among distributed processes or systems. Consensus algorithms are designed to achieve reliability in a network involving multiple unreliable nodes. Solving that issue – known as the consensus problem – is important in distributed computing and multi-agent systems. To accommodate this reality, consensus algorithms necessarily assume that some processes and systems will be un- available and that some communications will be lost. As a result, consensus algorithms must be fault-tolerant. They typically assume, for example, that only a portion of nodes will respond but require a response from that portion, such as 51%, at a minimum. Applications of consensus algorithms include: Deciding whether to commit a distributed transaction to a database. Designating node as a leader for some distributed task. Synchronizing state machine replicas and ensuring consistency among them. Consensus algorithms support many real-world systems including Google’s PageRank, load balancing, smart grids, clock synchronization and drone control. Blockchain, the most commonly associated with Bitcoin, also relies on consensus algorithms to reach agreement among nodes. A blockchain can be thought of as a decentralized database that is managed by dis- tributed computers on a peer-to-peer (P2P) network. Each peer maintains a copy of the ledger to prevent a single point of failure (SPOF). Updates and validations are reflected in all copies simultaneously. Bitcoin uses the proof of work algorithm (PoW) to ensure security in a trustless network, by including mechanisms that ensure that the effort of mining is represented within the block submitted by the miner. Software on the computers of miners accesses their processing capacity to solve transaction-related algorithms. The block is an encrypted hash proof of work that is created in a compute-intensive process. Although any party can submit a chain of blocks to the ledger, the amount of computing resources required to fake consensus is too great to make it worthwhile to a dishonest party. Other common consensus algorithms include the practical Byzantine fault tolerance algorithm (PBFT), the proof-of- stake algorithm (PoS) and the delegated proof-of-stake algorithm (DPoS). Source: https://whatis.techtarget.com/definition/consensus-algorithm

1.2.1.5 What is the difference between a public and private/consortium blockchains?

• Public blockchains: a public blockchain is a blockchain that anyone in the world can read, anyone in the world can send transactions to and expect to see them included if they are valid, and anyone in the world can participate in the consensus process – the process for determining what blocks get added to the chain and what the current state is. As a substitute for centralized or quasi-centralized trust, public blockchains are secured by cryptoeconomics – the combination of economic incentives and cryptographic verification using mechanisms such as proof of work or , following a general principle that the degree to which someone can have

1.2. Frequently Asked Questions 15 Blockchain for Dummies Documentation

an influence in the consensus process is proportional to the quantity of economic resources that they can bring to bear. These blockchains are generally considered to be “fully decentralized”. • Consortium blockchains: a consortium blockchain is a blockchain where the consensus process is controlled by a pre-selected set of nodes; for example, one might imagine a consortium of 15 financial institutions, each of which operates a node and of which 10 must sign every block in order for the block to be valid. The right to read the blockchain may be public, or restricted to the participants, and there are also hybrid routes such as the root hashes of the blocks being public together with an API that allows members of the public to make a limited number of queries and get back cryptographic proofs of some parts of the blockchain state. These blockchains may be considered “partially decentralized”. • Fully private blockchains: a fully private blockchain is a blockchain where write permissions are kept central- ized to one organization. Read permissions may be public or restricted to an arbitrary extent. Likely applications include database management, auditing, etc internal to a single company, and so public readability may not be necessary in many cases at all, though in other cases public auditability is desired. Source: https://blog.ethereum.org/2015/08/07/on-public-and-private-blockchains/

1.2.1.6 If the Bitcoin’s database is on my computer, can I add 1000 of BTC in my wallet?

The blockchain is famous for its security: once the data is there it is impossible to modify it. The blockchain consists of a chain of blocks, where every block contains data (for instance a money transactions, documents or personal data). When a new block is to be added to the chain, it has to be verified by the network of nodes first, and once this is done, the transaction can be inserted in the blockchain. There are mining and a consensus protocol standing behind this phase (click here to read more). The blocks are connected with each other in a way that if I edit the content of one block I must edit all the following blocks, moreover to edit a block you need the consensus of other nodes. Hence the more people are using a blockchain, the longer it is and the more secure the system is. Source: http://www.ledgerprojects.com/blockchain-for-dummies/

1.2.1.7 Why do I have to wait for confirmation?

Receiving notification of a payment is almost instant with Bitcoin. However, there is a delay before the network begins to confirm your transaction by including it in a block. A confirmation means that there is a consensus on the network that the bitcoins you received haven’t been sent to anyone else and are considered your property. Once your transaction has been included in one block, it will continue to be buried under every block after it, which will exponentially consolidate this consensus and decrease the risk of a reversed transaction. Each confirmation takes between a few seconds and 90 minutes, with 10 minutes being the average. If the transaction pays too low a fee or is otherwise atypical, getting the first confirmation can take much longer. Every user is free to determine at what point they consider a transaction sufficiently confirmed, but 6 confirmations is often considered to be as safe as waiting 6 months on a credit card transaction. Source: https://bitcoin.org/en/faq#why-do-i-have-to-wait-10-minutes

1.2.1.8 How much will the transaction fee be?

Transactions can be processed without fees, but trying to send free transactions can require waiting days or weeks. Although fees may increase over time, normal fees currently only cost a tiny amount. By default, all Bitcoin wallets listed on Bitcoin.org add what they think is an appropriate fee to your transactions; most of those wallets will also give you chance to review the fee before sending the transaction. Transaction fees are used as a protection against users sending transactions to overload the network and as a way to pay miners for their work helping to secure the network. The precise manner in which fees work is still being developed and will change over time. Because the fee is not related to the amount of bitcoins being sent, it may seem extremely

16 Chapter 1. Contents Blockchain for Dummies Documentation low or unfairly high. Instead, the fee is relative to the number of bytes in the transaction, so using multisig or spending multiple previously-received amounts may cost more than simpler transactions. If your activity follows the pattern of conventional transactions, you won’t have to pay unusually high fees. Source: https://bitcoin.org/en/faq#how-much-will-the-transaction-fee-be

1.2.1.9 What if I receive a bitcoin when my computer is powered off?

This works fine. The bitcoins will appear next time you start your wallet application. Bitcoins are not actually received by the software on your computer, they are appended to a public ledger that is shared between all the devices on the network. If you are sent bitcoins when your wallet client program is not running and you later launch it, it will download blocks and catch up with any transactions it did not already know about, and the bitcoins will eventually appear as if they were just received in real time. Your wallet is only needed when you wish to spend bitcoins. Source: https://bitcoin.org/en/faq#what-if-i-receive-a-bitcoin-when-my-computer-is-powered-off

1.2.1.10 How does mining help secure Bitcoin?

Mining creates the equivalent of a competitive lottery that makes it very difficult for anyone to consecutively add new blocks of transactions into the block chain. This protects the neutrality of the network by preventing any individual from gaining the power to block certain transactions. This also prevents any individual from replacing parts of the block chain to roll back their own spends, which could be used to defraud other users. Mining makes it exponentially more difficult to reverse a past transaction by requiring the rewriting of all blocks following this transaction. Source: https://bitcoin.org/en/faq#how-does-mining-help-secure-bitcoin

1.2.1.11 What do I need to start mining?

In the early days of Bitcoin, anyone could find a new block using their computer’s CPU. As more and more people started mining, the difficulty of finding new blocks increased greatly to the point where the only cost-effective method of mining today is using specialized hardware. You can visit BitcoinMining.com for more information. Source: https://bitcoin.org/en/faq#what-do-i-need-to-start-mining

1.2.1.12 Hasn’t Bitcoin been hacked in the past?

The rules of the protocol and the used for Bitcoin are still working years after its inception, which is a good indication that the concept is well designed. However, security flaws have been found and fixed over time in various software implementations. Like any other form of software, the security of Bitcoin software depends on the speed with which problems are found and fixed. The more such issues are discovered, the more Bitcoin is gaining maturity. There are often misconceptions about thefts and security breaches that happened on diverse exchanges and businesses. Although these events are unfortunate, none of them involve Bitcoin itself being hacked, nor imply inherent flaws in Bitcoin; just like a bank robbery doesn’t mean that the dollar is compromised. However, it is accurate to say that a complete set of good practices and intuitive security solutions is needed to give users better protection of their money, and to reduce the general risk of theft and loss. Over the course of the last few years, such security features have quickly developed, such as wallet encryption, offline wallets, hardware wallets, and multi-signature transactions. Source: https://bitcoin.org/en/faq#hasnt-bitcoin-been-hacked-in-the-past

1.2. Frequently Asked Questions 17 Blockchain for Dummies Documentation

1.3 Glossary

51% attack A condition in which more than half the computing power of a network is controlled by a single malicious miner or group of miners. If he controls 51% of the network that makes him the authority on the network, giving him the power to spend the same coins multiple times, issue transactions that conflict with someone else’s or stop someone else’s transaction from being confirmed Altcoins Altcoin is an abbreviation of “Bitcoin alternative”. Currently, the majority of altcoins are forks of Bitcoin with usually minor changes to the proof of work (POW) algorithm of the Bitcoin blockchain. The most promi- nent altcoin is . Litecoin introduces changes to the original Bitcoin protocol such as decreased block generation time, increased maximum number of coins and different hashing algorithm ASIC An “Application Specific Integrated Circuit” is a silicon chip specifically designed to do a single task. In the case of Bitcoin, they are designed to process SHA-256 hashing problems to mine new bitcoins. ASICs are considered to be much more efficient than conventional hardware(CPUs, GPUs). Using a regular computer for Bitcoin mining is seen as unprofitable and only results in higher electricity bill Bitcoin is a cryptocurrency that runs on a (1) global peer to peer network, is (2) decentralised (no single entity can control it), it’s (3) open source (wallet & transaction verification), (4) bypassing middlemen or central authority, with (5) no issuer or acquirer, (6) anyone with a computer or smartphone can use it Bitcoin ATM A cash point where people can trade fiat currency and bitcoins Block explorer An online tool for exploring the blockchain of a particular cryptocurrency, where you can watch and follow live all the transactions happening on the blockchain. Block explorers can serve as blockchain analysis and provide information such as total network hash rate, coin supply, transaction growth, etc. Block reward An amount of crypto-currency a miner receives for processing transactions in a given block. Because creating (or “mining”) blocks is so crucial to the security of the Bitcoin network and yet so hard, the Bitcoin protocol includes a mechanism to encourage people to mine: every time a block is added, the miner who found the block is given 12,5 BTC(this number will change at the next halving in 2020) as a block reward Blockchain Shared, trusted, public ledger of transactions, that everyone can inspect but which no single user controls. It is a cryptographed, secure, tamper-resistant distributed database. It solves a complex mathematical problem to exist. A blockchain is a perfect place to store value, identities, agreements, property rights, credentials, etc. Once you put something like a Bitcoin into it, it will stay there forever. It is decentralized, disintermediated, cheap and censorship-resistant. Applications of Blockchain: Bitcoin (cryptocurrency), (wants to replace the entire DNS system of the Internet), or Sia (a decentralized cloud storage), Ethereum (Turing complete Virtual Machine where you can run any ); Any centralized service like eBay, Dropbox can potentially be built in a decentralized way using blockchain technology, considerably lowering transaction costs Chain linking Chain linking is the process of connecting two blockchains with each other, thus allowing transactions between the chains to take place. This will allow blockchains like Bitcoin to communicate with other sidechains, allowing the exchange of assets between them Client A software program a user executes on a desktop, laptop or a mobile device to launch an application Classical cryptocurrency mining requires huge investments in hardware and electricity. Cloud mining companies aim to make mining accessible to everybody. People just can log in to a website and invest money in the company which already has mining datacenters. The money is managed by the company and it is invested in mining equipment. Investors get a share of the revenue. The disadvantage for the user is that cloud mining has low returns compared to traditional mining. Consensus (Bitcoin’s Process Consensus) Developers suggest bitcoin improvements/modifications, small or big, proposals on Github, , Reddit, mailing lists, etc. Discussion on this level is critical to enable smooth runtime consensus transitions.Modifications with reference implementations get tested on the testnet. After suc- cessful testing developers implement the changes into the Bitcoin software. Who has a say in the consensus process?: (1) Software Developers (do the reference implementations), (2) Miners (Runtime consensus for min-

18 Chapter 1. Contents Blockchain for Dummies Documentation

ing blocks), (3) Exchanges (They run nodes that validate transactions), (4) Wallet companies (create transactions run on nodes), (5) Merchants (Merchant processing also through nodes) Consensus (general) A fundamental problem in distributed computing is to achieve overall system reliability in the presence of a number of faulty processes. This often requires processes to agree on some data value that is needed during computation. The consensus problem requires agreement among a number of processes for a single data value. Some of the processes may fail or be unreliable in other ways, so consensus protocols must be fault tolerant. The processes must somehow put forth their candidate values, communicate with one another, and agree on a single consensus value. The bitcoin blockchain uses electricity to ensure the security of the system. It creates an economic system where you can only participate by incurring costs, Proof of work (POW). You do that for the possibility of reward/bitcoin. If you spend money, and you play fair by the rules, you get money back. If you cheat, you lose money. It doesn’t pay to cheat. This simple game theoretical equilibrium is the core of the bitcoin consensus algorithm Consortium blockchains A consortium blockchain is a blockchain where the consensus process is controlled by a pre-selected set of nodes; for example, one might imagine a consortium of 15 financial institutions, each of which operates a node and of which ten must sign every block for the block to be valid. The right to read the blockchain may be public or restricted to the participants. There are also hybrid routes such as the root hashes of the blocks being public together with an API that allows members of the public to make a limited number of queries and get back cryptographic proofs of some parts of the blockchain state. These blockchains may be considered “partially decentralized” Cryptographic Hash Function The cryptographic hash function is a mathematical algorithm that takes a particular input which can be any kind of digital data be it a password or jpeg file and produces a single fixed length output. Some examples of different hash function algorithms are MD5, MD4 or SHA256. The last one is used in the Bitcoin protocol. Main properties: (1) easy to compute hash value for any given message (2) infeasible to generate a message from its hash except by trying all possible input combinations(brute force attack) (3) infeasible to modify a message without changing the hash (4) infeasible to find two different messages with the same hash (5) deterministic so the same message always results in the same hash. Cryptographic hash functions have many information security applications, notably in digital signatures, message authentication codes (MACs), and other forms of authentication. They can also be used as ordinary hash functions, to index data in hash tables, for fingerprinting, to detect duplicate data or uniquely identify files, and as checksums to detect accidental data corruption Cryptojacking Cryptojacking is referred as a secret use of a device to mine cryptocurrency. The first widely known attempt for cryptojacking was the torrent tracker Piratebay. They enabled an in-browser mining software so when somebody visits the website his/her computer will start mining cryptocurrency via the browser. Users started noticing the unusual behavior in their browsers and Piratebay took down the software. There have been many attempts for cryptojacking since then. The easiest way to find out if a computer is mining cryptocurrency is to check the resources monitor for unusual CPU behavior or using the debug console of your browser an look for mining scripts. Developers also released Chrome browser extensions to protect users from mining occurring on their devices. Digital Signature Private keys are used for signing transactions. Each time a transaction is sent over the blockchain it gets signed by the user’s private key. The signed transaction is broadcasted over the network together with the corresponding public key. Each miner is able to verify the signature by verifying the signature with the public key. Double Spending Double-spending is the result of successfully spending some money more than once. Bitcoin is the first to implemented a solution in early 2009 which protects against double spending by verifying each transaction added to the blockchain to ensure that the inputs for the transaction had not previously already been spent Fiat currency Any money declared by a government to be to be valid for meeting a financial obligation, like USD or EUR The creation of an ongoing alternative version of the blockchain, by creating two blocks simultaneously on different parts of the network. This creates two parallel blockchains, where one of the two is the winning

1.3. Glossary 19 Blockchain for Dummies Documentation

blockchain. The winning blockchain gets determined by its users, by the majority choosing on which blockchain their clients should be listening Genesis block The very first block in the blockchain Halving A reduction in the block reward given to crypto-currency miners once a certain number of blocks have been mined. The Bitcoin block mining reward halves every 210,000 blocks Hardfork A hardfork is a change to the blockchain protocol that makes previously invalid blocks/transactions valid, and therefore requires all users to upgrade their clients. The most recent example of a hardfork in public blockchains is the Ethereum hardfork which happened on July 21st, 2016. The hardfork changed the Ethereum protocol, therefore a second blockchain emerged (, ETC) which supports the old Ethereum pro- tocol. In order to continue existing ETC needs miners, which would validate the transactions on the blockchain Hashcash is a proof-of-work system used to limit email spam and denial-of-service attacks, and more recently has become known for its use in bitcoin (and other ) as part of the mining algorithm. Hashcash was proposed in May 1997 by (ICO) ICOs are types of crowdfunding mechanisms conducted on the blockchain. Originally, the main idea of an ICO was to fund new projects by pre-selling coins/tokens to investors interested in the project. Entrepreneurs present a whitepaper describing the business model and the technical specifications of a project before the ICO. They lay out a timeline for the project and set a target budget where they describe the future funds spending (marketing, R&D, etc.) as well as coin distribution (how many coins are they going to keep for themselves, token supply, etc.). During the crowdfunding campaign, investors purchase tokens with already established cryptocurrencies like Bitcoin and Ethereum. IPFS The InterPlanetary File System (IPFS) is a hypermedia distribution protocol, addressed by content and iden- tities. IPFS enables the creation of completely distributed applications. It aims to make the web faster, safer, and more open. IPFS is an open source project developed by the team at Interplanetary Networks and many contributors from the open source community. It is a peer-to-peer distributed file system that seeks to connect all computing devices with the same system of files. In some ways, IPFS is similar to the Web, but IPFS could be seen as a single BitTorrent swarm, exchanging objects within one Git repository. In other words, IPFS provides a high throughput content-addressed block storage model, with content-addressed hyperlinks. This forms a gen- eralized Merkle DAG, a data structure upon which one can build versioned file systems, blockchains, and even a Permanent Web. IPFS combines a distributed hash table, an incentivized block exchange, and a self-certifying namespace. IPFS has no single point of failure, and nodes do not need to trust each other Light Node A computer on a blockchain network that only verifies a limited number of transactions relevant to its dealings, making use of the simplified payment verification (SPV) mode Lightning Network The Lightning network is a decentralized network using smart contract functionality on the blockchain to enable instant payments across a network of participants. The Lightning Network will allow bitcoin transactions to happen instantly, without worrying about block confirmation times. It will allow millions of transactions in a few seconds, at low costs, even between different blockchains, as long as both chains use the same cryptographic hash function. The Lightning network will allow two participants on the network to create a ledger entry, conduct a number of transactions between themselves and after the process has finished, record the state of the transactions on the blockchain. As for now, the bitcoin network is capable of processing up to 7 transactions per second. The Visa payment network, for instance, is believed to complete 45,000 transactions per second during a regular holiday period. This protocol tries to solve the bitcoin scalability problem Merkle tree The basic idea behind Merkle tree is to have some piece of data that is linking to another. You can do this by linking things together with a cryptographic hash. The content itself can be used to determine the hash. By using the cryptographic hashing we can address the content, and content gets immutable because if you change anything in the data, the cryptographic hash changes and the link will be different. Bitcoin uses cryptographic hashing, where every block points to the previous one if you modify the block, the hash will change and will make the block invalid Mining (Bitcoin) Mining is the process of adding transaction records to Bitcoin’s public ledger of past transactions or blockchain. This ledger of past transactions is called the blockchain as it is a chain of blocks. The blockchain

20 Chapter 1. Contents Blockchain for Dummies Documentation

serves to confirm transactions to the rest of the network as having taken place. Bitcoin nodes use the blockchain to distinguish legitimate Bitcoin transactions from attempts to re-spend coins that have already been spent else- where. Mining is intentionally designed to be resource-intensive and challenging so that the number of blocks found each day by miners remains steady. Individual blocks must contain a proof of work to be considered valid. This proof of work is verified by other Bitcoin nodes each time they receive a block. Bitcoin uses the hashcash proof-of-work function. The primary purpose of mining is to allow Bitcoin nodes to reach a secure, tamper- resistant consensus. Mining is also the mechanism used to introduce Bitcoins into the system: Miners are paid any transaction fees as well as a “subsidy” of newly created coins. This both serves the purpose of disseminating new coins in a decentralized manner as well as motivating people to provide security for the system Mining Difficulty Mining difficulty measures how hard it would be to find the next Bitcoin block. Every proof of work consensus algorithm has a mining difficulty which is also adjustable. Depending on how many miners join the network the difficulty might rise or fall. The aim of the difficulty is to keep the block times even and make the network secure. The average time for finding a Bitcoin block is set for 10 minutes. Litecoin is set for 2.5 minutes. In a mining pool, different users organize together in order to provide computing power for the bitcoin network. If a Bitcoin block is newly created, each of the users in the mining pool receives its fair share propor- tionately to his mining power. To become a member of a mining pool, the user needs to run software provided by the mining pool. The advantage of the mining pools is that block rewards get distributed across the pool providing more stable income. Node (Full Node) Any computer that connects to the blockchain network is called a node. Nodes that fully enforce all of the rules of the blockchain (i.e., Bitcoin) are called full nodes. Most nodes on the network are lightweight nodes instead of full nodes, but full nodes form the backbone of the network Oracles Smart contracts on the blockchain cannot access the outside network on their own. Therefore oracles sit between a smart contract and the external world, providing the data needed by the smart contract to prove performance while sending its commands to external systems Private Blockchains a fully private blockchain is a blockchain where write permissions are kept centralized to one organization. Read permissions may be public or restricted to an arbitrary extent. Likely applications include database management, auditing, etc. internal to a single company, and so public readability may not be necessary in many cases at all, though in other cases public auditability is desired Private key Each time a user runs a for the first time a public-private key pair gets generated. The private key is a randomly generated number which allows users to transact over the blockchain. It is locally stored and kept secret. Each time a Bitcoin gets sent a private key has to sign the transaction. This action is automatically executed by the wallet software. When a wallet asks users to do a backup what this means is that the users must secure their private key. There are different types of wallets such as online wallets, mobile wallets, desktop wallet, hardware wallets or paper wallets. The category of each wallet is determined by where private keys are stored. Online wallets are mostly provided by exchanges and keep user’s private keys on their servers. If the service provider goes offline users would lose access to their funds. Hardware wallets for example store user’s private keys in a secure device which looks like a USB flash drive. (PoA) A Proof of authority is a consensus mechanism in a private blockchain which essentially gives one client(or a specific number of clients) with one particular private key the right to make all of the blocks in the blockchain Proof of Stake Proof-of-stake (PoS) is a method by which a cryptocurrency blockchain network aims to achieve distributed consensus. While the proof-of-work (PoW) method asks users to repeatedly run hashing algorithms or other client puzzles, to validate electronic transactions, proof-of-stake asks users to prove ownership of a certain amount of currency (their “stake” in the currency). was the first cryptocurrency to launch using proof-of-Stake. Other prominent implementations are found in BitShares, , BlackCoin, NuShares/NuBits and Qora. Ethereum has planned a hard fork transition from PoW to PoS consensus. Decred hybridizes PoW with PoS and combines elements of both in an attempt to garner the benefits of the two systems and create a more robust notion of consensus. With Proof of Work, the probability of mining a block depends on the work done by the miner (e.g. CPU/GPU cycles spent checking hashes). In the case of Bitcoin, with Proof of Stake, the

1.3. Glossary 21 Blockchain for Dummies Documentation

resource that’s compared is the amount of Bitcoin a miner holds – someone holding 1% of the Bitcoin can mine 1% of the “Proof of Stake blocks”. Instead of sacrificing energy to mine a block, a user must prove they own a certain amount of the cryptocurrency to generate a block. The more stake you own, the more likely you are to generate a block. In theory, this should prevent users from creating forks because it will devalue their stake and it should save a lot of energy. Proof of Stake sounds like a good idea, but ironically, there is the “Nothing at Stake” problem. Since mining Bitcoins is costly, it is not smart to waste your energy on a fork that won’t earn you any money, however with Proof of Stake, it is free to mine a fork Proof of Work POW system/protocol/function is an economic measure to deter denial of service attacks and other service abuses such as spam on a network by requiring some work from the service requester, usually meaning processing time by a computer. The concept may have been first presented by Cynthia Dwork and Moni Naor in a 1993 journal. The term “Proof of Work” was first coined and formalized in a 1999 paper by Markus Jakobsson and Ari Juels. A key feature of these schemes is their asymmetry: the work must be moderately hard (but feasible) on the requester side but easy to check for the service provider. This idea is also known as a CPU cost function, client puzzle, computational puzzle or CPU pricing function Public Blockchains a public blockchain is a blockchain that anyone in the world can read, anyone in the world can send transactions to and expect to see them included if they are valid, and anyone in the world can participate in the consensus process – the process for determining what blocks get added to the chain and what the current state is. As a substitute for centralized or quasi-centralized trust, public blockchains are secured by crypto economics – the combination of economic incentives and cryptographic verification using mechanisms such as proof of work or proof of stake, following a general principle that the degree to which someone can have an influence in the consensus process is proportional to the quantity of economic resources that they can bring to bear. These blockchains are generally considered to be “fully decentralized” Ring Signature Ring signature is a cryptographic technology that could provide a decent level of anonymisation on a blockchain. Ring signatures make sure individual transaction outputs on the blockchain can’t be traced. A message signed with a ring signature is endorsed by someone in a particular group of people. One of the security properties of a ring signature is that it should be computationally infeasible to determine which of the group members’ keys was used to produce the signature Satoshi The smallest unit of Bitcoin, equal to 0.00000001 BTC is a person or group of people who created the bitcoin protocol and reference software, Bitcoin Core (formerly known as Bitcoin-Qt). In 2008, Nakamoto published a paper on The Cryptography Mailing list at metzdowd.com describing the bitcoin digital currency. In 2009, they released the first bitcoin software that launched the network and the first units of the bitcoin cryptocurrency, called bitcoins SHA (Secure Hash Algorithm) is a family of cryptographic hash functions published by the National Institute of Standards and Technology (NIST) as a U.S. Federal Information Processing Standard (FIPS). SHA256 is an algorithm used in Bitcoin that takes an input of any size which can be any form of data(text, jpeg, pdf, etc.), mixes it up and creates a fixed size output(a hash) which is 256-bit (32-byte) long . You can think of the hash as the fingerprint of the data. Hashes are one-way functions – they cannot be decrypted back. The only way to decrypt a hash is by brute forcing it. Brute force means to systematically try all the combinations for an input. Brute force attack will always find the input, no matter its complexity. The downside is whether or not you will still be alive when it finally guesses it Sidechains are blockchains that are interoperable with each other and with Bitcoin, avoiding liquidity shortages, market fluctuations, fragmentation, security breaches and outright fraud associated with alternative crypto- currencies. “Sidechains are new blockchains which are backed by Bitcoins, via Bitcoin contracts, just as dollars and pounds used to be backed by cold hard gold. You could in principle have thousands of sidechains “pegged” to Bitcoin, all with different characteristics and purposes . . . and all of them taking advantage of the scarcity and resilience guaranteed by the main Bitcoin blockchain, which in turn could iterate to implement experimental sidechain features once they have been tried and tested. . . ” more Softfork A softfork is a change to the bitcoin protocol wherein only previously valid blocks/transactions are made invalid. Since old nodes will recognize the new blocks as valid, a softfork is backward-compatible. This kind of fork requires only a majority of the miners upgrading to enforce the new rules

22 Chapter 1. Contents Blockchain for Dummies Documentation

SPV(Simplified Payment Verification) client SPV clients are Bitcoin lightweight clients which do not download and store the whole blockchain locally. These wallets provide a way to verify payments without having to download the complete blockchain. An SPV client only downloads the block headers by connecting to a full node State Channel State channels are interactions which get conducted off the blockchain without significantly increas- ing the risk of any participant. Moving these interactions off of the chain without requiring any additional trust can lead to significant improvements in cost and speed. State channels work by locking part of the blockchain state so that a specific set of participants must completely agree with each other to update it Testnet a second blockchain used by developers for testing new versions of client software without putting a real value at risk Token In the context of Blockchains, a token is a digital identity for something that can be owned. Historically, to- kens started as meta information encoded in simple Bitcoin transactions, thereby taking advantage of the Bitcoin blockchain’s strong immutability. At a protocol layer, tokens were outsourced extensions to Bitcoin’s core pro- tocol. Instead of being integrated as a feature on a software level, those tokens were created by misappropriating data fields in Bitcoin transactions (such as encoding data in the amount or op_return field). Today, modern to- kens are created as sophisticated smart contract systems with complex permission systems and interaction paths attached. Smart contracts can be understood as software agents, which act deterministically and autonomously, within the scope of a given network, according to a predefined rule set. If the governance rules around issuance and management of a token are sufficiently complex regarding how they coordinate a group of stakeholders, token smart contracts may be understood as organizations sui generis. The management rules may reflect those of known legal, organizational entities such as stock corporations, but they do not have to Transaction Fees (Bitcoin) may be included with any transfer of bitcoins from one address to another. At the moment, many transactions are typically processed in a way where no fee is expected at all, but for transactions which draw coins from many bitcoin addresses and therefore have a large data size, a small transaction fee is usually expected. The transaction fee is processed by and received by the bitcoin miner. When a new bitcoin block is generated with a successful hash, the information for all of the transactions is included with the block, and all transaction fees are collected by that user creating the block, who is free to assign those fees to himself. Transaction fees are voluntary on the part of the person making the bitcoin transaction, as the person attempting to make a transaction can include any fee or none at all in the transaction. On the other hand, nobody mining new bitcoins necessarily needs to accept the transactions and include them in the new block being created. The transaction fee is, therefore, an incentive on the part of the bitcoin user to make sure that a particular transaction will get included in the next block which is generated. It is envisioned that over time the cumulative effect of collecting transaction fees will allow somebody creating new blocks to “earn” more bitcoins that will be mined from new bitcoins created by the new block itself. This is also an incentive to keep trying to create new blocks even if the value of the newly created block from the mining activity is zero in the far future Turing completeness A machine is Turing complete if it can perform any calculation that any other programmable computer is capable of. All modern computers are Turing-complete in this sense. The Ethereum Virtual Machine (EVM) which runs on the Ethereum blockchain is Turing complete. Thus it can process any “computable function”. It is, in short, able to do what you could do with any conventional computer and programming language Wallet is a file that contains a collection of private keys and communicates with the corresponding blockchain. Wallets contain keys, not coins. Wallets require backups for security reasons. Whisper Whisper is a part of the Ethereum p2p protocol suite that allows for messaging between users via the same network that the blockchain runs on. The main task of whisper will be the provision of a communication protocol between dapps Source: https://blockchainhub.net/blockchain-glossary/

1.3. Glossary 23 Blockchain for Dummies Documentation

24 Chapter 1. Contents Index

Symbols I 51% attack, 18 Initial Coin Offering (ICO), 20 IPFS, 20 A Altcoins, 18 L ASIC, 18 Light Node, 20 Lightning Network, 20 B Bitcoin, 18 M Bitcoin ATM, 18 Merkle tree, 20 Block explorer, 18 Mining (Bitcoin), 20 Block reward, 18 Mining Difficulty, 21 Blockchain, 18 Mining Pool, 21 C N Chain linking, 18 Node (Full Node), 21 Client, 18 Cloud Mining, 18 O Consensus (Bitcoin’s Process Consensus), 18 Oracles, 21 Consensus (general), 19 Consortium blockchains, 19 P Cryptographic Hash Function, 19 Private Blockchains, 21 Cryptojacking, 19 Private key, 21 Proof of Authority(PoA), 21 D Proof of Stake, 21 Digital Signature, 19 Proof of Work, 22 Double Spending, 19 Public Blockchains, 22 F R Fiat currency, 19 Ring Signature, 22 Fork, 19 S G Satoshi, 22 Genesis block, 20 Satoshi Nakamoto, 22 SHA (Secure Hash Algorithm), 22 H Sidechains, 22 Halving, 20 Softfork, 22 Hardfork, 20 SPV(Simplified Payment Verification) client, 23 Hashcash, 20 State Channel, 23

25 Blockchain for Dummies Documentation

T Testnet, 23 Token, 23 Transaction Fees (Bitcoin), 23 Turing completeness, 23 W Wallet, 23 Whisper, 23

26 Index