Blockchain and Its Development Abdullah Aziz Researcher@SESLab mister.abdullah.aziz@gmail.com Feb 2, 2018
Contents Blockchain Concept • Characteristics • Hashing • Merkle Tree • The Block • Chain of Blocks • Forks • Securing Data • Public vs Private Blockhain Coding Blockchain Demo of Running implementation of Blockchain
Blockchain Concept What is Blockchain? • No more than a distributed database • A large worldwide computer where everyone can securely access data and execute transactional code. • All transactions stored in blocks of data. • Blocks are very hard to manipulate. • Due to its nature, you can say it gives you trustworthiness. • Not generally a place to store large amount of data. • Most data stored on blockchain are transactions or state of object, rather than the actual objects.
Blockchain Characteristics Global Singleton • It is global singleton instances. • Natively object oriented, where code and data reside together, However objects are securely separated with each other. Accessible • It's nature is accessible, everywhere there's internet, you can access the blockchain. Unstoppable • No one in control over blockchain. • It cannot be stopped and it cannot have central failure. • No single point of attack. (till now) Verifiable • Everyone who have access to the blockchain can verify every single transaction.
How does it work?
How does it work? Initiate • When someone is doing a single or group of transactions. • Transaction is typically sending data in the form of contract. Transaction • Then the transaction is sent to a large peer-to-peer network to computers. • Each node is called a node, and all have the copy of existing data. Transaction validation • Then the transaction is executed and validated based on the pre- shared contracts and scripts. • Ensures that all nodes execute transaction using same set of rules. • When the transaction is executed, the result is added to the blockchain.
Transactions in Blockchain Atomic • Full operation run, or nothing at all. Inspectable • It has to be inspectable. • Every single method call that comes to blockchain comes with the actual address to the caller. • That gives unique possibility for securing and auditing solution on a very wide scale. Run Independently • Transactions run independently of each other. • No two operations can interact or interfere with each other. Immortal • Blockchain objects are immortal, all data of an object is permanent. • The code for an object can never be changed and you can never delete an object externally. • The only way of deleting the block is that if it is programmed to remove itself.
Hashing Length of output always same • Basically to execute mathematical algorithm that creates a result with a given length regardless of the input. Digital fingerprint • he result of hashing function is hash, can think as a digital fingerprint. One Way • It is a one way function, meaning the function will always return the same result give the same input. • But you can never regenerate the input based on the result of the hashing algorithm. Uses • Password storing in database. • To verify consistency. (check data compromised) • In modern security. Blockchain use SHA-256 hashing.
SHA-256 Input Output I am Abdullah Aziz. 573cb37000355b98df2f9bae35f6 3ba669b533e4f0219f27fa595456 b0bc534b
Merkle Tree • A Merkle Tree is a hash of hashes. • Makes it quick and rather easy to confirm large amounts of data and transactions.
The Block • A block consists of data and its resulting hash. • If we change the data in the the block, the hash will change and the block will be invalid. • It is also includes the NOUNCE, which is input to the hashing algorithm that would result in the first part of the hash to be something predefined like a set of zeros. • It is not possible to predict the nounce so it can be considered as the proof of work machine creating the hash. (difficulty). • Let say that we require our hash to have a leading number of 4 zeros. Whenever we change anything, we will need to rerun the hashing algorithm until we figure out which nounce to set. (mining the Block) Message: “I am Abdullah Aziz” Hash: 0000573cb3700035 5b98df2f9bae35f63 ba669b533e4f0219f 27fa595456b0bc53 4b Nounce: 314115
A chain of Blocks Number: 9 Message: “I am Abdullah Aziz” Hash: 0000573cb37000355b98df2f9bae 35f63ba669b533e4f0219f27fa595 456b0bc534b Nounce: 314115 Timestamp: 321365171 Previous hash: 51d17b39395786e3ffaf14274d15 e780eeb4e4a51fdb4ca0bb66e65d 1b12094c Number: 8 Message: “I am Haris” Hash: 51d17b39395786e3ffaf14274d15e780 eeb4e4a51fdb4ca0bb66e65d1b12094c Nounce: 314115 Timestamp: 321365171 Previous hash: 07ab89a02c00f6b906411ff6f738581a3 a8c21005d850541b8503cee55a01890 Number: 10 Message: “I am Komal” Hash: c8c7451c74931ec851ccd9fbed1a6152e 5bc61995aadca050249191053bdce0d Nounce: 314115 Timestamp: 321365171 Previous hash: 0000573cb37000355b98df2f9bae35f6 3ba669b533e4f0219f27fa595456b0bc5 34b
A Distributed Chain of Blocks • In Blockchain, we distributed a chain of blocks to a vast number of computers. • This means that the chain exists in multiple locations. • Depending on the implementation of blockchain you are using, it could be millions of replications of the chain. • This mean that we can easily figure out if something has changed, even if one of the chain has be re-mined. • The resulting hashes would be different from one chain and blockchain works in a way where chain that has the most work put into it, wins. • The altered chain would than be rejected by distributed blockchain and be removed.
Forks Jack • Jack receives 100 bitcoins from his mother and bought a car from vendor a and sent 100 bitcoins to him. Vendor A received the 100 coins from Jack. • Jack also send 100 bitcoins to vendor B to buy another car based on previous block where he have 100 bitcoins received from his mother. • This creates a FORK. Vendor A Vendor B
Forks • In order for him to fix it, he must have a lot of computing power at his hands. • Actually, since the blockchain consists of having to prove that you put work into the calculations, he would have to have almost the same computing resources, as the rest of the blockchain in order for his new chain to be accepted. • This is quite unlikely, but people tried to do this but this fork has always been downloaded and removed.
Securing Your Data • Data stored in blockchain is generally available to everyone that has access to the chain. • In some cases, it is no problem that everyone have access to the data, but in some cases, you want to assure that you control who has your data. • There are basically two ways to do this: • Obfuscation • In software development, obfuscation is the deliberate act of creating source or machine code that is difficult for humans to understand. • Encryption
Public Vs. Private Blockchain Public Private • Available to everyone. • Expensive storage and transaction. • No given point of attack. • Rely on community, as soon community gone the chain will gone. • Democratic • Similar to traditional database. • Cost Controlled • Known entities • Controlled Storage • Transition to blockchain • Fewer point of attacks
Coding Blocking
Block The first block is called Genesis block.
Blockchain
Hash
Valid Hash • A valid hash is a hash that meets a certain requirement. For this blockchain, three leading zeros in front of the hash is the requirement for a valid hash. The number of leading zeros required is the difficulty.
Mine Block Mining is the process of finding a valid hash.
Nounce • The nonce is the number used to find a valid hash. • The nonce iterates from 0 until a valid hash is found. • This uses processing power! • As difficulty increases, the number of possible valid hashes decreases. • With less possible valid hashes, it takes more processing power to find a valid hash.
Mining new Block
Adding New Block • When adding a new block to the blockchain, the new block needs to meet these requirements. • Block index one greater than latest block index. • Block previous hash equal to latest block hash. • Block hash meets difficulty requirement. • Block hash is correctly calculated. • Other peers on the network will be adding blocks to the blockchain, so new blocks need to be validated.
Peer-to-Peer Network A global network of computers work together to keep the blockchain secure, correct, and consistent. Show code
Adding Peer
Demo
Summary Blockchain Concept • Characteristics • Hashing • Merkle Tree • The Block • Chain of Blocks • Forks • Securing Data • Public vs Private Blockhain Coding Blockchain Demo of Running implementation of Blockchain
Thanks Abdullah Aziz Researcher@SESLab mister.abdullah.aziz@gmail.com https://www.linkedin.com/in/abdullah-aziz/

Introduction to Blockchain & development

  • 1.
    Blockchain and Its Development AbdullahAziz Researcher@SESLab mister.abdullah.aziz@gmail.com Feb 2, 2018
  • 2.
    Contents Blockchain Concept • Characteristics •Hashing • Merkle Tree • The Block • Chain of Blocks • Forks • Securing Data • Public vs Private Blockhain Coding Blockchain Demo of Running implementation of Blockchain
  • 3.
    Blockchain Concept What is Blockchain? •No more than a distributed database • A large worldwide computer where everyone can securely access data and execute transactional code. • All transactions stored in blocks of data. • Blocks are very hard to manipulate. • Due to its nature, you can say it gives you trustworthiness. • Not generally a place to store large amount of data. • Most data stored on blockchain are transactions or state of object, rather than the actual objects.
  • 4.
    Blockchain Characteristics Global Singleton • Itis global singleton instances. • Natively object oriented, where code and data reside together, However objects are securely separated with each other. Accessible • It's nature is accessible, everywhere there's internet, you can access the blockchain. Unstoppable • No one in control over blockchain. • It cannot be stopped and it cannot have central failure. • No single point of attack. (till now) Verifiable • Everyone who have access to the blockchain can verify every single transaction.
  • 5.
  • 6.
    How does it work? Initiate •When someone is doing a single or group of transactions. • Transaction is typically sending data in the form of contract. Transaction • Then the transaction is sent to a large peer-to-peer network to computers. • Each node is called a node, and all have the copy of existing data. Transaction validation • Then the transaction is executed and validated based on the pre- shared contracts and scripts. • Ensures that all nodes execute transaction using same set of rules. • When the transaction is executed, the result is added to the blockchain.
  • 7.
    Transactions in Blockchain Atomic • Fulloperation run, or nothing at all. Inspectable • It has to be inspectable. • Every single method call that comes to blockchain comes with the actual address to the caller. • That gives unique possibility for securing and auditing solution on a very wide scale. Run Independently • Transactions run independently of each other. • No two operations can interact or interfere with each other. Immortal • Blockchain objects are immortal, all data of an object is permanent. • The code for an object can never be changed and you can never delete an object externally. • The only way of deleting the block is that if it is programmed to remove itself.
  • 8.
    Hashing Length of outputalways same • Basically to execute mathematical algorithm that creates a result with a given length regardless of the input. Digital fingerprint • he result of hashing function is hash, can think as a digital fingerprint. One Way • It is a one way function, meaning the function will always return the same result give the same input. • But you can never regenerate the input based on the result of the hashing algorithm. Uses • Password storing in database. • To verify consistency. (check data compromised) • In modern security. Blockchain use SHA-256 hashing.
  • 9.
    SHA-256 Input Output I amAbdullah Aziz. 573cb37000355b98df2f9bae35f6 3ba669b533e4f0219f27fa595456 b0bc534b
  • 10.
    Merkle Tree • AMerkle Tree is a hash of hashes. • Makes it quick and rather easy to confirm large amounts of data and transactions.
  • 11.
    The Block • Ablock consists of data and its resulting hash. • If we change the data in the the block, the hash will change and the block will be invalid. • It is also includes the NOUNCE, which is input to the hashing algorithm that would result in the first part of the hash to be something predefined like a set of zeros. • It is not possible to predict the nounce so it can be considered as the proof of work machine creating the hash. (difficulty). • Let say that we require our hash to have a leading number of 4 zeros. Whenever we change anything, we will need to rerun the hashing algorithm until we figure out which nounce to set. (mining the Block) Message: “I am Abdullah Aziz” Hash: 0000573cb3700035 5b98df2f9bae35f63 ba669b533e4f0219f 27fa595456b0bc53 4b Nounce: 314115
  • 12.
    A chain ofBlocks Number: 9 Message: “I am Abdullah Aziz” Hash: 0000573cb37000355b98df2f9bae 35f63ba669b533e4f0219f27fa595 456b0bc534b Nounce: 314115 Timestamp: 321365171 Previous hash: 51d17b39395786e3ffaf14274d15 e780eeb4e4a51fdb4ca0bb66e65d 1b12094c Number: 8 Message: “I am Haris” Hash: 51d17b39395786e3ffaf14274d15e780 eeb4e4a51fdb4ca0bb66e65d1b12094c Nounce: 314115 Timestamp: 321365171 Previous hash: 07ab89a02c00f6b906411ff6f738581a3 a8c21005d850541b8503cee55a01890 Number: 10 Message: “I am Komal” Hash: c8c7451c74931ec851ccd9fbed1a6152e 5bc61995aadca050249191053bdce0d Nounce: 314115 Timestamp: 321365171 Previous hash: 0000573cb37000355b98df2f9bae35f6 3ba669b533e4f0219f27fa595456b0bc5 34b
  • 13.
    A Distributed Chain of Blocks •In Blockchain, we distributed a chain of blocks to a vast number of computers. • This means that the chain exists in multiple locations. • Depending on the implementation of blockchain you are using, it could be millions of replications of the chain. • This mean that we can easily figure out if something has changed, even if one of the chain has be re-mined. • The resulting hashes would be different from one chain and blockchain works in a way where chain that has the most work put into it, wins. • The altered chain would than be rejected by distributed blockchain and be removed.
  • 14.
    Forks Jack • Jack receives100 bitcoins from his mother and bought a car from vendor a and sent 100 bitcoins to him. Vendor A received the 100 coins from Jack. • Jack also send 100 bitcoins to vendor B to buy another car based on previous block where he have 100 bitcoins received from his mother. • This creates a FORK. Vendor A Vendor B
  • 15.
    Forks • In orderfor him to fix it, he must have a lot of computing power at his hands. • Actually, since the blockchain consists of having to prove that you put work into the calculations, he would have to have almost the same computing resources, as the rest of the blockchain in order for his new chain to be accepted. • This is quite unlikely, but people tried to do this but this fork has always been downloaded and removed.
  • 16.
    Securing Your Data • Datastored in blockchain is generally available to everyone that has access to the chain. • In some cases, it is no problem that everyone have access to the data, but in some cases, you want to assure that you control who has your data. • There are basically two ways to do this: • Obfuscation • In software development, obfuscation is the deliberate act of creating source or machine code that is difficult for humans to understand. • Encryption
  • 17.
    Public Vs. Private Blockchain PublicPrivate • Available to everyone. • Expensive storage and transaction. • No given point of attack. • Rely on community, as soon community gone the chain will gone. • Democratic • Similar to traditional database. • Cost Controlled • Known entities • Controlled Storage • Transition to blockchain • Fewer point of attacks
  • 18.
  • 19.
    Block The first blockis called Genesis block.
  • 20.
  • 21.
  • 22.
    Valid Hash • Avalid hash is a hash that meets a certain requirement. For this blockchain, three leading zeros in front of the hash is the requirement for a valid hash. The number of leading zeros required is the difficulty.
  • 23.
    Mine Block Mining isthe process of finding a valid hash.
  • 24.
    Nounce • The nonceis the number used to find a valid hash. • The nonce iterates from 0 until a valid hash is found. • This uses processing power! • As difficulty increases, the number of possible valid hashes decreases. • With less possible valid hashes, it takes more processing power to find a valid hash.
  • 25.
  • 26.
    Adding New Block •When adding a new block to the blockchain, the new block needs to meet these requirements. • Block index one greater than latest block index. • Block previous hash equal to latest block hash. • Block hash meets difficulty requirement. • Block hash is correctly calculated. • Other peers on the network will be adding blocks to the blockchain, so new blocks need to be validated.
  • 27.
    Peer-to-Peer Network A global networkof computers work together to keep the blockchain secure, correct, and consistent. Show code
  • 28.
  • 29.
  • 31.
    Summary Blockchain Concept • Characteristics •Hashing • Merkle Tree • The Block • Chain of Blocks • Forks • Securing Data • Public vs Private Blockhain Coding Blockchain Demo of Running implementation of Blockchain
  • 32.