HTLC入門

D3e027f453bb96ac1398cc98620f2920?s=47 Shu Kobuchi
August 26, 2018
470

 HTLC入門

2018年8月26日にHashHubで行われた今井崇也博士主催「オフチェーンアカデミーハックデーβ」でHTLC(Hashed TimeLock Contract)入門のLTをさせていただきました。

D3e027f453bb96ac1398cc98620f2920?s=128

Shu Kobuchi

August 26, 2018
Tweet

Transcript

  1. HTLCೖ໳ 2018/8/26 ΦϑνΣʔϯΞΧσϛʔϋοΫσʔβ খᔹ प Shu Kobuchi

  2. ࣗݾ঺հ খᔹपɹ4IV,PCVDIJɹ!TIV@LPCTIVLPCVDIJ
 —χοΫωʔϜɿ͜Ϳγϡʔ
 —୅໨ϒϩοΫஉɹIUUQTXXXZPVUVCFDPNXBUDI WBU$*2B8*6: ϛεϏοτίΠϯ
 ౻ຊਅҥࢯͷΠϯλϏϡʔهࣄ
 IUUQTHPPHMKNRL !2 ◾03"/(&#&".


    ɹɹ—খᔹ͕.BJOOFUͰཱ͍ͯͯΔ
 ɹɹɹDMJHIUOJOHϊʔυ ◾גࣜձࣾΩϡʔϒγεςϜ
 ɹɹ—ܦӦઓུຊ෦ٕज़ઓུࣨ
 ɹɹɹ*5εϖγϟϦετ
  3. ίϛϡχςΟ঺հ ҉߸௨՟ಡॻձษڧձɹIUUQTDSZQUPDVSSFODZDPOOQBTTDPN
 —04$౦ژʹʮ೔ຊ҉߸௨՟Ϣʔβձʯͱͯ͠ग़ల
 —ॳ৺ऀʙதڃऀ޲͚ͷʮϏοτίΠϯͱ͔ษڧձʯʢ݄̍ճʣ
 —தڃऀʙ্ڃऀ޲͚ͷʮ҉߸௨՟ྠಡձʯʢ݄̍ճʣ
 —DSBTIBDBEFNZ *5ܥಈը഑৴ ʹͯϏοτίΠϯͱ͔ษڧձͷΞʔΧΠϒ഑৴த
 ɹIUUQTDSBTIBDBEFNZMFDUVSFSDSZQUPDVSSFODZ
 —ϩάϛʔ5FDIʢςοΫʣ

    ษڧձॻ͖ى͜͠ ͱͷఏܞ΋DSBTIBDBEFNZΛհͯ͠։ ࢝༧ఆ
 IUUQTMPHNJKQUFDI
 —೔ຊ҉߸௨՟Ϣʔβձ ౦ژࢧ෦ 04$౦ژ΁ͷग़ల
 ࣍ճ͸݄೔ ౔ ೔ ೔ !3
  4. )5-$ೖ໳

  5. )BTIFE5JNF-PDL$POUSBDU தؒऀΛܦ༝͢ΔϚϧνϗοϓૹۚΛ࣮ݱ  νϟωϧͷ։ઃ૬ख͕૿͑ΔͱɺPGϚϧνγάѼʹ͢ΔσϙδοτͰ ϩοΫ͞ΕΔ#JUDPJO͕૿͑Δ  νϟωϧະ։ઃͷ૬खͱ΋νϟωϧ։ઃࡁΈͷୈࡾऀΛܦ༝ܾͯ͠ࡁ !5 σϙδοτͷ #JUDPJO͕ଟ͍

    σϙδοτͷ #JUDPJOΛ཈͑ΒΕΔ
  6. தؒऀΛ৴༻ͤͣͱ΋ૹۚͰ͖Δ࢓૊Έ͕ඞཁ "MJDF͸$BSPMͱ௚઀νϟωϧΛష͍ͬͯͳ͍͕ɺ#PCΛ௨ͯ͠ૹ͕ۚͰ͖ͦ͏ "MJDF͕#PCʹ$BSPM΁#5$ૹۚ͢ΔΑ͏ʹݴͬͯ΋ɺ#PC͕౪ΉՄೳੑ ͸൱ఆͰ͖ͳ͍ #PC͕৴༻Ͱ͖ͳͯ͘΋ૹۚͰ͖Δ࢓૊Έ͕ඞཁ !6 "MJDF #PC $BSPM

  7. ৄ͘͠͸%SZKBࢯͷࢿྉΛ 5IBEEFVT%SZKB -JHIUOJOH/FUXPSL8IJUFQBQFSஶऀͷҰਓʣ
 IUUQTCDKQBSDIJWFTFBTPONBUFSJBMT @-JHIUOJOH@/FUXPSLQEG !7

  8. )5-$ͷ؆қతͳྫ ᶃ4FDSFU3Λ࡞੒͠ɺ4FDSFU)BTI3Λ"MJDFʹ࿈ܞ ᶄ)5-$59"Ͱɺ"MJDF͔Β#PC΁ͷࢧ෷͍Λอূ ᶅ)5-$59#ͱᶆ)5-$59$Ͱ#PC͔Β$BSPM΁ͷૹۚ ᶄ)5-$59"ͱᶇ)5-$59#Ͱ"MJDF͔Β#PC΁ͷૹۚ !8 "MJDF #PC $BSPM 4FDSFU3

    ᶃ)BTI3 ᶄ)5-$59" 4FDSFU3ͱ#PC`T1SJW,FZͰೖखՄ ·ͨ͸ɺ̎िؒܦաޙ"MJDF`T1SJW,FZ ͰೖखՄ ᶅ)5-$59# 4FDSFU3ͱ$BSPM`T1SJW,FZͰೖखՄ ·ͨ͸ɺ̎िؒܦաޙ#PC`T1SJW,FZ ͰೖखՄ ᶆ)5-$59$ 4FDSFU3ͱ$BSPM`T1SJW,FZͰೖख ᶇ)5-$59# 4FDSFU3ͱ#PC`T1SJW,FZͰೖख 4FDSFU3
  9. தؒऀ͔Βݟͯ࢝఺ɾऴ఺ͷ৴པ͕ͳͯ͘΋࢖͑ΔΑ͏ʹ #JUDPJOͱ4FDSFU3ͷަ׵͚ͩͰ͸ෆे෼ !9 ҆౔ໜږࢯϒϩάʮ%FWFMPQNFOUXJUIQMFBTVSFʯΑΓ IUUQTUFDINFEJBUIJOLIBUFOBCMPHDPNFOUSZ

  10. )5-$͸#*1ͰൃҊ #JUDPJO*NQSPWFNFOU1SPSPTBMʢϏοτίΠϯվળఏҊʣ
 #*1Ͱ)5-$͕ൃҊ͞Εͨ
 IUUQTHJUIVCDPNCJUDPJOCJQTCMPCNBTUFSCJQNFEJBXJLJ !10

  11. )5-$͸ΤεΫϩʔత -JHIUOJOH/FUXPSL͚ͩͰͳ͘ɺΦϯνΣʔϯʗΦϑνΣʔϯ໰ΘͣΤεΫϩʔ औҾʹԠ༻Ͱ͖Δ෯޿͘࢖͑Δߟ͑ํ &UIFSFVN4NBSU$POUSBDUͰ΋)5-$Λ࢖͑ͦ͏ #5$⁶&5)ͷΑ͏ͳҟछνΣʔϯؒऔҾͰ͋Δ"UPNJD4XBQʢΞτϛοΫ εϫοϓʣʹ΋)5-$͕࢖ΘΕ͍ͯΔ
 IUUQT[PPNCMDDPNBUPNJDTXBQ -JHIUOJOH/FUXPSLͷνϟωϧؒʢ"MJDF⁶#PCͷνϟωϧͱ#PC⁶$BSPMͷ νϟωϧʣऔҾ΋"UPNJD4XBQͰ͋Δ
 IUUQTUFDINFEJBUIJOLIBUFOBCMPHDPNFOUSZ

    !11
  12. -JHIUOJOH/FUXPSLΛֶͿ্ͰಡΜͰ͓͖͍ͨॻ੶ ࢁ࡚ॏҰ࿠ɾ҆౔ໜږɾాதढ़ଠ࿠ஶ  ʰϒϩοΫνΣʔϯɾϓϩά ϥϛϯάԾ૝௨՟ೖ໳ʱߨஊࣾ !12

  13. ࢀߟࢿྉɹ-JHIUOJOH/FUXPSL࣮༻ࣄྫ

  14. -JHIUOJOH/FUXPSLΛ5FTUOFUͰମݧ 4UBS#MPDLT IUUQTTUBSCMPDLTBDJORDP ◾ձܭ͸23ίʔυಡΈऔΓ
 ɹɹ—εϚϗ౳ͰಡΈऔܾͬͯࡁ
 ɹɹ—ΦϯνΣʔϯͱ͸ผن֨ͷૹۚํ๏

  15. 8PP$PNNFSDFͷԾ૝௨՟ܾࡁ #JUDPJO΍&UIFSFVNΛ͸͡Ίͱ͢Δ༷ʑͳԾ૝௨՟ܾࡁʹରԠ ◾#JUDPJOͱ"MUDPJO ѥछ 
 ɹɹ—#JUDPJO
 —#JUDPJO$BTI
 —-JUFDPJO
 —%BTI
 ͳͲ

    IUUQTKBXPSEQSFTTPSHQMVHJOTHPVSM XPPDPNNFSDFCJUDPJOBMUDPJOQBZNFOUHBUFXBZ BEEPO ◾&UIFSFVN
 ɹɹ—&UIFSFVN
 —&3$UPLFOT &UIFSFVN্Ͱൃߦ͞Ε
 ɹɹɹͨ&3$ͱ͍͏ن֨ͷτʔΫϯ IUUQTXXXXQCMPHDPNDSZQUPDVSSFODJFT XPSEQSFTTBOEXPPDPNNFSDFXFCTJUFT
  16. Ծ૝௨՟ܾࡁͰ΋࠷৽Λߦ͘8PP$PNNFSDF #JUDPJOͷઌਐٕज़-JHIUOJOH/FUXPSLͷܾࡁʹ΋ରԠ ◾8PP$PNNFSDF(BUFXBZ-JHIUOJOH
 ɹɹ—ੈքతͳ#JUDPJOελʔτΞοϓ
 #MPDLTUSFBN͕ࣾ8PPDPNNFSDFͱซ༻
 ɹɹɹ͢Δ(BUFXBZΛΦʔϓϯιʔεͰఏڙ IUUQTHJUIVCDPN&MFNFOUT1SPKFDUXPPDPNNFSDFHBUFXBZMJHIUOJOH

  17. -JHIUOJOH/FUXPSLͷ࣮ళฮܾࡁ ೥݄೔ ౔ ೔ຊͰॳΊͯͷ-JHIUOJOH/FUXPSL࣮ళฮܾࡁ͕ߦΘΕ ͨ !17 ϕϧΪʔϏʔϧμΠχϯάαϯλϧψʔ
 —҉߸௨՟ܾࡁͷ੟஍
 —*$0 *OJUJBM$PJO0⒎FSJOH

    Ͱ໊ݹ԰
 ɹ͔Β౦ژ੺ࡔʹҠస ࣗ਎͸໨ܸऀͱͳΓɺ5XJUUFSͰ͸େ͖ͳ ൓ڹ
 —೔ຊͰ-JHIUOJOH/FUXPSL͕େ͖ͳ
 ɹҰาΛ౿Έग़ͨ͠ IUUQTUXJUUFSDPNTIV@LPCTUBUVT
  18. ࢀߟࢿྉɹDMJHIUOJOHΛ"84Ͱߏங

  19. "84Ͱ-JHIUOJOH/FUXPSLϊʔυΛߏங &$Λར༻ ◾ΠϯελϯελΠϓ
 ɹɹ—UTNBMM
 —UNJDSPͩͱ
 ɹɹɹϏϧυ࣌ʹ
 ɹɹɹϝϞϦෆ଍
  ◾ετϨʔδαΠζ
 ɹɹ—ϑϧϊʔυͳΒ


    ɹɹ—5FTUOFUͳΒ(#
 ɹɹ—.BJOFUͳΒ(# ◾".*
 ɹɹ—6CVOUV
 —ϒϩοΫνΣʔϯ
 ɹɹɹͰΑ͘ར༻͞ΕΔ
  20. #JUDPJO$PSFͱDMJHIUOJOHΠϯετʔϧ #JUDPJOϊʔυ͸$ ͷϦϑΝϨϯε࣮૷ͷ#JUDPJO$PSF CJUDPJOE ΍+BWB࣮૷ ͷCJUDPJOKɺHP࣮૷ͷCUDEͳͲ͕͋Γɺ-JHIUOJOH/FUXPSLϊʔυ΋$ݴޠ࣮૷ ͷDMJHIUOJOH MJHIUOJOHE ɺHPݴޠ࣮૷ͷMOEͳͲ͕͋Δɻ
 ࠓճ͸ɺ#JUDPJO$PSF

    CJUDPJOE  DMJHIUOJOH MJHIUOJOHE Λ঺հ #JUDPJODPSFͷΠϯετʔϧ VCVOUV  IUUQTRJJUBDPNUPLVPJUFNTFGEGDGDFC -JHIUOJOH/FUXPSLϊʔυΛ্ཱͪ͛Δํ๏ DMJHIUOJOHฤ  IUUQTRJJUBDPNNVUBJUFNTCFDBGFDE
  21. ։͚Δϙʔτ ηΩϡϦςΟάϧʔϓΠϯό΢ϯυ
 Ͱઃఆ
 ◾.BJOOFUͷ৔߹
 ɹɹ—
 — ◾5FTUOFUͷ৔߹
 ɹɹ—
 — ◾MJHIUOJOH

    .BJOOFU 5FTUOFUڞ௨ 
 ɹɹ—
  22. "84Ͱཱͯͨϊʔυ΁ͷνϟωϧͷషΓํ ௨ৗɺ*1WύϒϦοΫ*1Λ༻͍Δ͕ɺ"84౳Ϋϥ΢υͰ͸
 *1WύϒϦοΫ*1Ͱ͸షΕͳ͍ͷͰɺύϒϦοΫ%/4Λར༻ $ lightning-cli connect 03878c29e98b292d75184e04f8732df71b829e1f027abd881f68ba87f94890f8e2 54.64.156.15:9735 { "code"

    : -1, "message" : "Connection establishment: Connection timed out" } vagrant@vagrant:~/lightning$ lightning-cli connect 03878c29e98b292d75184e04f8732df71b829e1f027abd881f68ba87f94890f8e2 ec2-54-64-156-15.ap-nor theast-1.compute.amazonaws.com:9735 { "id": “03878c29e98b292d75184e04f8732df71b829e1f027abd881f68ba87f94890f8e2" } vagrant@vagrant:~/lightning$ lightning-cli fundchannel 03878c29e98b292d75184e04f8732df71b829e1f027abd881f68ba87f94890f8e2 1000000 { “tx": "02000000000101f8fb8fe048fe4dd0d9c2f854777685b4bf8bc68ba18a7e2b6c092a4a26fee2110100000000f fffffff0240420f0000000000220020117ee3b27964d2fec71ec73fa6c3ac4f14f5a23b6d7dd17b0a925c9d421 62c9859bb650300000000160014be090d0aceb6702c948220f84c9cc1a026ce60a302473044022004d5dc06814 fab006d8658c9d4a76669fbab4c3257e6e377e8b44a2502628262022075564b6dd354a3bac745403b0e16fd7b3 ab8f8e303a17acf75165ea92c8a0026012102f530fbd401090d92b1863cf6db3657c323dc482f12a88ff4a5814 7ac0111acf900000000", "txid": "cfd32c38756a5165cba58c01daf2503de7e220c671f41483949ca8be2bb93e8b", "channel_id": “8b3eb92bbea89c948314f471c620e2e73d50f2da018ca5cb65516a75382cd3cf" }
  23. -JHIUOJOH/FUXPSL&YQMPSFS -JHIUOJOH/FUXPSLνϟωϧΛՄࢹԽͨ͠αΠτ 5FTUOFU 
 IUUQTFYQMPSFSBDJORDP

  24. -JHIUOJOH/FUXPSL&YQMPSFS -JHIUOJOH/FUXPSLνϟωϧΛՄࢹԽͨ͠αΠτ .BJOOFU 
 IUUQTMONBJOOFUHBCFOXJO ◾03"/(&#&".
 ɹɹ—খᔹ͕.BJOOFUͰཱ͍ͯͯΔϊʔυ ◾5FTUOFUΛ௒͑Δن໛
 ɹɹ—ϊʔυ਺ɺνϟωϧ਺ͱ΋ʹ.BJOOFUͷํ͕ଟ਺

  25. #JUDPJOΛࢧ͑Δ"84 #JUDPJOϊʔυΛՔಇͤ͞Δͷʹ"84͸͔ͳΓ࢖ΘΕ͍ͯΔ
 ੈքͷϊʔυ&YQMPSFS
 IUUQTCJUOPEFTFBSODPNOPEFT R+BQBO

  26. #JUDPJOΛࢧ͑Δ"84 #JUDPJOϊʔυΛՔಇͤ͞Δͷʹ"84͸͔ͳΓ࢖ΘΕ͍ͯΔ
 ੈքͷϊʔυ&YQMPSFS
 IUUQTCJUOPEFTFBSODPNOPEFT R+BQBO