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

MasteringBitcoin 第5章トランザクション

MasteringBitcoin 第5章トランザクション

ビットコインとか勉強会#29 (2019/04/22) で発表した内容です。
https://cryptocurrency.connpass.com/event/126164/

Yusuke Egami

April 23, 2019
Tweet

More Decks by Yusuke Egami

Other Decks in Technology

Transcript

  1. ϚΠφʔ ϒϩοΫ ʢϊʔυʣ ϚΠφʔ ʢϊʔυʣ ϚΠφʔ ʢϊʔυʣ ϚΠφʔ ʢϊʔυʣ ϒϩοΫ

    5Y 5Y 5Y τϥϯβΫγϣϯͷ֓ཁ ΢ΥϨοτ 5Y ΢ΥϨοτ ΢ΥϨοτ 5Y 5Y τϥϯβΫγϣϯͷϥΠϑαΠΫϧ ૊੒ ఻ൖ ֬ೝ ϒϩοΫʹ τϥϯβΫγϣϯΛ ٧Ί͍ͯ͘ ه࿥  5YͷϥΠϑαΠΫϧ ϒϩʔυΩϟετ ϒϩʔυΩϟετ ϒϩʔυΩϟετ ϒϩοΫ 5Y
  2. #5$ #5$ #5$ */165 065165 #5$ #5$ ߹ܭɹ#5$ ߹ܭɹ#5$ ࠩ෼ɹ#5$ʢख਺ྉʣ

    w ̍ͭҎ্ͷ*/165ͱ̍ͭҎ্ͷ065165͔Β੒Δ w */165065165ख਺ྉͱͳΔ w τϥϯβΫγϣϯͷதʹख਺ྉΛ໌͍ࣔͯ͠ΔՕॴ͸ͳ͍ τϥϯβΫγϣϯͷ֓ཁ
  3. τϥϯβΫγϣϯͷ֓ཁ w JOQVUͱPVUQVUͷ૊Ͱߏ੒ w JOQVU͸ৗʹผͷτϥϯβΫγϣϯͷPVUQVU 6590 Λࢀর 5Y JOQVU PVUQVU

    PVUQVU 5Y JOQVU PVUQVU PVUQVU JOQVU JOQVU 5Y JOQVU PVUQVU PVUQVU JOQVU 6590 6590 6590 6590ʢະ࢖༻τϥϯβΫγϣϯΞ΢τϓοτʣͱ͸ τϥϯβΫγϣϯΞ΢τϓοτͷ͏ͪɺ·ͩΠϯϓοτͱͯ͠࢖༻͞Ε͍ͯͳ͍΋ͷ
  4. τϥϯβΫγϣϯͷ֓ཁ JOQVU PVUQVU <>Ϙϒʹ#5$ 5Y˛ग़ྗ ΞϦε JOQVU PVUQVU <>Ωϟϩϧʹ#5$ Ϙϒ

    JOQVU PVUQVU <>Ϙϒʹ#5$ φϯγʔ <>δϣϯʹ#5$ 5Y 5Y 5Y 5Yग़ྗ<> 5Yग़ྗ<> ߹ܭ#5$ ߹ܭ#5$ 5Y˔ग़ྗ τϥϯβΫγϣϯͷΠϯϓοτ͸ 6590΁ͷϙΠϯλͦͷ΋ͷ w JOQVUͱPVUQVUͷ૊Ͱߏ੒ w JOQVU͸ৗʹผͷτϥϯβΫγϣϯͷPVUQVU 6590 Λࢀর
  5. τϥϯβΫγϣϯͷ֓ཁ 6590ϕʔε 6590 6590ϕʔεͱΞΧ΢ϯτϕʔεͷҧ͍ 6590 6590 6590 #5$ #5$ #5$

    #5$ #5$ ΞΧ΢ϯτϕʔε ͦͷΞυϨεʹඥͮ͘աڈͷૹۚΛ͢΂ͯ߹ࢉ͢Δ ࠷৽ͷ࢒ߴ͚ͩΛอ࣋ #5$ #5$ #5$
  6. τϥϯβΫγϣϯͷߏ੒ 3BX5SBOTBDUJPO'PSNBU <CZUF7FSTJO> MJUUMFFOEJBO  <*OQVU$PVOU> DCF⒎DGBBDB⒎FDBBFDBCBCZUF5Y)BTI MJUUMFFOEJBO  CZUF0VUQVU*OEFY

    MJUUMFFOEJBO  B6OMPDLJOH4DSJQU4J[FCZUF BB⒎EFGCEGBBBCBFDGDBEECFECEBECCG GCBFGCCBECEECGFGFCFFBFCBGGEEGEC GGGGB6OMPDLJOH4DSJQU ⒎⒎⒎⒎4FRVFODF/VNCFS CFECGDBGFCEEBFEGCFBECZUF5Y)BTI MJUUMFFOEJBO  CZUF0VUQVU*OEFY MJUUMFFOEJBO  C6OMPDLJOH4DSJQU4J[FCZUF DBCDDDCBGFCFG⒎GGEDDDFEFEGCDFFFCE FEGCCGCFGFDFDDGFBGEBCDDDDEFFFCGEBBBDEDF⒎DEDF CBFGDGE6OMPDLJOH4DSJQU ⒎⒎⒎⒎4FRVFODF/VNCFS 0VUQVU$PVOU F"NPVOUTBUPTIJ MJUUMFFOEJBO  -PDLJOH4DSJQU4J[F BCDGCGCGCFCDEBD-PDLJOH4DSJQU EB"NPVOUTBUPTIJ MJUUMFFOEJBO  -PDLJOH4DSJQU4J[F BFGEEBFECBGBD-PDLJOH4DSJQU -PDLUJNF
  7. bitcoin script w τϥϯβΫγϣϯͰ༻͍ΒΕΔεΫϦϓτݴޠ w ελοΫͱݺ͹ΕΔσʔλߏ଄ w νϡʔϦϯάෆ׬શੑ w ϧʔϓ΍෼ذ͕ͳ͍

    w ෳࡶͳ͜ͱΛग़དྷͳ͘͢Δ͜ͱͰCJUDPJOωοτϫʔΫʹର͢Δ߈ܸΛ ੍ݶ͢Δ w εςʔτϨε w ঢ়ଶΛ࣋ͨͳ͍ͷͰͲΜͳγεςϜͰ΋ಉ͡ϓϩηεɺݕূ݁Ռͱͳ Δ
  8. bitcoin script w -PDLJOH4DSJQU͸τϥϯβΫγϣϯΞ΢τϓοτʹؚ·ΕΔɺͦͷΞ΢τϓο τͷ࢖༻৚݅ͷTDSJQU w 6OMPDLJOH4DSJQU͸τϥϯβΫγϣϯΠϯϓοτʹؚ·ΕΔɺΞ΢τϓο τͷMPDLΛຬͨ͢TDSJQU w -PDLJOH4DSJQUͱ6OMPDLJOH4DSJQU͸ͭܨ͛ͯҰͭͷϓϩάϥϜʹͳΔ

    w ϊʔυ͕ϓϩάϥϜΛCJUDPJOTDSJQUͱ࣮ͯ͠ߦͯ͠ਖ਼͍͔͠ݕূ w ਖ਼͍͠ͱ͸εΫϦϓτͷ࣮ߦ݁Ռ͕536&Ͱ͋Δ͜ͱ -PDLJOH4DSJQU 6OMPDLJOH4DSJQU 0, ϊʔυ ݕূ /( -PDLJOH4DSJQUͱ6OMPDLJOH4DSJQU
  9. P2PKH (Pay-to-Public-Key-Hash) w 01@)"4)ɿ5IFJOQVUJTIBTIFEUXJDFpSTUXJUI4)"BOEUIFOXJUI3*1&.% w 01@&26"-7&3*':ɿ4BNFBT01@&26"- CVUSVOT01@7&3*':BGUFSXBSE w 01@7&3*':ɿ.BSLTUSBOTBDUJPOBTJOWBMJEJGUPQTUBDLWBMVFJTOPUUSVF5IFUPQTUBDLWBMVFJT SFNPWFE

    w 01@$)&$,4*(ɿ5IFFOUJSFUSBOTBDUJPOTPVUQVUT JOQVUT BOETDSJQU GSPNUIFNPTUSFDFOUMZ FYFDVUFE01@$0%&4&1"3"503UPUIFFOE BSFIBTIFE5IFTJHOBUVSFVTFECZ01@$)&$,4*( NVTUCFBWBMJETJHOBUVSFGPSUIJTIBTIBOEQVCMJDLFZ*GJUJT JTSFUVSOFE PUIFSXJTF IUUQTCJUDPJOCPPLJOGPXQDPOUFOUUSBOTMBUJPOTKBCPPLQEGϖʔδʹελοΫͷڍಈͷਤ 1VCMJD,FZ)BTI͸CJUDPJOΞυϨε͔Β#FTFEFDPEFͯ͠ಘΒΕΔ τϥϯβΫγϣϯશମΛϋογϡͨ͠΋ͷ΁ͷॺ໊ CJUDPJOϊʔυͰ࣮ߦ͞ΕΔ
  10. Ϛϧνγάωνϟ Ϣʔεέʔε w /ݸͷެ։伴ͱ.ݸͷॺ໊͕ೖ͍ͬͯΔTDSJQU w .PG/ͱදݱ w /͸Ωʔͷ૯਺ɺ.͸ඞཁͳॺ໊ͷ਺Ͱ͢ w ྫ͑͹PGͳΒݸͷެ։伴ʹରͯ͠ݸͷॺ໊Λ༻͍ͳ͍ͱ͍͚·ͤΜ

    w ෳ਺ਓͰ؅ཧ͢ΔΞυϨεͰҰఆ਺Ҏ্ͷڐՄ͕ͳ͍ͱಈ͔ͤͳ͍ΞυϨε w ඞཁͳΩʔΛ૿΍͢͜ͱͰ࿙Ӯʹର͢Δ଱ੑΛ͚ͭΔ w ݸਓͰPG/ͷΞυϨεΛ؅ཧ͢ΔͱҰͭΩʔΛͳͯ͘͠΋όοΫΞοϓͱͯ͠ಇ͘
  11. Ϛϧνγάωνϟ PGͷTDSJQUͷྫ 1VCMJD,FZ"1VCMJD,FZ#1VCMJD,FZ$01@$)&$,.6-5*4*( 01@4JHOBUVSF#4JHOBUVSF$ 01@4JHOBUVSF#4JHOBUVSF$ 1VCMJD,FZ"1VCMJD,FZ#1VCMJD,FZ$01@$)&$,.6-5*4*( ඞཁͳൿີ伴ͷ਺ 01@$)&$,.6-5*4*(ɿ࠷ॳͷॺ໊ͱ&$%4"ͷҰக͕ݟ͔ͭΔ·Ͱ֤ެ։伴Λൺֱ͠·͢ɻ࣍ͷެ։伴Ͱ࢝·Γɺ &$%4"ͷҰக͕ݟ͔ͭΔ·Ͱɺ࢒Γͷެ։伴ͱ൪໨ͷॺ໊Λൺֱ͠·͢ɻ͜ͷϓϩηε͸ɺ͢΂ͯͷॺ໊͕νΣοΫ ͞ΕΔ͔ɺ੒ޭͨ݁͠ՌΛग़͢ͷʹे෼ͳެ։伴͕࢒Βͳ͘ͳΔ·Ͱ܁Γฦ͞Ε·͢ɻ͢΂ͯͷॺ໊͸ެ։伴ͱҰக͢

    Δඞཁ͕͋Γ·͢ɻެ։伴͸ॺ໊ൺֱʹࣦഊͨ͠৔߹ʹ࠶౓νΣοΫ͞Εͳ͍ͨΊɺରԠ͢Δެ։伴͕TDSJQU1VC,FZ· ͨ͸SFEFFN4DSJQUʹஔ͔Εͨͷͱಉ͡ॱংͰTDSJQU4JHʹॺ໊Λ഑ஔ͢Δඞཁ͕͋Γ·͢ɻ͢΂ͯͷॺ໊͕༗ޮͳ৔߹ ͸͕ฦ͞ΕɺͦΕҎ֎ͷ৔߹͸͕ฦ͞Ε·͢ɻόάͷͨΊʹɺͭͷ༨෼ͳະ࢖༻஋͕ελοΫ͔Β࡟আ͞Ε·͢ɻ ʢ(PPHMF຋༁ΑΓʣ ඞཁͳൿີ伴ͷ਺
  12. P2SH (Pay-to-Script-Hash) w ΑΓ୹͍ϑΟϯΨʔϓϦϯτͰෳࡶͳTDSJQUΛஔ͖׵͑Δ͜ͱͰɺτϥϯβΫγϣϯͷσʔλαΠζΛ খ͘͢͞Δ w TDSJQU͕ΞυϨεͱ࣮ͯ͠૷͞ΕΔ͜ͱͰɺૹΓओͱૹΓओͷ΢ΥϨοτ͸14)ʹؔ͢Δෳࡶͳ࣮૷ Λ͢Δඞཁ͕ͳ͍ w 14)͸ɺTDSJQUΛߏ੒͢Δෛ୲ΛૹΓखͰ͸ͳ͘ड͚खଆʹҠ͍ͯ͠Δ

    w 14)͸ɺΞ΢τϓοτ͕࣋ͭ௕͍TDSJQU ͜Ε͸6590ηοτʹؚ·ΕΔͨΊϝϞϦΛѹഭ͢Δ ΛΠϯ ϓοτଆ ϒϩοΫνΣʔϯ্ʹͷΈอଘ͞ΕΔ ʹҠ͢͜ͱͰσʔλετϨʔδͷෛ୲ΛΠϯϓοτଆ ʹҠ͍ͯ͠Δ w 14)͸ɺ௕͍TDSJQU͕ࢧ෷͍࣌Ͱ͸ͳ͘ࢿ͕ۚ࢖ΘΕΔ࣌఺Ͱੜ͡ΔΑ͏ʹ͢Δ͜ͱͰɺσʔλετ Ϩʔδͷෛ୲͕ൃੜ͢Δ࣌ࠁΛະདྷʹҠ͍ͯ͠Δ w 14)͸ɺૹΓख͕௕͍TDSJQUΛ൐ͬͯࢿۚΛૹΔͱ͖ʹෛ୲͢ΔτϥϯβΫγϣϯख਺ྉΛɺड͚ख ͕SFEFFNTDSJQUΛ࢖ͬͯࢿۚΛ࢖͏ͱ͖ʹෛ୲͢ΔΑ͏ʹมߋ͍ͯ͠Δ 14)͸MPDLJOHTDSJQUΛෳࡶͳ··௚઀ѻ͏͜ͱʹൺ΂ͯҎԼͷར఺͕͋Γ·͢ɻ