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

hakone_hackthon

Taiki
August 27, 2018
72

 hakone_hackthon

Taiki

August 27, 2018
Tweet

Transcript

  1. Blockchain΁ͷظ଴ “The technology most likely to change the next decade

    of business is not the social web, big data, the cloud, robotics, or even artificial intelligence. It’s the blockchain, the technology behind digital currencies like Bitcoin.” )BSWBSE#VTJOFTT3FWJFX%PO5BQTDPU
  2. Blockchain΁ͷظ଴ ‘’Bitcoin at its most fundamental level is a breakthrough

    in computer science —one that builds on 20 years of research into cryptographic currency’’ •— Marc Andreessen
  3. Bitcoin͕ղ͖͔ͨͬͨ໰୊ A peer to peer version of electronic cash would

    allow online payments to be sent directly from one party to another without going through a financial institution. ࣗ෼ͷ͓ۚΛ୭ʹ΋ࢭΊΒΕΔ͜ͱແࣗ͘෼ͷ޷͖ͳλΠϛϯάͰ ૹۚ͢Δʹ͸Ͳ͏͢Ε͹Α͍͔ʁ
  4. Blockchain is a public distributed ledger, in which all who

    choose to participate in it have autonomy to access it. Simply put, a blockchain is like spreadsheet anyone can access. Every participate has a copy of the spreadsheet and its responsible for keeping it up to date What is a block chain
  5. ৘ใηΩϡϦςΟʔͷࡾେཁ݅(CIA) 1,ػີੑ 2,׬શੑ 3,Մ༻ੑ confidentiality integrity Availability ਖ਼౰ͳݖརΛ͍࣋ͬͯͳ͍ਓ Ҏ֎͕ΞΫηεͰ͖ͳ͍ ਖ਼౰ͳݖརΛ͍࣋ͬͯͳ͍

    ਓҎ֎͕มߋͰ͖ͳ͍(վ᜵͞Εͳ͍) ඞཁͳ࣌ʹΞΫηεͰ͖Δ Blockchain͸͍ͭͰ΋࢖͑ͯվ᜵ෆՄೳੑ͕ߴ͍͕openͰ͋Δɻ
  6. 24 Public Consortium Private ϊʔυ ෼ࢄ͢Δ ෼ࢄ͠ͳ͍ ෼ࢄ͠ͳ͍ ϒϩοΫνΣʔϯӾཡ Φʔϓϯ

    ੍ݶՄೳ ੍ݶՄೳ ϒϩοΫੜ੒ PoW΍PoSͳͲͷ೉қ ౓ͷߴ͍࢓૊Έ͕ඞཁ ೚ҙʢϒϩοΫੜ੒ओମ Λݶఆͤ͞Δ৔߹͕ଟ ͍ʣ ೚ҙ ؅ཧऀ ඞཁͳ͍ ඞཁ ඞཁ Ϣʔεέʔε Bitcoin, EthereumͳͲ TendermintͳͲ اۀ಺σʔλ؅ཧͳͲ HyperledgerͳͲ
  7. 25 Public Consortium Private ϊʔυ ෼ࢄ͢Δ ෼ࢄ͠ͳ͍ ෼ࢄ͠ͳ͍ ϒϩοΫνΣʔϯӾཡ Φʔϓϯ

    ੍ݶՄೳ ੍ݶՄೳ ϒϩοΫੜ੒ PoW΍PoSͳͲͷ೉қ ౓ͷߴ͍࢓૊Έ͕ඞཁ ೚ҙʢϒϩοΫੜ੒ओମ Λݶఆͤ͞Δ৔߹͕ଟ ͍ʣ ೚ҙ ؅ཧऀ ඞཁͳ͍ ඞཁ ඞཁ Ϣʔεέʔε Bitcoin, EthereumͳͲ TendermintͳͲ اۀ಺σʔλ؅ཧͳͲ HyperledgerͳͲ ؅ཧऀ͕͍Δ৔߹ɺͦͷ؅ཧऀʹΑͬͯBlockchain಺ͷσʔλΛ؅ཧ͢Δ͜ͱ͕Ͱ͖ͯ͠·͏ɻ
  8. 35 ൿີ伴ͱެ։伴 Source : mastering bitcoin ൿີ伴͸ɺ16ਐ๏ͷ64ܻͱͳ͍ͬͯΔɻ16ͷ64৐ɻ 1664 ≈ 1077

    Ӊ஦ʹଘࡏ͢Δݪࢠͷ਺ͱಉ͡ͰɺӉ஦ͷத͔ΒಛఆͷݪࢠΛݟ͚ͭΔ ͘Β͍೉͍͠ɻ
  9. 36 ECDSAʢElliptic Curve Digital Signature Algorithmʣ Source : mastering bitcoin

    ପԁۂઢ Txʹඞཁͳిࢠॺ໊͸ɺൿີ伴Λପԁۂઢ্ͷ εΧϥʔഒࢉΛ༻͍ͯ࡞੒͞ΕΔɻ ެ։伴͔Βൿີ伴ͷ࡞੒͸ݶΓͳ͘೉͍͠ɻ G_1 G_2 y2 = x3 + 7
  10. 37 ECDSAʢElliptic Curve Digital Signature Algorithmʣ ପԁۂઢ G_1 G_2 G_3

    Txʹඞཁͳిࢠॺ໊͸ɺൿີ伴Λପԁۂઢ্ͷ εΧϥʔഒࢉΛ༻͍ͯ࡞੒͞ΕΔɻ ެ։伴͔Βൿີ伴ͷ࡞੒͸ݶΓͳ͘೉͍͠ɻ G_1 + G_2 = G_3ͰՃ๏Λఆٛ͢Δɻ ͜ͷͱ͖ɺG_1, G_2͕༗ཧ਺Ͱ͋Ε͹G_3΋༗ཧ਺ Tx͝ͱʹr*Gͷ஋ΛٻΊΔɺ͜Ε͕signatureʹͳΔ y2 = x3 + 7 https://zoom-blc.com/what-is-ecdsa
  11. 41 ϒϩοΫͷߏ଄ TX time stump TX TX TX TX TX

    TX TX TX TX TX TX TX TX TX TX TX TX TX
  12. 42 ϒϩοΫͷߏ଄ TX this block’s hash time stump TX TX

    TX TX TX TX TX TX TX TX TX TX TX TX TX TX TX TX
  13. 44 ϒϩοΫͷߏ଄ previous block’s hash TX this block’s hash time

    stump TX TX TX TX TX TX TX TX TX TX TX TX TX TX TX TX TX TX
  14. 45 ϒϩοΫͷߏ଄ previous block’s hash nonce TX this block’s hash

    time stump difficulty TX TX TX TX TX TX TX TX TX TX TX TX TX TX TX TX TX TX
  15. 46 Former block’s hash value Former block’s hash value Former

    block’s hash value Nonce Nonce Nonce Transaction Transaction Transaction Transaction Transaction Transaction Transaction Transaction Transaction Transaction Transaction Transaction • A block is including transactions in a certain period of time. • A block is including the former block’s hash value. 
 Therefore, it looks like a chain structure. • The hash is recomputed for each value until a hash containing the 
 required number of zero bits is found. (set by “the difficulty”) The Structure of Blocks
  16. Nonce͸ϚΠφʔ͕ࣗ༝ʹܾΊΒΕΔՄมͳ஋ɺ ৭ʑͳ஋Λ୅ೖͯ͠ଞͷϚΠφʔΑΓ΋ઌʹϒϩοΫΛ ੜ੒͢Δ͜ͱ͕Ͱ͖ͨΒใु͕΋Β͑Δɻ Nonce : A Other data : fnb435yBHJV

    Nonce : B Other data : fnb435yBHJV Nonce : C Other data : fnb435yBHJV Hash ☓ 21333508fdw9cujsighwehɾɾɾ Hash ☓ 00avfea32452jkvfbjak463b4ɾɾɾ Hash ◦ 000000dw9cujsighwehɾɾɾ
  17. Nonce : C Other data : fnb435yBHJV Hash 000000dw9cujsighwehɾɾɾ Targetͷnonce͸ϋογϡ஋Λܭࢉͨ࣌͠ʹɺ

    ઌ಄ʹ0͕ ྫ͑͹5ݸฒΜͩΒ੒ޭͱఆٛ͢Δɻ=> Blockੜ੒ͱใु Hash(blockchain, ⋯, nonce) ≤ target(difficulty)
  18. 51 PoW (Workflow Systemᶃ) Participants : A, B, C, D,

    E, F, G Miners : α, β, γ, δ, ε A B C D E F α β γ ε δ Blockchain
  19. 52 PoW (Workflow Systemᶄ) A send 10BTC to C, C

    send 5BTC to F, E send 8BTC to D A→C, C→F, E→ D A B C D E F α β γ ε δ
  20. 53 PoW (Workflow Systemᶅ) A B C D E F

    α β γ ε δ The transactions are broadcasted to participants and miners at the same time. Transactions like A→C, C→F, E→D are also the same.
  21. 54 PoW (Workflow Systemᶆ) A B C D E F

    α β γ ε δ The miners which received transactions confirm signatures and start to find Nance.
  22. 55 PoW (Workflow Systemᶇ) A B C D E F

    α β γ ε δ The one who finds Nonce will make a new block and broadcast it to all participants and miners.
  23. 56 PoW (Workflow Systemᶈ) A B C D E F

    α β γ ε δ Miners which received the block confirm it and add it to own blocks.
  24. Proof of Stake Other data : fnb435yBHJV Hash 000000dw9cujsighwehɾɾɾ ྫ͑͹ɺStakeʹԠͯ͡೉қ౓͕ҟͳΓɺΑΓଟ͘Stakeͯ͠ਓ΄Ͳ

    ؆୯ʹBlockΛੜ੒͢Δ͜ͱ͕Ͱ͖Δɻ Hash(blockchain, ⋯) ≤ target(difficulty, stake, time)
  25. PBFT(Practical Byzantine Fault Tolerance) ߹ҙ͕ϏβϯνϯͳৼΔ෣͍Λ͢ΔϓϩηεʹΑܾͬͯ·ͬͯ͠·Θͳ͍ɻ N − F > N

    − F 2 + F T > N − F 2 + F Ϗβϯνϯʹͳ͍ͬͯͳ͍ϊʔυ͚ͩͰ΋߹ҙܗ੒͕Ͱ͖Δɻ N − F ≥ T ͕ͨͬͯ͠ɺ N:શମͷϊʔυ਺ɹF:Ϗβϯνϯͳϊʔυ T:ਖ਼ৗʹίϯηϯαεΛͱΔͷʹඞཁͳϊʔυ
  26. 69 ϒϩοΫνΣʔϯͬͯඞཁͳΜ͚ͩͬʁ σʔλϕʔε͸ඞཁ͔ʁ ϒϩοΫ νΣʔ ϯ͡Ό ͳͯ͘ྑ͘ ͳ͍ʁ Y N

    ෳ਺ͷεςʔΫϗϧμʔ ͕ؔΘΔ͔ʁ Y ͦΕΒͷεςʔΫϗϧμʔ͸৴པ Ͱ͖Δ͔ʁ Y ͦΕΒΛ౷߹͢Δ͜ͱ͸Ͱ͖Δ͔ʁ Y N N N ୈࡾऀΛ৴པͰ͖Δ͔ʁ Y N ϒϩοΫνΣʔϯΛ ಋೖ͢Δίετͱޮ ༻͸ׂʹ͋͏͔ʁ N Y ϒϩοΫ νΣʔϯ࢖ ͓͏͔ʂ ࣗ෼͕ϒϩοΫνΣʔ ϯ্ͷه࿥Λॻ͍ͨ ΓಡΜͩΓΛ͢Δඞ ཁੑ͸͋Δ͔ʁ ࢀߟɿDistributed.comɹBlockcahin Capital LLC Y N ίϯηϯαε͸ෳ਺ ͷϓϨʔϠʹΑͬͯ ܾఆ͞ΕΔʁ Y N ޮ཰ΑΓ΋ɺվ͟Μ ଱ੑ΍ΞΫηαϏϦ ςΟʔͷํ͕େࣄʁ N ίϯιʔγ ΞϜ ϒϩοΫ νΣʔϯʂ ϓϥΠϕʔ τ ϒϩοΫ νΣʔϯʂ ύϒϦοΫ ϒϩοΫ νΣʔϯʂ Y
  27. Hyperledger Fabricͱ͸ ΞϓϦέʔγϣϯ؀ڥ ϢʔβʔͷΞΫηε App Blockchain chaincode σʔλͷ֨ೲઌ BC΁ͷॻ͖ࠐΈ Chain

    code ΞϓϦέʔγϣϯͷॲཧʹඞཁͳ ChainCode Λ͋Β ͔͡Ί༻ҙͯ͠ɺ σʔλͷ֨ೲઌ ͦͷ ChainCode ܦ༝ͰಡΈॻ͖ ߋ৽ݕࡧɾɾɾ BlockchainΞϓϦέʔγϣϯ
  28. Hyperledger Fabricͱ͸ ΞϓϦέʔγϣϯ؀ڥ ϢʔβʔͷΞΫηε App Blockchain chaincode σʔλͷ֨ೲઌ BC΁ͷॻ͖ࠐΈ Chain

    code Blockchain্ʹσϓϩΠ͢Δ Code( ChainCode ) ͸GoͰ࣮૷͢Δඞཁ͕͋Γɺந৅తɻ BlockchainΞϓϦέʔγϣϯ