A Comprehensive Survey on Blockchain's Technology
Total Page:16
File Type:pdf, Size:1020Kb
Graduado en Matemáticas e Informática Universidad Politécnica de Madrid Escuela Técnica Superior de Ingenieros Informáticos TRABAJO FIN DE GRADO A Comprehensive Survey on Blockchain’s Technology Autor: Alejandro Esquivias Cañadas Director: Dr. Kashif Sharif BEIJING, JUNIO 2019 Acknowledgments This thesis was done in collaboration with Beijing Institute of Technology, with Dr. Kashif Sharif as the supervisor and with the help of Biswas Sujit. I would like to thank my family for all the support, Andrea for the help with the cryptography part as well as the constant support she gave me. Last but not least I would like to thank all the friends (Dani and Omar particularly) I have shared good memories with and have helped me during these years. CONTENTS I- INTRODUCTION ............................................................................................................... 1 1. Overview of Thesis ............................................................................................................ 1 2. Motivation ......................................................................................................................... 2 3. Contributions ..................................................................................................................... 2 II- BLOCKCHAIN TECHNOLOGY INTRODUCTION ................................................ 5 1. Blockchain overview .......................................................................................................... 5 1.1- Difference between symmetric and asymmetric encryption ..................................... 6 1.2- Overview of Blockchain’s mechanism ...................................................................... 7 1.3- Public and Private Blockchain .................................................................................. 8 2- Transaction structure ............................................................................................................ 9 2.1- Transaction Structure in Bitcoin .................................................................................... 9 2.2- Transaction structure in Ethereum ............................................................................... 10 2.3- Transaction Structure in Hyperledger .......................................................................... 10 3. Block Structure ............................................................................................................... 10 3.1- Block Structure in Bitcoin ........................................................................................... 10 3.2- Block Structure in Ethereum ........................................................................................ 12 3.3- Block structure in Hyperledger .................................................................................... 13 4- Example of transaction processes....................................................................................... 14 4.1- Transaction in Bitcoin .................................................................................................. 14 4.1.1 Types of transaction ................................................................................................... 17 4.2- Transactions in Ethereum ............................................................................................ 19 4.2.1- Transfer from one EOA to another EOA: ................................................................. 19 4.2.2- Deploy a contract on Ethereum Network .................................................................. 19 4.2.3- Execute a Function on a Deployed Contract ............................................................. 20 4.3- Transactions in Hyperledger ........................................................................................ 21 III- SECURITY IN BLOCKCHAIN AND ITS APPLICATIONS .................................. 23 1- Hash functions ................................................................................................................. 23 1.1 - Hash Codes ........................................................................................................... 23 1.2- Compression Functions ................................................................................................ 24 1.3- Collisions ..................................................................................................................... 24 2. Standard use of hash functions in cryptography ............................................................ 25 2.1- SHA 256 in Bitcoin and Hyperledger Fabric ............................................................... 25 2.2- Attacks on SHA 256 .................................................................................................... 27 2.3- Keccak 256 in Ethereum .............................................................................................. 28 2.4- Attacks on sponge functions ........................................................................................ 29 3. Elliptic Curve Cryptography ............................................................................................. 31 3.1. Basic Overview of Elliptic Curve Cryptography .................................................... 31 3.1.1- Elliptic curves over Fp ............................................................................................... 32 m 3.1.2- Elliptic curves over F2 ............................................................................................. 33 4. ECDSA (Elliptic Curve Digital Signature Algorithm) ......................................................... 33 5. Blockchain Applications................................................................................................... 34 5.1- Blockchain in IoT ........................................................................................................ 35 5.1.1- IOTA ......................................................................................................................... 35 5.2- Atonomi ....................................................................................................................... 36 5.3- Blockchain in government Services ............................................................................. 36 IV- CONSENSUS ALGORITHMS ......................................................................................... 38 1. Bitcoin’s Proof Of Work ................................................................................................... 38 1.1. History ..................................................................................................................... 38 1.2. Dwork’s and Naor’s Pricing Functions ................................................................... 38 1.3. Adam Back’s work .................................................................................................. 39 1.4. The Hashcash cost function ..................................................................................... 40 1.5. Critiques and Limitations ........................................................................................ 41 2. Ethereum: From Proof of Work to Proof of Stake .......................................................... 42 2.1. Ethereum’s terminology .......................................................................................... 42 2.2. Proof Of Stake (PoS) ............................................................................................... 43 2.3. The Byzantine Generals Problem ............................................................................ 44 2.4. Ethereum Casper ..................................................................................................... 47 2.4.1. The CBC Protocol ................................................................................................... 47 2.4.2. Casper FFG ............................................................................................................. 49 3. Hyperledger’s Kafka ........................................................................................................ 51 3.1. Hyperledger Fabric .................................................................................................. 51 3.2. Kafka in general ...................................................................................................... 52 3.3. Kafka in Fabric ........................................................................................................ 53 4. Conclusions on consensus algorithms ............................................................................. 54 V- APPLICATION .................................................................................................................... 56 VI. FINAL CONCLUSIONS .................................................................................................... 59 VII- BIBLIOGRAPHY ............................................................................................................. 60 I- INTRODUCTION 1. Overview of Thesis Index terms: Proof of Work, Proof of Stake, Byzantine Generals Problem, Bitcoin, Ethereum, Hyperledger Fabric, Hash Functions, Hash Collisions, Sponge Functions, Elliptic Curve Cryptography, Consensus, IoT. Blockchain is a technology that has been gaining attention lately. When this was written there were over 1600 different cryptocurrencies and 33 % of the bankers [45] expect commercial blockchain adoption by next year. It is imperative that we understand this technology, which is