Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Understanding Blockchain

Understanding Blockchain

Slides of PHP Reboot Meetup on Understanding Blockchain.

Kapil Sharma

April 20, 2019
Tweet

More Decks by Kapil Sharma

Other Decks in Technology

Transcript

  1. 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
  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
  3. 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
  4. BC BLOCK CHAIN Immutable Ledger A re gi st r

    y, t h at i s p e r m a n e nt .
  5. 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
  6. 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 .
  7. 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 .
  8. 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 .
  9. 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?
  10. 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
  11. 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
  12. 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
  13. 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
  14. 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
  15. 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
  16. 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 ?
  17. 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 ?
  18. 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 ?
  19. 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
  20. 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 ?
  21. 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 ?
  22. 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
  23. 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 ?
  24. PHP Reboot Li ke i n gol d m i

    ni ng. Kapil Sharma 36 Mining
  25. PHP Reboot Li ke i n gol d m i

    ni ng. Kapil Sharma 37 Mining BLOCK # 1 HASH: 12345 Previous Hash: 01234 DATA
  26. 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
  27. 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
  28. PHP Reboot S H A 256 Kapil Sharma 40 Hash

    Big 64 digit Hexa-decimal number
  29. 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
  30. 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
  31. 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
  32. 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
  33. 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
  34. 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
  35. 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 .
  36. 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 .
  37. 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 .
  38. 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
  39. PHP Reboot H ow t hey s ol ve d

    i t ? Kapil Sharma 53 Byzantine General’s Problem
  40. PHP Reboot H ow t hey s ol ve d

    i t ? Kapil Sharma 54 Byzantine General’s Problem
  41. 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
  42. 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
  43. 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
  44. 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
  45. 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
  46. 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.
  47. 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 .
  48. 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.
  49. 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
  50. Thank You. Kapil Sharma • Twitter: kapilsharmainfo • Linked In:

    kapilsharmainfo • Website: www.phpreboot.com BC BLOCK CHAIN