KEMBAR78
Blockchain | PDF | Audit | Bitcoin
0% found this document useful (0 votes)
28 views144 pages

Blockchain

Uploaded by

ma2srinivas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views144 pages

Blockchain

Uploaded by

ma2srinivas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 144

Blockchain overview

IBM Skills Academy


What is blockchain?
Blockchain Working
Why is it relevant for
enterprise?

Bitcoin vs Blockchain
Blockchain Mining

Understanding Blockchain Cryptography


Actors and Components of Blockchain
Smart Contract-Create,Deploy,Invoke
Docker
Hyperledger-Fabric
Blockchain Usecases
What is Blockchain?

Blockchain

6
Stuart W. Scott
Haber Stornetta
What is blockchain?

Blockchain is a distributed, decentralized


immutable ledger which is completely
transparent.
Blockchain is a shared immutable ledger for recording the
history of transactions.

Blockchain

A business blockchain, such as IBM Blockchain and the


Linux Foundation’s Hyperledger Project, provides a
permissioned network with known identities.

6
What is Blockchain?

Ledger Book Block


A B

C
A B

C
A B

C
“ What the internet did for
communications,
blockchain will do for trusted
transactions.

- Ginni Rometty (THINK Forum 2017)

5
How Blockchain Network
Works?
Hashing
Algorithm
Hashing Algorithm

Block No.-1

Data

Prev Hash:000000000
Hash:0000D8C42

Block
Hashing Algorithm

Block No.-1

Data

Prev Hash:000000000
Hash:0000D8C42 Fingerprint
Block
Hashing Algorithm

Block No.-

Data
SHA 256

Prev Hash:
Hash:
Hashing Algorithm

Encrypt
ed data
5819E961F19967B4ECB24
Document, Audio , Video 29085E17909CFFD4DCB6
SHA256 267D0067F6CAEC22150A
etc.
7B1

This has 64
hexadecimal characters.
Each character is of 4 bits.
So in total it has 64* 4 bits
i.e. 256 bits.
Hashing Algorithm

Block No.-1

Data

Prev Hash:000000000
Hash:0000D8C42
Hashing Algorithm

Block No.-1 Block No.-2

Data Data

Prev Hash:000000000 Prev Hash:0000D8C42


Hash:0000D8C42 Hash:00003A459
Hashing Algorithm

Block No.-1 Block No.-2 Block No.-3

Data Data Data

Prev Hash:000000000 Prev Hash:0000D8C42 Prev Hash:00003A459


Hash:0000D8C42 Hash:00003A459 Hash:00003D45F

Genesis Block
Hashing Algorithm

Requirements of Hash Algorithm-

Data Encrypted Withstand


One Way
Data Collisions

Avalanche
Deterministic ABC 845
Effect

Fast
Computation
Blockchain is nothing but a data structure build upon the concept of Hash functions.
https://emn178.github.io/online-tools/sha256.html
Immutable Ledger
Immutable Ledger

Money Sales Deed Institution House


You
Immutable Ledger

Maintain Register

Institution Centralized Database


Immutable Ledger
Immutable Ledger

Hacker Attacks Corrupted

A B C D E F
Distributed P2P network

A B

Click to add text


E

C
Distributed P2P network

A B

C
Distributed P2P network

A B

C
Distributed P2P network

A B

C
Distributed P2P network

A B

C
Business networks and assets transfer
• An asset is anything that can be owned or controlled
to produce value, for example, goods and services.

• Assets can be:


o Tangible, for example, shipping containers,
food products, spare parts, and land
o Intangible, for example, intellectual properties
(patents and trademarks), financial (bonds and
invoices), and digital goods (music and eBook)

• Assets are transferred through business networks that


are composed of participants (for example, Each participant records transactions in ledgers.
customers, suppliers, service providers, and banks) The ledger is a log of transactions, and is the key
across regulatory and geographical boundaries. system of record for asset exchange for a business.

• Transactions describe the exchange of assets Contracts are a set of business terms that should
between participants. be met by participants before a transaction is
completed.

7
Business networks and market growth
• A market is the flow of assets across business networks:
o Public (market or car auction).
o Private (supply chain financing or bonds).

• Inefficiencies in business networks arise due to:


o Geographical and regulatory boundaries.
o Multiple ledgers that are maintained by participants
for multiple business networks.
o Participants requirements for trusted transactions.

• Business network inefficiencies reduce:


o Growth of markets.
o Growth of wealth that is generated from markets. Blockchain for business is a team
sport.

8
Problem…
Participant
B’s records
Participant Bank
A’s records records

Insurer Regulator Auditor


records records records

… inefficient, expensive, and vulnerable


9
A shared, replicated, permissioned ledger …
Participant
B’s records
Participant Bank
A’s records records

Blockchain

Insurer Regulator Auditor


records records records

… with consensus, provenance, immutability, and finality


10
Blockchain for business requirements

Append-only Shared Smart Business


distributed system of ledger Contract terms that are
records that are
run with
shared across
transactions.
business networks.

Transactions Transactions are


are secure with provably endorsed
appropriate by relevant
visibility. participants.
Privacy Accountability

11
Blockchain platforms
Blockchain
Mining
How Does a Blockchain Work?
Blockchain Mining

Transaction Solve Mathematical Miner Solved Miners Verify the Block is added
Problem Problem First Validity
How Mining
works: The
Nonce
How Mining Works ?

Nonce

Target
How Mining Works ?
Nonce:
➢ The nonce is the number that blockchain miners
are solving for.
How Mining Works ?
Target:
➢Target is a number used in mining.
➢It is a number that a block hash must be below for
the block to be added on to the blockchain.
Hashing Algorithm

5819E961F19967B4ECB24
Document, Audio, Video, SHA25 29085E17909CFFD4DCB62
etc. 6 67D0067F6CAEC22150A7B
1

This has 64 hexadecimal characters.


Each character is of 4 bits.
So in total it has 64* 4 bits i.e. 256 bits.
How Mining Works ?
Hexadecimal Numbers Decimal Hexadecimal Decimal Hexadecimal
0 0 11 B
1 1 12 C
2 2 13 D
3 3 14 E
4 4 15 F
5 5
6 6
7 7
8 8
9 9
10 A
Mempool

FF3ABC Fees:0.0008
Block No.-1
D23ABC Fees:0.001
Nonce:
A21ADC Fees:0.002
Timestamp:
B24ABE Fees:0.006
Transactions:

43AFBC Fees:0.007

E23AB2 Fees:0.004
Prev Hash:000000000
F23A6C Fees:0.005 Hash:

Mempool
(Behind the scenes)
The Mining Mission
Miners aim to find a specific hash value for each new block. The first miner to discover the correct hash receives a block
reward. This reward is paid in newly minted Bitcoins. Here, the mission is to find a hash value for the new block. The miner
who finds the hash value first is rewarded with some bitcoins called block reward

1 Hash Discovery 2 Miner Reward


The process of finding the correct hash value. The reward given to the successful miner.

preencoded.png
Difficulty Level
Finding hash value is not a big deal. Every node can do that.
Therefore, a difficulty level is associated with it to make the nodes
compete with each othe

Competition
Nodes compete to solve the hash problem.

Measurement
Difficulty is a measure of the challenge.

preencoded.png
Nonce
Since the data of a block remains same, the hash is always
same. Therefore, the only possibility to try out different hash
values is by associating a nonce with the content of the
block. The nonce is an arbitrary string of 32-bit length.
Range of Nonce = 0 to 2^32 –1 ≃ 0 to 4 x10^9

Those who find hash first will broadcast the block


along with the nonce. By receiving this, others stop
mining and validate whether the received hash
satisfies the specified difficulty level. If yes, the
nodes show their acceptance by adding it to the
blockchain

preencoded.png
Mining Process: Steps
1 Transaction Verification
Verify pending transactions.

2 Block Creation
Construct a new block.

3 Nonce Iteration
Try different nonce values.

4 Hash Submission
Submit the winning hash.

preencoded.png
The Nonce

Block No.-

Nonce:

Data:

Prev Hash:
Hash:
The Nonce

Block No.-

Nonce:

Data: SHA 256

Prev Hash:
Hash:
Hash:
The Nonce

Block No.- 6

Nonce:
Data:
Kshitij->Rakesh 500 coins
Raj->Bella 200 coins
Prev Hash: 0000AB23
Hash:
The Nonce

Block No.- 6

Nonce: 23
Data:
Kshitij->Rakesh 500 coins
Raj->Bella 200 coins
Prev Hash: 0000AB23
Hash: 00001ba1
The Nonce

Block No.- 6

Nonce: 50
Data:
Kshitij->Rakesh 500 coins
Raj->Bella 200 coins
Prev Hash: 0000AB23
Hash: 0000fb12
The Nonce

Block No.- 6

Nonce: 3
Data:
Kshitij->Rakesh 500 coins
Raj->Bella 200 coins
Prev Hash: 0000AB23
Hash: 0000acc12
The Nonce

Block No.- 6

Nonce: 1001
Data:
Kshitij->Rakesh 500 coins
Raj->Bella 200 coins
Prev Hash: 0000AB23
Hash: 0000ef23
Hashing Algorithm

5819E961F19967B4ECB24290
Document, Audio, Video, SHA256 85E17909CFFD4DCB6267D00
etc. 67F6CAEC22150A7B1

This has 64
hexadecimal characters.
Each character is of 4 bits.
So in total it has 64* 4 bits
i.e. 256 bits.
How Mining Works ?

Decimal Hexadecima Decimal Hexadecimal


l
0 0 11 B
Hexadecimal Numbers 1 1 12 C
2 2 13 D
3 3 14 E
4 4 15 F
5 5
6 6
7 7
8 8
9 9
10 A
How Mining Works ?

• d2fd3930d274b202fe8e7cb431e38a8b64ec396e15f5717e60493234b0de210a
• 52d095795c1dc87ff2f6b4d9b005a1fe2cfed01103763c9443f6d4496df8e800

• 0000005432d9f64f6e05c019f9302162100163b6cdba06bd72eee35cd19aebf

Smallest- 0000000.......................0 Largest- fffffffffffff..................f


How Mining Works ?

All Possible Hashes

Block No.-6

Nonce:

Data:
RAM>Rakesh 500 coins​
Raj->Bella 200 coins
Prev Hash: 0000AB23
Hash:
How Mining Works ?

All Possible Hashes

Block No.-6 Largest

Nonce:

Data:
RAM>Rakesh 500 coins
Raj->Bella 200 coins
Prev Hash: 0000AB23
Hash:
Smallest
How Mining Works ?

All Possible Hashes

Block No.-6 Largest

Nonce:

Data:
RAM->Rakesh 500 coins​​
Raj->Bella 200 coins
Prev Hash: 0000AB23 Target('0000')
Hash:
Smallest
How Mining Works ?

All Possible Hashes

Block No.-6 Largest

Nonce:100

Data:
RAM>Rakesh 500 coins​​
Raj->Bella 200 coins
Prev Hash: 0000AB23 Target('0000')
Hash: cd19aebf
Smallest
How Mining Works ?

All Possible Hashes

Block No.-6 Largest

Nonce:76

Data:
Kshitij->Rakesh 500 coins
Raj->Bella 200 coins
Prev Hash: 0000AB23 Target('0000')
Hash: 1da81a0e
Smallest
How Mining Works ?

All Possible Hashes

Block No.-6 Largest

Nonce: 201
Data:
RAM>Rakesh 500 coins
Raj->Bella 200 coins
Prev Hash: 0000AB23 Target('0000')
Hash: b474e220
Smallest
How Mining Works ?

All Possible Hashes

Block No.-6 Largest

Nonce:512

Data:
RAM->Rakesh 500 coins
Raj->Bella 200 coins
Prev Hash: 0000AB23 Target('0000')
Hash: 0000b6aa
Smallest
Understanding Mining Difficulty

Current Target:
0000000000000000000b3ce90000000000000000000000000000
000000000000

19 leading
0's
Understanding Mining Difficulty
Q) Who adjusts the difficulty ?

To compensate for increasing hardware speed and varying


interest in running nodes over time, the proof-of-work difficulty
is determined by a moving average targeting an average
number of blocks per hour. If they’re generated too fast, the
difficulty increases. – Satoshi Nakamoto
Is Mining
that easy?
Challenges faced by Miners

Time
Electricity
Taki
Bills
ng

Start All
Mathematical Over Again
problem solving Attitude
skill

Fast
Computers
Mining
Pool
Mining Pools
Mining Pools
Mining Pools
CPUs Vs
GPUs Vs
ASCIs
CPUs Vs GPUs Vs ASCIs

CPU < 10 MH/s

GPU< 1 GH/s

ASIC> 1000 GH/s


The Halving

Event Date Block number Reward

Launch of Bitcoin 03 Jan. 2009 0 50 new XBT

1st halving 28 Nov. 2012 210’000 25 new XBT

2nd halving Note- Supply cap of Bitcoin is 21 million.


09 Jul. 2016 420’000 12.5 new XBT

3rd halving 11 May 2020 630’000 6.25 new XBT

4th halving Expected 2024 740’000 3.125 new XBT

5th halving Expected 2028 850’000 1.5625 new XBT

Maximum supply reached Expected 2140 6’930’000 0 new XBT


PRIVATE AND PUBLIC KEY
PRIVATE AND PUBLIC KEY

Private Key Public Key

Message
Verification
Function

Signature
Yes/
No
PUBLIC KEY VS
BITCOIN ADDRESS
PRIVATE AND PUBLIC KEY

Private Key Public Key

Message
Verification
Function

Signature
Yes/
No
PRIVATE AND PUBLIC KEY

Bitcoin
Private Key Public Key
Address

Message
Verification
Function

Signature
Yes/
No
SMART CONTRACT

Smart Contract
If IOT
detected a Yes Cancel delivery
temperature> and do not pay
30 degree to A.
Celsius

No
Note-Assuming
optimum Do delivery and
temperature <30 transfer money to
degree Celsius. A.
TYPES OF BLOCKCHAIN
There mainly four types of Blockchains that have
emerged after Bitcoin introduced Blockchain to the
world.

1.Public Blockchain:
2.Private Blockchain:
3.Consortium or Federated Blockchain
4.Hybrid Blockchain
Consensus
Protocol
Consensus Protocol

Prevent Attacks Competing Chain Problem


CONSENSUS PROTOCOL

• Consensus mechanisms (also known as consensus protocols or consensus algorithms)


are used to verify transactions and maintain the security of the underlying blockchain

• Types of Consenus Protocol


• 1.Proof of Work(PoW)(Bitcoin)
• 2.Proof of Stake(PoS)(Etherum)
PROOF OF WORK

• Proof of Work is one of the first consensus protocols used in blockchain applications. It is
based on computing the hash values and validating the transactions until a specified
number of trailing zeros are found in the hash value. The number that generates the
hash with the specified number of trailing zeros is known as a nonce.
CONSENSUS PROTOCOL

• Longest Chain Rule

Competing Chain Problem


CONSENSUS PROTOCOL

A B

C
CONSENSUS PROTOCOL

A B

C
CONSENSUS PROTOCOL

A B

C
CONSENSUS PROTOCOL

A B

C
CONSENSUS PROTOCOL

A B

C
CONSENSUS PROTOCOL

A B

C
CONSENSUS PROTOCOL

A B

C
CONSENSUS PROTOCOL

A B

C
CONSENSUS PROTOCOL

A B

E
Orphan Block

Orphan Block
CONSENSUS PROTOCOL

A B

C
CONSENSUS PROTOCOL

Note-

• All the transaction in the Orphan Block will be dropped and the miner that had mined the block will not get any reward.

• An orphan block is a block that has been solved within the blockchain network but was not accepted by the
network.

• There can be two miners who solve valid blocks simultaneously. The network uses both blocks until one chain
has more verified blocks than the other. Then, the blocks in the shorter chain are orphaned

• The longest chain is what individual nodes accept as the valid version of the blockchain

• The rule that nodes adopt the longest chain of blocks allows every node on the network to
agree on what the blockchain looks like, and therefore agree on the same transaction history.
STRUCTURE OF BLOCKCHAIN
• Each block has a Block header and a list of transactions as shown above.
• Go to https://www.blockchain.com/explorer to see the bitcoin block structure.
• WHAT IS A BLOCK HEADER?
• The block header is made up of metadata (data about data). It helps to verify
the validity of a block.
As you can see in the architecture diagram, the block header of a block
consists of:
• Version
• Timestamp
• Hash
• Difficulty-Level
• Nonce
• Merkle Root
• No of Transactions → Number of transaction in a block.
• Output total + Estimated transaction volume→ total amount of bitcoin that have been transferred.
• Transaction Fee → Fee taken by bitcoin network.
• Height → The 1st block has no 1, second block has no 2 and so on... 500312 is the sequence no of
this block.
• Timesatmp → The timestamp marks the time of each transaction. In a way, it proves when and what
has happened on the block.
• Relayed By → BTC TOP is the minor who has mined (validated) this block.
• Difficulty → Difficulty level to find the value of hash.
• Bits and size→ how many bits in the block and size in Kb
• Version → Bitcoin architecture version
• Nonce → nonce is random number used to generate Hash.
• Block Reward → Bitcoin, miner earned by mining this block.
NONCE RANGE

Block No.-1

Nonce:
Nonce is a 32 bit
number.
Data
Range of Nonce = 0 to 2^32 –
Prev Hash:000000000
1 ≃ 0 to 4 x10^9
Hash:0000D8C42
NONCE RANGE

SHA 256
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxx

Total number of possible hashes = 16 x 16 x......16 = 16^64 ≃


10^77
NONCE RANGE

Total valid hashed ≃ 10^77


Total number of Nonce that we can generate ≃ 4
x10^9
10^77 >>>>>4 x10^9

Q) So what the miners do when all the nonce get exhausted and miners
have not
hit the target ?
That there are not enough nonce to generate the valid
hash.
All Possible Hashes

Largest

ALL POSSIBLE NONCE

Smallest
TIMESTAMP

Block No.-1

Nonce:

Data

Prev Hash:000000000
Hash:
TIMESTAMP

Block No.-1

Nonce:

Timestamp: 1622186555
SHA 256

Data

Prev Hash:000000000
Hash:
Further examples by (selected) industry

Financial Public Sector Retail Insurance Manufacturing


• Trade Finance • Asset • Supply chain • Claims • Supply chain
Registration processing
• Cross-currency • Loyalty • Product parts
payments • Citizen Identity programs • Risk provenance
• Maintenance
• Mortgages • Medical records • Information • Asset usage tracking
sharing (supplier history
• Dispute • Medicine supply
– retailer)
Management chain • Claims file
• Food Trust
• Energy Trading • Voting

27
Shared ledger

Records all transactions across


• Shared between participants. business networks.
• Participants have their own copy
through replication.
• Permissioned, so participants see only
the appropriate transactions.
• THE shared system of record.
• Immutable due to an append-only data
structure.

12
Smart contract

Business rules that are associated


• Verifiable and signed. with the transaction.
• Business rules, which are written in
programming languages, and supported
by the blockchain technology.
• Examples:
o Defines contractual conditions under
which a bond transfer occurs.
o Defines rules on which a vehicle can be
transferred to a new owner.

13
Privacy
The ledger is shared, but
• Participants require: participants require privacy and
• Appropriate privacy and confidentiality confidentiality.
between subsets of participants.
• An identity that is not linked to a
transaction.
• Transactions must be authenticated.
• Cryptography is central to these
processes.

14
Bitcoin versus blockchain for business

• Bitcoin uses an un-permissioned public ledger:


o Defines an unregulated shadow currency.
o The first blockchain application.
o Resource-intensive.
Blockchain technology is the
infrastructure upon which
• Blockchains for business are generally
permissioned and private, and prioritize:
blockchain applications are built.
o Identity over anonymity.
o Selective endorsement over proof of work.
o Assets over cryptocurrency.

17
Example:
Supply chain

What • The provenance of each component part in complex Benefits


system is hard to track.
1. Trust increased, no authority
• Manufacturer, production date, batch, and even
"owns” provenance.
the manufacturing machine program.
2. Improvement in
system utilization.
How • Blockchain holds complete provenance details
of each component part. 3. Recalls "specific"
• Accessible by each manufacturer in the production rather than cross-fleet.
process, the aircraft owners, maintainers, and
government regulators.

22
Example:
Audit and compliance

What • Financial data in a large organization is dispersed Benefits


throughout many divisions and geographies.
1. Lowers cost of audit and
• Audit and Compliance needs an indelible record of all regulatory compliance.
key transactions over a reporting period.
2. Provides “seek and find”
access to auditors and
How • Blockchain collects transaction records from a diverse regulators.
set of financial systems.
3. Changes the nature of
• Append-only and tamperproof qualities create a high-
confidence financial audit trail. compliance from
passive to active.
• Privacy features ensure authorized user access.
25
Actors in Blockchain Management
Applicability

Industry: Technology and Industry: Finance


Industry: Retail
Consulting
Application: Developed its own
Application: Uses blockchain to improve
Application: IBM Blockchain blockchain platform, Quorum, to
food traceability and safety by tracking the
helps businesses build enhance transaction security and
journey of food from farm to store
trusted networks to track efficiency.
assets and streamline
processes
EXIT JOB ROLES
JOB ROLES

You might also like