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

Bitcoin Basic OP_CODEs

Bitcoin Basic OP_CODEs

Let's enjoy Bitcoin OP_CODEs!

Shun Usami

June 23, 2018
Tweet

More Decks by Shun Usami

Other Decks in Technology

Transcript

  1. WHAT IS BITCOIN? WHAT IS BITCOIN? ▸ Q1 : Bitcoinͱ͸ʁ

    ▸ A1 : վ᜵Ͱ͖ͳ͍σʔλϕʔε ▸ Q2 : ԿΛอଘ͍ͯ͠Δʁ ▸ A2 : ৣ͕͔͔ͬͨίΠϯ
  2. LOCK & UNLOCK BITCOIN LOCK & UNLOCK BITCOIN ▸ Lock

    Script : ίΠϯʹ伴Λ͔͚ΔͨΊͷεΫϦϓτ ▸ Unlock Script : ίΠϯͷ伴Λղৣ͢ΔͨΊͷεΫϦϓτ ▸ [Unlock Sceript] [Lock Script]ͷॱ൪ʹ࣮ߦͨ݁͠ՌɺTrue ͕ฦͬͯདྷΕ͹ͦͷίΠϯ͸࢖༻Մೳʂ ʢʹScriptPubkeyʣ ʢʹScriptSigʣ
  3. WHAT IS STACK MACHINE? WHAT IS STACK MACHINE? ▸ BitcoinͷεΫϦϓτ͸ελοΫϚγϯ্Ͱ࣮ߦ͞ΕΔ

    ▸ ελοΫϚγϯͱ͸Կ͔͸ɺҎԼͷྫΛݟͯΈ·͠ΐ͏ʂ ▸ ex. [3] [20] [8] [ADD] [MUL] 8 20 3 28 3 84
  4. UNLOCK FAILURE UNLOCK FAILURE ▸ Lock script : [19] [2]

    [SUB] [EQUAL] ▸ Unlock script : [8] 2 19 8 17 8 FALSE
  5. P2PK SCRIPT PAY TO PUBLIC KEY ▸ OP_CHECKSIG : (sig

    pubkey) -> TRUE/FALSE ▸ pubkeyʹରԠ͢Δൿີ伴Ͱॺ໊͞Εͨsig͔Ͳ͏͔ݕূ
  6. P2PKH SCRIPT PAY TO PUBLIC KEY HASH ▸ OP_DUP :

    x -> x x ▸ OP_HASH160 : pubkey -> pubkeyHash ▸ OP_VERIFY : Ұ൪্͕TRUE͡Όͳ͔ͬͨΒଈ࠲ʹFail
  7. LOCK UNTIL SCRIPT LOCK UNTIL ▸ OP_CHECKLOCKTIMEVERIFY : time ->

    time/Fail ▸ ΋͠ݱࡏ࣌ࠁ͕timeΑΓલͩͬͨΒଈ࠲ʹFail ▸ OP_DROP : Ұ൪্ͷσʔλΛ࡟আ
  8. M-OF-N MULTISIG SCRIPT M-OF-N MULTISIG ▸ OP_CHECKMULTISIG : <sig1>…<sigN> M

    <pub1>… <pubN> N -> TRUE/FALSE ▸ Nݸͷpubkeyͷ͏ͪɺͦΕΒʹରԠ͢ΔMݸͷൿີ伴Ͱ ॺ໊Ͱ͖͍ͯΔ͔ݕূ