Share
Embed
Understanding Blockchain
Slides of PHP Reboot Meetup on Understanding Blockchain.
Kapil Sharma
April 20, 2019
Transcript
68 slides
-
PHP Reboot • 14+ Years’ experience in Web Application development.
• Open Source Contributor. • Managing PHP Reboot, Developers community in Pune since 2014. • Twitter: kapilsharmainfo • Linked In: kapilsharmainfo • Slides: speakerdeck.com/kapilsharma • YouTube: bit.ly/kapilyoutube Te c hni ca l A rc hi te c t at Ea ste r n E nte r p r i s e . Kapil Sharma Kapil Sharma 2 -
PHP Reboot Ch a i n of b l oc
k BLOCK CHAIN Add a footer 4 Bl oc k = Data = = = = = = = = = = = = = Data : “ Na m e ” : ” Ka pi l S ha r m a ”. H a s h: 1234567890A BCDEF ( H exa d e c i m a l nu m b e r ) P revi ous H a s h: A BCDEF 0123456789 ( H exa d e c i m a l nu m b e r ) Data: One Previous: 0000 Hash: 1234 Data: Two Previous: 1234 Hash: 3456 Data: Three Previous: 3456 Hash: 12AB -
PHP Reboot Kapil Sharma 5 Cryptography Immutable Ledger P2P Network
Mining Consensus Protocol Signature -
PHP Reboot Kapil Sharma 6 Cryptography Immutable Ledger P2P Network
Mining Consensus Protocol Signature -
BC BLOCK CHAIN Cryptography Let ’s m a ke a
F i nge r pr i nt . -
PHP Reboot U nde rsta ndi ng S H A
256 Add a footer 9 Hash Cryptography •Cryptography Algorithm. •Requirements: • One way • Deterministic • Fast computation • The Avalanche effect • Must withstand collisions -
PHP Reboot Kapil Sharma 10 Cryptography Immutable Ledger P2P Network
Mining Consensus Protocol Signature -
PHP Reboot Kapil Sharma 11 Cryptography Immutable Ledger P2P Network
Mining Consensus Protocol Signature -
BC BLOCK CHAIN Immutable Ledger A re gi st r
y, t h at i s p e r m a n e nt . -
PHP Reboot A re gi st r y, t h
at i s p e r m a n e nt . Kapil Sharma 13 Immutable Ledger -
PHP Reboot A re gi st r y, t h
at i s p e r m a n e nt . Kapil Sharma 14 Immutable Ledger ₹ H om e re gi st r y exa m pl e . -
PHP Reboot A re gi st r y, t h
at i s p e r m a n e nt . Kapil Sharma 15 Immutable Ledger ₹ H om e re gi st r y exa m pl e . -
PHP Reboot A re gi st r y, t h
at i s p e r m a n e nt . Kapil Sharma 16 Immutable Ledger ₹ H om e re gi st r y exa m pl e . -
PHP Reboot A re gi st r y, t h
at i s p e r m a n e nt . Kapil Sharma 17 Immutable Ledger ₹ H om e re gi st r y exa m pl e . Problems? -
PHP Reboot A re gi st r y, t h
at i s p e r m a n e nt . Kapil Sharma 18 Immutable Ledger Bl oc k c ha i n exa m pl e . Data: PH: 000 Hash: 123 Data: PH: 123 Hash: 234 Data: PH: 234 Hash: 345 -
PHP Reboot A re gi st r y, t h
at i s p e r m a n e nt . Kapil Sharma 19 Immutable Ledger Bl oc k c ha i n exa m pl e . Data: PH: 000 Hash: 123 Data: PH: 123 Hash: 234 Data: PH: 234 Hash: 345 Data: PH: 345 Hash: 456 -
PHP Reboot A re gi st r y, t h
at i s p e r m a n e nt . Kapil Sharma 20 Immutable Ledger Bl oc k c ha i n exa m pl e . Data: PH: 000 Hash: 123 Data: PH: 123 Hash: 234 Data: PH: 234 Hash: 345 Data: PH: 345 Hash: 456 Data: PH: 456 Hash: 567 Data: PH: 567 Hash: 678 -
PHP Reboot A re gi st r y, t h
at i s p e r m a n e nt . Kapil Sharma 21 Immutable Ledger Bl oc k c ha i n exa m pl e . Data: PH: 000 Hash: 123 Data: PH: 123 Hash: 234 Data: PH: 234 Hash: 345 Data: 1 PH: 345 Hash: 543 Data: PH: 456 Hash: 567 Data: PH: 567 Hash: 678 -
PHP Reboot A re gi st r y, t h
at i s p e r m a n e nt . Kapil Sharma 22 Immutable Ledger Bl oc k c ha i n exa m pl e . Data: PH: 000 Hash: 123 Data: PH: 123 Hash: 234 Data: PH: 234 Hash: 345 Data: 1 PH: 345 Hash: 543 Data: PH: 456 Hash: 567 Data: PH: 567 Hash: 678 -
PHP Reboot A re gi st r y, t h
at i s p e r m a n e nt . Kapil Sharma 23 Immutable Ledger Bl oc k c ha i n exa m pl e . Data: PH: 000 Hash: 123 Data: PH: 123 Hash: 234 Data: PH: 234 Hash: 345 Data: 1 PH: 345 Hash: 543 Data: PH: 456 Hash: 567 Data: PH: 567 Hash: 678 INVALID -
PHP Reboot A re gi st r y, t h
at i s p e r m a n e nt . Kapil Sharma 24 Immutable Ledger P robl e m s 1. Wh at stops u s e re ca l c u l ate h a s h of fol l owi n g b l oc ks ? -
PHP Reboot A re gi st r y, t h
at i s p e r m a n e nt . Kapil Sharma 25 Immutable Ledger P robl e m s Data: PH: 000 Hash: 123 Data: PH: 123 Hash: 234 Data: PH: 234 Hash: 345 Data: 1 PH: 345 Hash: 543 Data: PH: 456 Hash: 567 Data: PH: 567 Hash: 678 1. Wh at stops u s e re ca l c u l ate h a s h of fol l owi n g b l oc ks ? -
PHP Reboot A re gi st r y, t h
at i s p e r m a n e nt . Kapil Sharma 26 Immutable Ledger P robl e m s Data: PH: 000 Hash: 123 Data: PH: 123 Hash: 234 Data: PH: 234 Hash: 345 Data: 1 PH: 345 Hash: 543 Data: PH: 543 Hash: 765 Data: PH: 567 Hash: 678 1. Wh at stops u s e re ca l c u l ate h a s h of fol l owi n g b l oc ks ? -
PHP Reboot A re gi st r y, t h
at i s p e r m a n e nt . Kapil Sharma 27 Immutable Ledger P robl e m s 1. Wh at stops u s e re ca l c u l ate h a s h of fol l owi n g b l oc ks ? Data: PH: 000 Hash: 123 Data: PH: 123 Hash: 234 Data: PH: 234 Hash: 345 Data: 1 PH: 345 Hash: 543 Data: PH: 543 Hash: 765 Data: PH: 765 Hash: 876 -
PHP Reboot A re gi st r y, t h
at i s p e r m a n e nt . Kapil Sharma 28 Immutable Ledger P robl e m s 1. Wh at stops u s e re ca l c u l ate h a s h of fol l owi n g b l oc ks ? Data: PH: 000 Hash: 123 Data: PH: 123 Hash: 234 Data: PH: 234 Hash: 345 Data: 1 PH: 345 Hash: 543 Data: PH: 543 Hash: 765 Data: PH: 765 Hash: 876 2. If we c h a n ge d a b l oc k m i sta ke n l y, h ow d o we re cove r i t ? -
PHP Reboot Kapil Sharma 29 Cryptography Immutable Ledger P2P Network
Mining Consensus Protocol Signature -
PHP Reboot Kapil Sharma 30 Cryptography Immutable Ledger P2P Network
Mining Consensus Protocol Signature -
PHP Reboot M u l t i p l e
p e e r cop i e s of s a m e b l oc k c h a i n . Kapil Sharma 31 P2P Network P robl e m s 1. Wh at stops u s e re ca l c u l ate h a s h of fol l owi n g b l oc ks ? Data: PH: 000 Hash: 123 Data: PH: 123 Hash: 234 Data: PH: 234 Hash: 345 Data: 1 PH: 345 Hash: 543 Data: PH: 543 Hash: 765 Data: PH: 765 Hash: 876 2. If we c h a n ge d a b l oc k m i sta ke n l y, h ow d o we re cove r i t ? -
PHP Reboot 32 Data: PH: 000 Hash: 123 Data: PH:
123 Hash: 234 Data: PH: 234 Hash: 345 Data: 1 PH: 345 Hash: 543 Data: PH: 543 Hash: 765 Data: PH: 765 Hash: 876 Data: PH: 000 Hash: 123 Data: PH: 123 Hash: 234 Data: PH: 234 Hash: 345 Data: PH: 345 Hash: 456 Data: PH: 456 Hash: 567 Data: PH: 567 Hash: 678 Data: PH: 000 Hash: 123 Data: PH: 123 Hash: 234 Data: PH: 234 Hash: 345 Data: PH: 345 Hash: 456 Data: PH: 456 Hash: 567 Data: PH: 567 Hash: 678 M u l t i p l e p e e r cop i e s of s a m e b l oc k c h a i n . P2P Network -
PHP Reboot M u l t i p l e
p e e r cop i e s of s a m e b l oc k c h a i n . Kapil Sharma 33 P2P Network P robl e m s 1. Wh at stops u s e re ca l c u l ate h a s h of fol l owi n g b l oc ks ? Data: PH: 000 Hash: 123 Data: PH: 123 Hash: 234 Data: PH: 234 Hash: 345 Data: 1 PH: 345 Hash: 543 Data: PH: 543 Hash: 765 Data: PH: 765 Hash: 876 2. If we c h a n ge d a b l oc k m i sta ke n l y, h ow d o we re cove r i t ? -
PHP Reboot Kapil Sharma 34 Cryptography Immutable Ledger P2P Network
Mining Consensus Protocol Signature -
PHP Reboot Kapil Sharma 35 Cryptography Immutable Ledger P2P Network
Mining Consensus Protocol Signature -
PHP Reboot Li ke i n gol d m i
ni ng. Kapil Sharma 36 Mining -
PHP Reboot Li ke i n gol d m i
ni ng. Kapil Sharma 37 Mining BLOCK # 1 HASH: 12345 Previous Hash: 01234 DATA -
PHP Reboot Li ke i n gol d m i
ni ng. Kapil Sharma 38 Mining BLOCK # 1 HASH: 12345 Previous Hash: 01234 DATA Nonce -
PHP Reboot Li ke i n gol d m i
ni ng. Add a footer 39 Mining BLOCK # 1 HASH: 12345 Previous Hash: 01234 DATA Nonce -
PHP Reboot S H A 256 Kapil Sharma 40 Hash
Big 64 digit Hexa-decimal number -
PHP Reboot F i ndi ng t he gol de
n H A S H Kapil Sharma 41 Mining Big 64 digit Hexa-decimal number Smallest Largest -
PHP Reboot F i ndi ng t he gol de
n H A S H Kapil Sharma 42 Mining Big 64 digit Hexa-decimal number Smallest Largest 1234567890ABCDEF1234567890ABCDEF 1234567890ABCDEF1234567890ABCDEF -
PHP Reboot F i ndi ng t he gol de
n H A S H Kapil Sharma 43 Mining Big 64 digit Hexa-decimal number Smallest Largest 1234567890ABCDEF1234567890ABCDEF 1234567890ABCDEF1234567890ABCDEF 001234567890ABCDEF1234567890ABCD EF1234567890ABCDEF1234567890ABCD -
PHP Reboot F i ndi ng t he gol de
n H A S H Kapil Sharma 44 Mining Big 64 digit Hexa-decimal number Smallest Largest 1234567890ABCDEF1234567890ABCDEF 1234567890ABCDEF1234567890ABCDEF 001234567890ABCDEF1234567890ABCD EF1234567890ABCDEF1234567890ABCD 000034567890ABCDEF1234567890ABCD EF1234567890ABCDEF1234567890ABCD -
PHP Reboot F i ndi ng t he gol de
n H A S H Kapil Sharma 45 Mining Big 64 digit Hexa-decimal number Smallest Largest 1234567890ABCDEF1234567890ABCDEF 1234567890ABCDEF1234567890ABCDEF 001234567890ABCDEF1234567890ABCD EF1234567890ABCDEF1234567890ABCD 000034567890ABCDEF1234567890ABCD EF1234567890ABCDEF1234567890ABCD Target -
PHP Reboot F i ndi ng t he gol de
n H A S H Add a footer 46 Mining BLOCK # 1 HASH: 12345 Previous Hash: 01234 DATA Smallest Largest Target -
PHP Reboot Kapil Sharma 47 Cryptography Immutable Ledger P2P Network
Mining Consensus Protocol Signature -
PHP Reboot Kapil Sharma 48 Cryptography Immutable Ledger P2P Network
Mining Consensus Protocol Signature -
PHP Reboot S ol vi ng t he P 2P
net wor k probl e m s . Kapil Sharma 49 Consensus Protocol P robl e m s 1. F ra ud ( A ddi ng wrong bl oc k ) 2. Two b l oc ks a d d e d at a s a m e t i m e . -
PHP Reboot Di ffe re nt ways of s ol
vi n g F ra u d P rob l e m Kapil Sharma 50 Types of Consensus Protocol Type of Cons e ns us P rotocol s 1. P roof of Wor k ( P OW) ( Bi tcoi n) . 2. P roof of S ta ke ( P O S ) ( S m a r t Cont ra c t s ) 3. O t he rs . -
PHP Reboot P roof of Wor k Kapil Sharma 51
Consensus Protocol H a s h ge n e rate d by s ol vi n g Cr yptogra p h i c Ch a l l e n ge . BLOCK # 1 HASH: 12345 Previous Hash: 01234 DATA Smallest Largest Target F i na nc i a l Inc e nt i ve 1. M i n e coi n s . 2. Tra n s a c t i on fe e . -
PHP Reboot Two b l oc ks a d d
e d at a s a m e t i m e Byza nt i ne fa u l t Tol e ra nc e Kapil Sharma 52 Consensus Protocol -
PHP Reboot H ow t hey s ol ve d
i t ? Kapil Sharma 53 Byzantine General’s Problem -
PHP Reboot H ow t hey s ol ve d
i t ? Kapil Sharma 54 Byzantine General’s Problem -
PHP Reboot H ow t hey s ol ve d
i t ? Kapil Sharma 55 Byzantine General’s Problem General Commander 1 Commander 2 Commander 3 -
PHP Reboot H ow t hey s ol ve d
i t ? Kapil Sharma 56 Byzantine General’s Problem General Commander 1 Commander 2 Commander 3 -
PHP Reboot H ow t hey s ol ve d
i t ? Kapil Sharma 57 Byzantine General’s Problem General Commander 1 Commander 2 Commander 3 -
PHP Reboot H ow t hey s ol ve d
i t ? Kapil Sharma 58 Byzantine General’s Problem General Commander 1 Commander 2 Commander 3 -
PHP Reboot H ow t hey s ol ve d
i t ? Kapil Sharma 59 Byzantine General’s Problem General Commander 1 Commander 2 Commander 3 -
PHP Reboot Def i n i t i on .
Kapil Sharma 60 Byzantine fault tolerance If the fraud node is less than 1/3rd, network may reach the consensus. -
PHP Reboot S ol vi ng t he P 2P
net wor k probl e m s . Kapil Sharma 61 Consensus Protocol P robl e m s 1. F ra ud ( A ddi ng wrong bl oc k ) 2. Two b l oc ks a d d e d at a s a m e t i m e . -
PHP Reboot Kapil Sharma 62 Cryptography Immutable Ledger P2P Network
Mining Consensus Protocol Signature -
PHP Reboot Kapil Sharma 63 Cryptography Immutable Ledger P2P Network
Mining Consensus Protocol Signature -
PHP Reboot En s u re m e s s
a ge i s cor re c t . Kapil Sharma 64 (Digital) Signature P ubl i c a nd P r i vate keys 1. P r i vate key – Kn own onl y to you . 2. P ubl i c key – G e n e rate d f rom p r i vate key a n d di st r i bute d to t h e wh ol e wor l d . 1. Di st r i b u te you r p u b l i c key ( T h os e wh o n e e d to ve r i f y) 2. S i gn you r d oc u m e nt ( u s i n g p r i vate key) 3. S e n d d oc u m e nt a n d d i gi ta l s i gn at u re . 4. Re c e i ve r m ay ve r i f y d i gi ta l s i gn at u re by p u b l i c key. -
PHP Reboot Kapil Sharma 65 Cryptography Immutable Ledger P2P Network
Mining Consensus Protocol Signature -
PHP Reboot Kapil Sharma 66 Cryptography Immutable Ledger P2P Network
Mining Consensus Protocol Signature -
PHP Reboot T ha nks to a nde rs 94
( G i t H ub) Kapil Sharma 67 Code examples github.com/anders94/blockchain-demo github.com/anders94/public-private-key-demo -
Thank You. Kapil Sharma • Twitter: kapilsharmainfo • Linked In:
kapilsharmainfo • Website: www.phpreboot.com BC BLOCK CHAIN