Blockchain 101

21
Blockchain 101 A Breakdown By Suki Chana 05/07/2022 Esselltee Ltd, 521 Bath Road, Bristol BS3133HH; Telephone 07710 813601; Email [email protected] 1

Transcript of Blockchain 101

Page 1: Blockchain 101

Blockchain 101A Breakdown By Suki Chana

03/05/2023 Esselltee Ltd, 521 Bath Road, Bristol BS3133HH; Telephone 07710 813601; Email [email protected] 1

Page 2: Blockchain 101

03/05/2023 Esselltee Ltd, 521 Bath Road, Bristol BS3133HH; Telephone 07710 813601; Email [email protected]

2

Executive Summary

Evers since the publication of Satoshi Nakamoto’s paper on “bitcoin: A Peer-to-Peer Electronic Cash System” in 2008 the world has been overrun by the term “Blockchain” . Much has been written and many claim to understand it; and many to be frank do. However for those who would like a simpler view of blockchains and distributed ledgers this slide deck provides an easy to follow guide on the basics.

Readers of this document will learn what a block is, how it gets linked into a chain and why the chain is hard to break. Readers will also learn about distributed ledgers and what they offer in terms of process simplification. Finally this presentation will review bitcoin and describing the salient point s of this implementation.

Page 3: Blockchain 101

03/05/2023 Esselltee Ltd, 521 Bath Road, Bristol BS3133HH; Telephone 07710 813601; Email [email protected]

3

Forget what you have heard up to now

• BitCoin• Ethereum• Cypher Block

These are not definitions of Blockchain They are specific implementations of

Blockchain A blockchain is not just for crypto

currency You can build a Blockchain from the

ground up

Page 4: Blockchain 101

03/05/2023 Esselltee Ltd, 521 Bath Road, Bristol BS3133HH; Telephone 07710 813601; Email [email protected]

4

What Is a BlockchainA Blockchain • Is a linked list of digital data items called blocks. • Chronicles the events in the lifetime of a digital entity – e.g. a bank account, a coin, etc. –

recording all the events in that entities lifetime.• Contains:

• A Genesis block – The first block in the chain which only points to a successor• Link blocks – Subsequent blocks that are linked bi-directionally – they have a predecessor and a

successor• A last block – one which doesn’t point to a next block, i.e. it only has a predecessor

• Links blocks sequentially, chronologically and Cryptographically – hard to break• Can be

• Of infinite size• Traversed in either direction – The links identify next and previous blocks• Validated to check integrity – missing or altered blocks• Public or private:

• Public blockchains can be accessed by any body• Private blockchains can only be accessed by those within the a particular domain – e.g. employees of a

company

• Are: • Stored within databases• Best implemented over distributed networks

There is no standard for the design of a blockchain

Page 5: Blockchain 101

03/05/2023 Esselltee Ltd, 521 Bath Road, Bristol BS3133HH; Telephone 07710 813601; Email [email protected]

5

What is a BlockIndividual blocks:

• Can be created by anyone in the blockchain’s domain - according to the rules of the chain designer – These can be called “Creators”

• Must be signed by the creator – Using their private key – Part of the security mechanism

• Must contain the creators public key – For validation purposes• Must identify the predecessor and successor blocks – The linking

mechanism• Use the signature of the previous block in the calculation of the

next block signature – The linking and integrity management mechanism

• Contain at least one time stamp• Can be strengthened by using Proof of Work – Added security • Contain a payload – e.g. a bank balance• May include Smart Contracts

“There is no standard for block design” If viewed a block is just a blob of hexadecimal data

Page 6: Blockchain 101

03/05/2023 Esselltee Ltd, 521 Bath Road, Bristol BS3133HH; Telephone 07710 813601; Email [email protected]

6

Before we continue

Whilst blocks are the individual components of a blockchain before we move on to looking at how blockchains work it is worth pausing to look at a few details like:

• Cryptographic Keys• Digital Signatures• Proof of work• Smart Contracts• Distributed ledgers• Consensus

These are the things that extend the basic blockchain increasing its strength and flexibility

Page 7: Blockchain 101

03/05/2023 Esselltee Ltd, 521 Bath Road, Bristol BS3133HH; Telephone 07710 813601; Email [email protected]

7

Cryptographic Keys• Digital cryptography is the application of publically

defined algorithms to produce an output which hides the original data (encryption)

• The original data can be recovered by reversing the calculation (decryption)

• What stops unauthorised people from reversing a cryptographic algorithm to recover the original data is the use of secret numbers called cryptographic keys

• Cryptographic keys are kept secret• Without the correct key a cryptographic algorithm

cannot be reversed • There are two types of cryptographic keys

• A symmetric key is one that can be used to encrypt and decrypt a piece of data

• An asymmetric key comes in two parts, one to encrypt data and the other to decrypt it

• The two parts of an asymmetric key are known as the private and public keys. These are mathematically joined and cannot swapped or used with other asymmetric keys

• The owner of the Private Key must be keep it secret whilst the public key can be shared with people who the owners wants to communicate with in a secure way

• Senders can use a person’s public key to encrypt data in a way that only the owner of the corresponding private key can open it (decrypt) or use it to validate data that has been signed by the owner using the matching private key

• The owner of a private key can use it to decrypt data encrypted with the corresponding public key or sign data for validation with the matching public key.

Page 8: Blockchain 101

03/05/2023 Esselltee Ltd, 521 Bath Road, Bristol BS3133HH; Telephone 07710 813601; Email [email protected]

8

Digital Signatures• Digital signatures are the numeric results generated when a

recursive mathematical algorithm is applied to a block of electronic data.

• SHA 1 is an example of a signing algorithm – no matter how big the data block is, it always returns a 20 character result – sometimes called a hash or a digest

• Digital Signatures are calculated using cryptographic keys – e.g. the creators private key

• These keys are personal to a user which makes the digital signature as personal as a written signature.

• Unlike written signatures if you change a single bit in the original data the digital signature will be different - Even when the same key is used – Hence digital signatures are used to prevent people tampering with electronic data because they are unique.

• Random numbers called nonces are often added to guarantee uniqueness of the signature• In normal operation you send the original data and the digital signature to the user. Users validate the signature by executing a validation process over the data using the signatories public key and if the result they get does not match the signature then this indicates that someone has altered the data on route.

Page 9: Blockchain 101

03/05/2023 Esselltee Ltd, 521 Bath Road, Bristol BS3133HH; Telephone 07710 813601; Email [email protected]

9

What Is Proof of Work

One way of implementing POW is to sign a data string created by concatenating the creator signatures from a collection of blocks using an approvers private key. The resulting digital signature is then added to each block in that selection – Those blocks become approved and can be added back to their respective chains.Chain integrity is maintained by the creator and POW signatures.

Proof of work provides external corroboration that an event took place by validating a block and placing a secondary seal on it.

There is no standard for POW so it can be implemented using varying processes – For a particular implementation this can be defined in a smart code contract.

POW is performed after each block has been validated using the creators public keyPOW is performed by “Approvers” using their private key

Page 10: Blockchain 101

03/05/2023 Esselltee Ltd, 521 Bath Road, Bristol BS3133HH; Telephone 07710 813601; Email [email protected]

10

What are Smart Contracts

Smart Contracts are a dual concept that needs to be viewed as two linked components.• Smart Code Contracts:

• Are executable code fragments – e.g. servlets, applets, etc.

• Encapsulate permitted behaviour• Can be executed when processing a block• Are signed so they can’t be tampered with

• Smart Legal Contracts:• Are human readable documents• Specify those aspects of a Smart Code

Contract that are not behavioural - e.g. Liabilities, compensation values, etc.

• Define how Smart Code contracts can be used

Page 11: Blockchain 101

03/05/2023 Esselltee Ltd, 521 Bath Road, Bristol BS3133HH; Telephone 07710 813601; Email [email protected]

11

Distributed LedgersTraditional ledgers store collections of data; e.g. bank ledgers are databases holding the balances and transaction histories of all the accounts held within that bank.

Bank ledgers can be implemented using blockchains. Single chains represent each account and the database holding all the chains becomes the banks ledger – We can refer to this as a blockchain ledger (BCL)

Distributed Ledgers are:

• A collection of databases (public or private) that all hold identical copies of a blockchain ledger

• Usually hosted by systems that expose interfaces to blockchain ledger users

• Distributed over a network – LAN or WAN

Page 12: Blockchain 101

03/05/2023 Esselltee Ltd, 521 Bath Road, Bristol BS3133HH; Telephone 07710 813601; Email [email protected]

12

Distributed Ledgers & ConsensusDistributed ledgers work on the principle of consensus. Consensus is reached when the majority of entities within a single environment reach the same conclusion or have the same view.In a distributed ledger if the majority of the databases have the same view of a particular blockchain ledger then that is deemed to be the truth.The strength of consensus is that to attack the system an attacker must have the power to attack a minimum of 51% of the blockchain ledgers in a single distributed ledger in order to get the consensus and alter the state of the blockchain ledger. This gets exponentially more difficult as the to number of network nodes grow making consensus a powerful component of distributed ledger security:

Total Nodes No of nodes to reach 51% 10 6 100 51 1000 510 10,000 5,100 100,000 51,0001,000,000 510,0000

In the example opposite the truth is represented by the four nodes that agree an account balance of 100. Consensus is delivered by 80% of the network.

Acct Balance = 100 Acct Balance = 100

Acct Balance = 100

Acct Balance = 100 Acct Balance = 80

Page 13: Blockchain 101

03/05/2023 Esselltee Ltd, 521 Bath Road, Bristol BS3133HH; Telephone 07710 813601; Email [email protected]

13

How Does The Blockchain Work – Minimal Block Structure

A minimal block should contain: Chain Identifier - Identifies the chain to which the block belongs Block Identifier – Identifies the block Block Sequence No - Specifies the position of the block in the chain – 0 or 1 for the genesis block Previous Block Identifier – Identifies the preceding block – blank for the genesis block Previous Block Sequence No – identifies the position of the preceding block in the chain Next Block Identifier – Identifies the next block in the chain – not populated within the last block of

the chains Next Block Sequence No – Identifies the sequence number that should be applied to the next block Nonce – A random value used as part of the signature generation algorithm – minimise risk of

duplicate signatures Creators Signature – Seals block Creators Public Key – Used to validate the signature Proof of Work – Double seal on block POW Public Key – Used to validate POW Timestamp Payload – Can be anything the application requires

“There are no hard and fast standards”

Page 14: Blockchain 101

03/05/2023 Esselltee Ltd, 521 Bath Road, Bristol BS3133HH; Telephone 07710 813601; Email [email protected]

14

How Does The Blockchain Work – Chain Propagation & Distributed Ledgers

To be effective blockchain ledgers need to work over a distributed networks that contain:• Creator nodes • Approver nodes • A time server – to make sure all the timestamps reference a

common source.Creator nodes:

• Work on a chain and build the next block – e.g. a transaction on a bank account

• Broadcast the block to the network of approver nodes.Approver nodes perform the proof of work:

• Validate it against their copy of the chain• Calculate the POW hash & Add it to the block• Timestamp the approved block• Add the approved block to their copy of the Blockchain• Transmit the approved block to all other nodes.

Step 1 - Any node can be a creator or an approver – In fact the roles switch dynamically. The network is in a stable state

Page 15: Blockchain 101

03/05/2023 Esselltee Ltd, 521 Bath Road, Bristol BS3133HH; Telephone 07710 813601; Email [email protected]

15

How Does The Blockchain Work – Chain Propagation & Distributed Ledgers (2)

Step 3: All other nodes become approvers. The first node to complete POW broadcasts the approved block to the network.

Step 4: All nodes add the approved block to their copy of the chain – every node has identical data.

Step 2: A Node processes an event relating to the an object on the blockchain and broadcasts it to all the nodes on the network

Page 16: Blockchain 101

03/05/2023 Esselltee Ltd, 521 Bath Road, Bristol BS3133HH; Telephone 07710 813601; Email [email protected]

16

How Does The Blockchain Work - Security

Blockchain security relies on:1. The Creators signature to ensure the block

cannot be altered on the way to approvers2. The POW hash to validate the blockBlockchain doesn’t concern itself with the security of the payload – • If sensitive data is stored in there it must be

encrypted with additional payload keys• These need not be shared if a singular entity

works on block creationBlockchains are validated by sequentially validating the creator signatures from the genesis block to the last block – The longer the blockchain the longer this operationAdditional validation can be performed by validating the POW of each block.

Page 17: Blockchain 101

03/05/2023 Esselltee Ltd, 521 Bath Road, Bristol BS3133HH; Telephone 07710 813601; Email [email protected]

17

The Strength of BlockchainBlockchains are strong because:Each block is indelible

• Cannot be changed• If deleted chain is invalidated

To alter a block you have to • Redo the signatures of all the blocks proceeding the one you want to change – To do this you need the

private keys of all the block creators that built the blocks after the one you want to change • Redo the proof of work for all the proceeding blocks – To do this you will need:

• The private keys of all the approvers of that approved the blocks after the one you want to change• The other blocks they used to include in the POW.

To attack the Blockchain you must simultaneously attack all the instances of the chain within the distributed ledger

Smart Contracts – Especially coded ones enforce how the blocks in a chain can be manipulatedConsensus – The truth is always represented by 51% of the nodes on the networkWeight of Numbers – The more you distribute the harder it is to break (in theory)

Page 18: Blockchain 101

03/05/2023 Esselltee Ltd, 521 Bath Road, Bristol BS3133HH; Telephone 07710 813601; Email [email protected]

18

P2P Payments a Practical Example

Scenario – A sender needs to make a high value payment using the CHAPS system. The sender has an account with Bank A and the recipient has an account with Bank B. Both Banks have a settlement accounts with a central bank. The purpose of the central bank is to provide monetary transfers between banks and guarantee the liquidity of the banking system by holding capital reserves for member banks in their respective settlement accounts.When a transfer between Bank A and Bank B needs to happen the central bank debits Bank A’s settlement account by the transfer amount and credit’s Bank B’s settlement account.This is performed over the SWIFT network as follows:

1. Bank A sends a payment request into the SWIFT Network.2. SWIFT sends a settlement / authorisation request to the central banks Real Time Gross Settlement System

(RTGS).3. The central Banks debits Bank A’s settlement account and credits Bank B’s settlement account with the transfer

amount.4. The Central bank sends out a transfer approval – stating funds are settled.5. The SWIFT network sends a settlement notification to both banks. Bank B can immediately credit the recipients

bank account with cleared funds.

SWIFT NetworkBank A Bank B

Central Bank (RTGS)

Bank A SettlementAccount

Bank B SettlementAccount

Bank A CustomerAccounts Bank B Customer

Accounts

1

2

3

5

4

Recipients

5

Sender

Page 19: Blockchain 101

03/05/2023 Esselltee Ltd, 521 Bath Road, Bristol BS3133HH; Telephone 07710 813601; Email [email protected]

19

P2P Payments with Distributed LedgersTo replace CHAPs with a blockchain and distributed ledger solution the public ledger shown opposite would be required.The ledger would need to hold individual blockchains that represent:1. Each customer account made up of blocks that represent

the balance and transactions on each account.2. Each settlement account made up of blocks representing

the balance and transactions on each account.3. Smart contracts define the operations that can be

performed on the respective accounts.Notes: I. Capital reserves are still held in the central bank for Bank

A and B – Liquidity is not an issue. II. The consumers capital is held by their bank individually

Bank A CustomerAccount

Bank B Customer Account

Distributed Transaction Ledger

Bank A SettlementAccount Bank B Settlement

Account

Page 20: Blockchain 101

03/05/2023 Esselltee Ltd, 521 Bath Road, Bristol BS3133HH; Telephone 07710 813601; Email [email protected]

20

P2P Payments with Distributed LedgersWith the distributed ledger described on the previous slide in place the CHAPS transaction shown before could be completed by Bank A alone as follows.1. Bank A debits the sender’s account balance

by adding a new block on sender’s account blockchain with the distributed ledger.

2. Bank A debits its settlement account by adding a new block to its settlement account blockchain on the distributed ledger

3. Bank A credits Bank B’s settlement account by adding a new block to its settlement account blockchain on the distributed ledger

4. Bank A credits the sender’s account balance by adding a new block on the recipient’s account blockchain on the distributed ledger.

Bank A Bank B

Central Bank

Bank A CustomerAccount

Bank B Customer Account

Recipients

Distributed Transaction Ledger

1

3

2Bank A SettlementAccount Bank B Settlement

Account

4

The Distributed Ledger and blockchains make sure all transactions are recorded indelibly. Actions 1-4 can be performed simultaneously and in real timeThe central bank can always reverse a transaction if regulatory rules are broken. Smart Contracts ensure that the operations performed by bank A on the distributed ledger are performed in a uniform way.

Sender

Page 21: Blockchain 101

03/05/2023 Esselltee Ltd, 521 Bath Road, Bristol BS3133HH; Telephone 07710 813601; Email [email protected]

21

Now Think BackFor Example Bitcoin:

• Is an implementation of a Blockchain & DLT• Is was developed by a Satoshi Nakamoto – Not a real guy• The blocks represent collections of Bitcoins , record transactions made with them and define who owns them• Creators and approvers are called Miners• Mining uses complex CPU intensive algorithms.• Any one can mine Bitcoins or perform POW as long as:

• They use official Bitcoin software – Complex algorithms – Hi computing power• Can afford the power requirements involved in the mining process

• The miner gains possession of the Bitcoin and he has the right to use it and its inherent value• POW miners are rewarded in Bitcoins for the work they do approving blocks

Value Hypothesis• Mining is power hungry so miners don’t get them for free• The theory is (like any work) you expend energy to create value – Value can later be exchanged for other goods and services• To create Bitcoins you use a “powerful computers and lots of electricity” – That is what the miners input, the output is the coin• The value of the coin then fluctuates based on normal economic rules like:

• Total coins in circulation• What people are will to give you for them

Facts• Bitcoins currently cost more to mine then they are worth in $US • When Bitcoins are traded the block that represents it must be signed with the new owner private key• If the owner of a Bitcoin loses their private keys the coin is lost as they cant prove they own it• As of 6 February 2016, there were 15.2 million Bitcoins in circulation• 1/3 of all Bitcoins mined to date may be lost• There will only ever be 21m bit coins in circulation