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

ブロックチェーン連続講義 第2-3回 ビットコインの技術 / Bitcoin Technology

ブロックチェーン連続講義 第2-3回 ビットコインの技術 / Bitcoin Technology

ブロックチェーンハブ主催で開催している第2期ブロックチェーン連続講義の第3回「ビットコインの技術」のスライドです。2016年7月15日(金) に使用しました。

Kenji Saito

July 15, 2016
Tweet

More Decks by Kenji Saito

Other Decks in Technology

Transcript

  1. 2 3
    SFC / CSO
    [email protected]
    — 2016-07-15 – p.1/47

    View full-size slide

  2. Proof of Work
    API
    — 2016-07-15 – p.2/47

    View full-size slide

  3. 1.
    2.
    3.
    4. -
    5. -
    6.
    — 2016-07-15 – p.3/47

    View full-size slide

  4. 1.
    — 2016-07-15 – p.4/47

    View full-size slide

  5. vs.
    ( )
    http://www.post.japanpost.jp/service/letax/index.html
    http://enaiyo.post.japanpost.jp/mpt/
    ( )
    — 2016-07-15 – p.5/47

    View full-size slide

  6. Satoshi Nakamoto, “Bitcoin: A Peer-to-Peer Electronic
    Cash System”, 2008
    P2P
    http://bitcoin.org/
    BTC (ISO XBT )
    2013 11 1BTC 10
    — 2016-07-15 – p.6/47

    View full-size slide

  7. 2.
    — 2016-07-15 – p.7/47

    View full-size slide

  8. (1)
    2,100 cm3
    1 1cm3
    10
    12.5cm3
    — 2016-07-15 – p.8/47

    View full-size slide

  9. (2)

    — 2016-07-15 – p.9/47

    View full-size slide

  10. = or
    :

    — 2016-07-15 – p.10/47

    View full-size slide

  11. 3.
    — 2016-07-15 – p.11/47

    View full-size slide

  12. -
    — 2016-07-15 – p.12/47

    View full-size slide

  13. -
    RSA, DSA, ECDSA ( DSA) ( RSA)
    PKI
    — 2016-07-15 – p.13/47

    View full-size slide

  14. 4. -
    — 2016-07-15 – p.14/47

    View full-size slide

  15. — 2016-07-15 – p.15/47

    View full-size slide

  16. (1)
    (= ) →
    — 2016-07-15 – p.16/47

    View full-size slide

  17. (2)
    M A 60BTC
    — 2016-07-15 – p.17/47

    View full-size slide

  18. — 2016-07-15 – p.18/47

    View full-size slide

  19. 1. 10
    ( )
    2.
    3.
    1
    — 2016-07-15 – p.19/47

    View full-size slide

  20. — 2016-07-15 – p.20/47

    View full-size slide

  21. 21 ( 4 ) ( )
    2,100 BTC
    1 1 BTC 2140
    20,999,999.9769 BTC
    — 2016-07-15 – p.21/47

    View full-size slide

  22. — 2016-07-15 – p.22/47

    View full-size slide

  23. ( )


    — 2016-07-15 – p.23/47

    View full-size slide

  24. — 2016-07-15 – p.24/47

    View full-size slide

  25. POW
    ( )
    Proof Of Work . . .
    — 2016-07-15 – p.25/47

    View full-size slide

  26. 1
    — 2016-07-15 – p.26/47

    View full-size slide

  27. ( )
    — 2016-07-15 – p.27/47

    View full-size slide

  28. 5. -
    — 2016-07-15 – p.28/47

    View full-size slide

  29. Transaction Data Structure
    Field Description Size (bytes)
    Version Currently 1 4
    # of inputs Positive var-int 1∼9
    List of inputs Variable
    # of outputs Positive var-int 1∼9
    List of outputs Variable
    Lock time 4
    — 2016-07-15 – p.29/47

    View full-size slide

  30. Output Data Structure
    Field Description Size (bytes)
    Amount Value in 10−8BTC 8
    Script length Positive var-int 1∼9
    Script Variable
    — 2016-07-15 – p.30/47

    View full-size slide

  31. Input Data Structure
    Field Description Size (bytes)
    Referred TX Double SHA-256 value 32
    Referred output Index of the output 4
    Script length Positive var-int 1∼9
    Script Variable
    Sequence # 4
    — 2016-07-15 – p.31/47

    View full-size slide

  32. Major Script Operators
    Operator Code Description
    OP_0 0 Push 0 byte
    N/A 1∼0x4b Push # bytes
    OP_PUSHDATA1 0x4c Push length specified by 1-byte suffix
    OP_PUSHDATA2 0x4d Push length specified by 2-byte suffix
    OP_PUSHDATA4 0x4e Push length specified by 4-byte suffix
    OP_NOP 0x61 Do nothing
    OP_VERIFY 0x69 TX invalid if not true
    OP_DUP 0x76 Copy 1 item
    OP_EQUAL 0x87 If 2 items match
    OP_EQUALVERIFY 0x88 OP_EQUAL → OP_VERIFY
    OP_HASH160 0xa9 Apply SHA-256→RIPEMD-160
    OP_CHECKSIG 0xac If signature for TX verified
    OP_CHECKMULTISIG 0xae If multiple signatures for TX verified
    Script is a stack-oriented language with postfix notation
    — 2016-07-15 – p.32/47

    View full-size slide

  33. Script (General)
    Output:
    OP_DUP OP_HASH160
    OP_PUSHDATA*
    OP_EQUALVERIFY OP_CHECKSIG
    Input:
    OP_PUSHDATA*
    OP_PUSHDATA*
    TX output addressed to a public-key digest and referring
    input
    — 2016-07-15 – p.33/47

    View full-size slide

  34. Script Processing
    Concatinates scripts: input → output
    Stack-based processing
    — 2016-07-15 – p.34/47

    View full-size slide

  35. Script (Generation)
    Output:
    OP_PUSHDATA* OP_CHECKSIG
    Input:
    OP_PUSHDATA*
    Gen. TX otuput and referring input
    No need to specify public key by its digest
    Can avoid compromising security down to 160bit
    — 2016-07-15 – p.35/47

    View full-size slide

  36. Block Data Structure
    Field Description Size (bytes)
    Block header 6 items 80
    # of TXs Positive var-int 1∼9
    List of TXs Variable
    — 2016-07-15 – p.36/47

    View full-size slide

  37. Block Header Data Structure
    Field Description Size (bytes)
    Version 4
    Digest Double SHA-256 value 32
    Merkle root Double SHA-256 value 32
    Time Seconds (since 1970-01-01T00:00 UTC) 4
    Target Compressed format 4
    Nonce Appropriate value 4
    Merkle root is the digest of all TXs
    — 2016-07-15 – p.37/47

    View full-size slide

  38. Merkle Tree
    Digest = double SHA-256 value
    — 2016-07-15 – p.38/47

    View full-size slide

  39. Networking
    No structure
    All TCP, default port number: 8333
    IPv6 supported since v0.7 of reference
    implementation (v0.9.4 as of Jan. 2015)
    Can use IPv4, IPv6 or Tor
    In reference implementation
    Max # of outbound connections : 8
    Max # of all connections : 125 (by default)
    Only one outbound connection to an address group
    High 16bit in IPv4
    High 32bit in IPv6
    — 2016-07-15 – p.39/47

    View full-size slide

  40. Major Messages
    Category Name Function
    Connection version Sends version and block #
    verack Acknowledges version
    addr (address) Sends list of IP address/port #
    getaddr Requests addr
    Data inv (inventory) Sends (new) blocks and/or txs
    transfer getblocks Requests inv for all blocks within range
    getdata Requests block/tx by the digest
    block Sends block replying to getdata
    tx (transaction) Sends tx replying to getdata
    Header getheaders Requests headers for all blocks within range
    transfer headers Sends block headers up to 2,000
    Others alert Broadcasts alert
    ping Confirms connection
    pong Acknowledges ping
    — 2016-07-15 – p.40/47

    View full-size slide

  41. Message Structure
    Field Description Size (bytes)
    Magic number 0xd9b4bef9 4
    Command Message name (ASCII string) 12
    Payload length Size of payload in bytes 4
    Checksum Double SHA-256 value of payload First 4
    Payload Message data Variable
    All integers are encoded in Little Endian except IP address
    and port #
    We’ve just seen the payloads for block and tx messages
    — 2016-07-15 – p.41/47

    View full-size slide

  42. DNS Seed
    seed.bitcoin.sipa.be
    dnsseed.bluematt.me
    dnsseed.bitcoin.dashjr.org
    seed.bitcoinstats.com
    seed.bitnodes.io
    bitseed.xf2.org
    Maintained by volunteers
    None of these uses DNSSEC
    — 2016-07-15 – p.42/47

    View full-size slide

  43. Transfer Protocol
    block message is handled in the same manner
    — 2016-07-15 – p.43/47

    View full-size slide

  44. For more detail, see
    https://bitcoin.org/en/developer-reference
    — 2016-07-15 – p.44/47

    View full-size slide

  45. 6.
    — 2016-07-15 – p.45/47

    View full-size slide

  46. BTC ( )
    LTC ( )
    DOGE ( )
    ETH ( )
    — 2016-07-15 – p.46/47

    View full-size slide

  47. — 2016-07-15 – p.47/47

    View full-size slide