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

ビヨンドブロックチェーン / Beyond Blockchain

ビヨンドブロックチェーン / Beyond Blockchain

2018年8月14日(火)〜18日(土) に開催された IPA セキュリティ・キャンプ全国大会 2018 の中で 15日(水) に実施した【開発と運用トラック】「ビヨンドブロックチェーン」にて使用したスライドです。

Kenji Saito

August 15, 2018
Tweet

More Decks by Kenji Saito

Other Decks in Technology

Transcript

  1. ( ) SFC ( ) ( ) CSO (Chief Science

    Officer) 1993 ( ) 2006 ( ) SFC 17 P2P (Peer-to-Peer) 2011 → ( ) — 2018-08-15 – p.2/94
  2. (2017) : SF + + SF (2048 ) 2048 —

    2018-08-15 – p.3/94
  3. ( ) (1) (2) (3) (4) ( ) state machine

    replication (1984) — 2018-08-15 – p.6/94
  4. 1) = ( , , , ) 2) 3) ⇒

    ( ) ⇒ · / (dependable ) — 2018-08-15 – p.7/94
  5. /DLT ( ) Bitcoin ( ) Open Assets Protocol (OAP)

    ( ) Ethereum ( ) ( ) Enterprise Ethereum Alliance (↓ ) (DLT: Distributed Ledger Technology) ( ) Hyperledger (Linux Foundation) Fabric (IBM/DAH), Sawtooth (Intel), Iroha ( ) Corda (R3), Tangle (IOTA), . . . , BBc-1 ( ) — 2018-08-15 – p.8/94
  6. (2) (double spending) ( ) ⇒ ⇒ ( ) ⇒

    ⇒ → → ⇒ → — 2018-08-15 – p.10/94
  7. / (1) 2,100 cm3 (cc) 1 1cm3 10 12.5cm3 ⇒

    ⇒ ( ) — 2018-08-15 – p.13/94
  8. / (2) ( ) ( ) ( ) ( )

    ( ) → ( ) — 2018-08-15 – p.14/94
  9. UTXO M A 60BTC ( ) SegWit ( ) —

    2018-08-15 – p.16/94
  10. ∼ ϖʔδ൪߸O ϖʔδ൪߸O  ϖʔδ൪߸O  ϖʔδ൪߸O  ϖʔδ൪߸O 

    ϖʔδ൪߸O  ϖʔδ൪߸O  ϖʔδ൪߸O  ͬͪ͜ͷྺ࢙͕༗ޮ ( ) — 2018-08-15 – p.18/94
  11. /DLT ਖ਼౰ੑͷอূ ྫ6590ߏ଄ͱσδλϧॺ໊ ଘࡏੑͷূ໌ ྫ࡞ۀূ໌෇͖ϋογϡνΣʔϯ །Ұੑͷ߹ҙ ྫφΧϞτɾίϯηϯαε ϧʔϧͷهड़ ྫ#5$ͷҠస ɾ

    τϥϯβΫγϣϯͷ಺༰͕վ͟ΜͰ͖ͣɺ ɾ ͦͷΞηοτʹؔ͢ΔաڈͷτϥϯβΫγϣϯྻʹরΒͯ͠ໃ६͕ͳ͘ɺ ɾ ͔ͭɺਖ਼౰ͳϢʔβʹΑΓ౤ೖ͞Ε͍ͯΔ͜ͱΛอূ͢Δ ɾաڈʹ͋ͬͨτϥϯβΫγϣϯͷূڌΛຣফͰ͖ͣɺ ɾ ͔ͭɺաڈʹͳ͔ͬͨτϥϯβΫγϣϯͷূڌΛ፻଄Ͱ͖ͳ͍ ɾໃ६͢Δ;ͨͭͷτϥϯβΫγϣϯ͕౤ೖ͞Εͨ৔߹ɺ ɹ ͍ͣΕ ؔ༩͢Δશһ͕ಉ͡ยํΛબΜͰྺ࢙ͷதʹҐஔ͚ͮΔ ɾΞϓϦέʔγϣϯϩδοΫ Կ͕ਖ਼͍͠τϥϯβΫγϣϯ͔ΛܾΊΔ — 2018-08-15 – p.19/94
  12. /DLT Bitcoin, Ethereum DLT BBc-1 ( ) ( ) (

    ) ( ) ( ) ( ) ( ) ( ) ( ) Ethereum ( ) ( ) — 2018-08-15 – p.20/94
  13. ( ( )) ( ) DLT ( ) ( )

    : ( ) ( ) ( ) BBc-1 ( ) — 2018-08-15 – p.21/94
  14. 0 and/or “The Times 03/Jan/2009 Chancellor on brink of second

    bailout for banks” 2009 1 3 2 https://blockchain.info SEARCH 0 — 2018-08-15 – p.22/94
  15. /DLT ( ) ( ) ( vs. ) ( )

    ( ) ( ) ⇒ ( : BBc-1) DLT : : — 2018-08-15 – p.23/94
  16. C V C ≥ V Bitcoin ( ) bitcoin Bitcoin

    ( ) Ethereum DLT ( ) BBc-1 ( ) ( ) C ≥ V (proactive) (introspection ( ) ) ( ) — 2018-08-15 – p.25/94
  17. Ethereum ( ) ( ) ⇒ (Casper) ( ) ⇒

    ZoE (Zcash on Ethereum) ( vs. ) ( ) ⇒ Plasma ( ) ⇒ ( ) (Benevolent Dictator For Life (BDFL)) ( ) ⇒ — 2018-08-15 – p.27/94
  18. BBc-1 ( ) ( ) ⇒ ( ) ⇒ (

    vs. ) ( ) ⇒ DHT ( ) ⇒ ( ) ( ) ⇒ — 2018-08-15 – p.28/94
  19. #JUDPJO ##D$PSF ϨοδϟʔαϒγεςϜ ΞϓϦέʔγϣϯ ͦ ͷ ଞ ͞ · ͟

    · ͳ Ξ ϓ Ϧ ͷ Մ ೳ ੑ ڞ௨ϥΠϒϥϦ ##D ։ൃ߲໨ ஍ Ҭ ௨ ՟ Ξ ϓ Ϧ ϙ Π ϯ τ Ξ ϓ Ϧ དྷ ྺ ূ ໌ Ξ ϓ Ϧ ʜ ॳظʹ͓͍ͯଘࡏূ໌Λґଘ ΞϯΧϦϯά ֤ϊʔυʹ͓͚Δه࿥ʹ͸ ֤छσʔλϕʔεΛར༻Մೳ TRMJUF.Z42-ͦͷଞ%# BBc-1 σδλϧ௨՟ϥΠϒϥϦ ͦͷଞͷϥΠϒϥϦ Bitcoin Ethereum ( ) ( ) — 2018-08-15 – p.30/94
  20. Python 3.5.0 (3.6.0 ) ( + pipenv) macOS + Homebrew

    $ brew install libtool automake pkg-config libffi autoconf openssl Linux (Ubuntu 16.04 LTS ) $ sudo apt install -y git tzdata openssh-server libffi-dev net-tools autoconf automake libtool libssl-dev pkg-config make Windows 10 Linux (Ubuntu 16.04 LTS ) — 2018-08-15 – p.36/94
  21. Python (venv) macOS ‘python3.6’ ‘python3’ $ python3.6 -m venv bbcenv

    $ source bbcenv/bin/activate (bbcenv) $ pip install -U pip (bbcenv) $ deactivate — 2018-08-15 – p.37/94
  22. pip $ pip install bbc1 develop $ bbc_core.py --no_nodekey --no_nodekey

    Python 3.7.0 “bad argument to internal function” $ pip install -U --force-reinstall --no-binary :all: gevent <CTRL>+C — 2018-08-15 – p.38/94
  23. (develop pip ) pip install $ git clone https://github.com/beyond-blockchain/bbc1.git $

    cd bbc1 $ python setup.py sdist $ pip install dist/bbc1-1.0.1.tar.gz dist tar pip install — 2018-08-15 – p.39/94
  24. $ cat > test.txt BBC HEAVEN. <CTRL>+D $ more test.txt

    BBC HEAVEN. file_proof.py BBc-1 Core $ file_proof.py store test.txt BBc-1 Core — 2018-08-15 – p.44/94
  25. (1) ——- Dump of the transaction data —— * transaction_id:

    b’de0af83d66170096dac81c4889bed3e1a20b6ab3eb3ae789adf8a580e25c100c’ version: 0 timestamp: 1529296860 Event[]: 0 Reference[]: 0 Relation[]: 1 [0] asset_group_id: b’45b2a200ccdcdcc3fb80cc9d423e1069f3ca726157f6492b4a70a48e4a1713ab’ Asset: asset_id: b’8bd26d0774050015181185de631c48bdfba411b64fb318f3cbfe8df2dcc80a9d’ user_id: b’e59c553504ca7a54f888eb47e61b773a221ae1311bd58ec4c0912d71c443d715’ nonce: b’83136a5fe6a76ab0’ file_size: 12 file_digest: b’7a30a5ef92e4f84287225e980c48ad3a7c29ea929a710d6b798a9bdcc41afc97’ body_size: 21 body: b’Owner is user_default’ — 2018-08-15 – p.45/94
  26. (2) Witness: [0] user_id: b’e59c553504ca7a54f888eb47e61b773a221ae1311bd58ec4c0912d71c443d715’ sig_index: 0 Cross_Ref: None Signature[]:

    1 [0] key_type: 1 signature: b’2a99a304311eacec015f99638584865faf5c7b5b609f0a04762ea40828baf11934df 6cc22289287362b9f9d6deb7f2c6f9528d0aab61b059292f50646942e553’ pubkey: b’04dc03d221c173fb2cf49bd4f2077fdd88babaa8234a96353b245cb3450ca665a12adb1 86695040188b366f12569b892c63f8410b9e471c4f1cf6f3ff96ddc48fc’ — 2018-08-15 – p.46/94
  27. BBc-1 Core $ file_proof.py verify test.txt 1 test.txt is valid

    1 test.txt is invalid — 2018-08-15 – p.48/94
  28. BBc-1 Core $ file_proof.py update test.txt BBc-1 Core verify $

    file_proof.py verify test.txt — 2018-08-15 – p.49/94
  29. (1) ——- Dump of the transaction data —— * transaction_id:

    b’346cd3f414a3ed25b7180a80bde41b1b611c13a4de0018f9684356312fa3ddbf’ version: 0 timestamp: 1529297518 Event[]: 0 Reference[]: 0 Relation[]: 1 [0] asset_group_id: b’45b2a200ccdcdcc3fb80cc9d423e1069f3ca726157f6492b4a70a48e4a1713ab’ Pointers[]: 1 [0] transaction_id: b’de0af83d66170096dac81c4889bed3e1a20b6ab3eb3ae789adf8a580e25c100c’ asset_id: None Asset: asset_id: b’69e01aef0e2854aa45625036f824c8275ecfacf48090b07b21bed216f5a67b34’ user_id: b’e59c553504ca7a54f888eb47e61b773a221ae1311bd58ec4c0912d71c443d715’ nonce: b’1f0e962766009a52’ — 2018-08-15 – p.50/94
  30. (2) file_size: 11 file_digest: b’d866539f224896613df91023f0a9e226085451d6adf1dc5282cbba129d553713’ body_size: 21 body: b’Owner is

    user_default’ Witness: [0] user_id: b’e59c553504ca7a54f888eb47e61b773a221ae1311bd58ec4c0912d71c443d715’ sig_index: 0 Cross_Ref: None Signature[]: 1 [0] key_type: 1 signature: b’5eeb9ca0ce527c90e62a6d087e13ccc009b621974420a5f6201ad65443d0b600c4c2c0 ac6f4ba22beee8a1e265853d13fc3e147ad38c2bebc9b06869559925ff’ pubkey: b’04dc03d221c173fb2cf49bd4f2077fdd88babaa8234a96353b245cb3450ca665a12adb186 695040188b366f12569b892c63f8410b9e471c4f1cf6f3ff96ddc48fc’ — 2018-08-15 – p.51/94
  31. / ( ) $ file_proof.py keypair $ file_proof.py setup $

    file_proof.py wait -o someone ID $ file_proof.py send test.txt “someone” file_proof.py get — 2018-08-15 – p.52/94
  32. (1) verify ——- Dump of the transaction data —— *

    transaction_id: b’8775246772587c9b35329ae39a2d6826175c2cb7ba98da80f51e818db4a144d7’ version: 0 timestamp: 1529298154 Event[]: 0 Reference[]: 0 Relation[]: 1 [0] asset_group_id: b’45b2a200ccdcdcc3fb80cc9d423e1069f3ca726157f6492b4a70a48e4a1713ab’ Pointers[]: 1 [0] transaction_id: b’346cd3f414a3ed25b7180a80bde41b1b611c13a4de0018f9684356312fa3ddbf’ asset_id: None Asset: asset_id: b’97a5023af9fcdba1fb72e12f34c9bf05ee1b24636c02f8d88f5a7f9d269115b6’ user_id: b’2a59d59e3809f827ce709d3815e3950eef4a6a93af5557a93a7fdfba71460843’ nonce: b’18607aaf24de83ee’ — 2018-08-15 – p.53/94
  33. (2) file_size: 11 file_digest: b’d866539f224896613df91023f0a9e226085451d6adf1dc5282cbba129d553713’ body_size: 52 body: b’Ownership is

    transfered from user_default to someone’ Witness: [0] user_id: b’e59c553504ca7a54f888eb47e61b773a221ae1311bd58ec4c0912d71c443d715’ sig_index: 0 [1] user_id: b’2a59d59e3809f827ce709d3815e3950eef4a6a93af5557a93a7fdfba71460843’ sig_index: 1 Cross_Ref: None — 2018-08-15 – p.54/94
  34. (3) Signature[]: 2 [0] key_type: 1 signature: b’149b0fd48137fec9a076b9214de857da285f2bcc7e634579ac519eada35386179b9c 78e6aa20910165648d8bef62e625d449445626d9c7bcdfaf63d1279331ee’ pubkey:

    b’04dc03d221c173fb2cf49bd4f2077fdd88babaa8234a96353b245cb3450ca665a12adb1 86695040188b366f12569b892c63f8410b9e471c4f1cf6f3ff96ddc48fc’ [1] key_type: 1 signature: b’51f77ef2b66bd61db125facbc478c03df5a258af8fded20501c00665594c910604e7d e5c5b75d0259cf8716acd1e99a193fc79f20173b175e1b8bfe72c530df0’ pubkey: b’045833b8045305cb4da21f17cef4c44941de6152d0cfc0c77bc638071a8b86337a59f474 fc11e924a5afe7f3fc4e43491a55193c32f9403ca574ddc088cf8d5158’ — 2018-08-15 – p.55/94
  35. GitHub git clone $ git clone https://github.com/beyond-blockchain/bbc1-lib-std.git $ cd bbc1-lib-std

    $ git checkout develop tar pip $ python setup.py sdist $ pip install dist/bbc1-lib-std-0.11.0.tar.gz — 2018-08-15 – p.58/94
  36. ( SQLite3 ) ( ) ( ) ( ) (

    ) — 2018-08-15 – p.59/94
  37. GitHub git clone $ git clone https://github.com/beyond-blockchain/bbc1-lib-tokens.git $ cd bbc1-lib-tokens

    $ git checkout develop tar pip $ python setup.py sdist $ pip install dist/bbc1-lib-tokens-0.10.0.tar.gz bbc_core.py — 2018-08-15 – p.60/94
  38. payment GitHub git clone $ git clone https://github.com/beyond-blockchain/examples.git $ cd

    examples/payment payment.py BBc-1 — 2018-08-15 – p.64/94
  39. $ python payment.py --help (bbc_core.py ) $ python payment.py setup

    “./.bbc1_app_support” — 2018-08-15 – p.66/94
  40. alice bob $ python payment.py def-user alice $ python payment.py

    def-user bob alice bob ( ) — 2018-08-15 – p.67/94
  41. $ python payment.py user alice ∗bob bob ( bob )

    alice $ python payment.py user alice ∗alice bob — 2018-08-15 – p.68/94
  42. $ python payment.py def-currency Yen JPY default_spec.json (mint) ( )

    $ python payment.py currency ∗Yen — 2018-08-15 – p.69/94
  43. alice 1,000 $ python payment.py issue 1000 alice mint alice

    bob $ python payment.py status alice balance = 1000JPY. $ python payment.py status bob balance = 0JPY. — 2018-08-15 – p.70/94
  44. alice bob 100 $ python payment.py transfer 100 bob alice

    mint $ python payment.py status alice balance = 900JPY. $ python payment.py status bob balance = 100JPY. — 2018-08-15 – p.71/94
  45. 2 $ python payment.py def-currency Dollar USD decimal_2.json mint (

    ) $ python payment.py currency Yen ∗Dollar — 2018-08-15 – p.72/94
  46. (1) ( ) bob 10 $ python payment.py issue 10

    bob mint alice bob $ python payment.py status alice balance = 0.00USD. $ python payment.py status bob balance = 10.00USD. — 2018-08-15 – p.73/94
  47. (2) $ python payment.py currency Yen ∗Yen Dollar alice bob

    1 110 (bob alice 110 1 ) $ python payment.py swap 110 bob 1 Dollar alice, bob, mint, mint — 2018-08-15 – p.74/94
  48. (3) alice bob $ python payment.py status alice balance =

    790JPY. $ python payment.py status bob balance = 210JPY. $ python payment.py currency Dollar Yen ∗Dollar $ python payment.py status alice balance = 1.00USD. $ python payment.py status bob balance = 9.00USD. — 2018-08-15 – p.75/94
  49. token lib mint token_lib.BBcMint mint.transfer() . . . transaction mint.store.sign()

    . . . mint.store.sign_and_insert() . . . — 2018-08-15 – p.78/94
  50. 304 mint.swap(counter_mint, user.user_id, counter_user.user_id, value1, value2, keypair_this=user.keypair, keypair_that=counter_user.keypair, keypair_mint=currency.keypair, keypair_counter_mint=counter_currency.keypair)

    ⇓ tx = mint.transfer(user.user_id, counter_user.user_id, value1) counter_mint.transfer(counter_user.user_id, user.user_id, value2, transaction=tx) mint.store.sign(tx, counter_user.user_id, counter_user.keypair) mint.store.sign(tx, mint.mint_id, currency.keypair) mint.store.sign(tx, counter_mint.mint_id, counter_currency.keypair) mint.store.sign_and_insert(tx, user.user_id, user.keypair, mint.idPublickeyMap) — 2018-08-15 – p.79/94
  51. Go Etheruem macOS + Homebrew $ brew install geth Linux

    (Ubuntu 16.04 LTS ) $ sudo apt install software-properties-common $ sudo add-apt-repository -y ppa:ethereum/ethereum $ sudo apt update $ sudo apt install ethereum Windows 10 Linux (Ubuntu 16.04 LTS ) — 2018-08-15 – p.82/94
  52. Solidity macOS + Homebrew $ brew install solidity Linux (Ubuntu

    16.04 LTS ), Windows 10 $ sudo apt install solc — 2018-08-15 – p.83/94
  53. git clone $ git clone https://github.com/beyond-blockchain/ledger_subsystem.git $ cd ledger_subsystem tar

    pip $ python setup.py sdist $ pip install dist/ledger_subsystem-0.11.0.tar.gz — 2018-08-15 – p.85/94
  54. (1) “bbc_core.py” BBc-1 Core bbc_core.py populus $ eth_subsystem_tool.py -w ∼/.bbc1

    populus Genesis $ eth_subsystem_tool.py -w ∼/.bbc1 genesis Ethereum $ eth_subsystem_tool.py -w ∼/.bbc1 new_account — 2018-08-15 – p.87/94
  55. (2) geth $ eth_subsystem_tool.py -w ∼/.bbc1 run_geth $ tail -f

    geth.log BBcAnchor ( ) $ eth_subsystem_tool.py -w ∼/.bbc1 deploy geth $ eth_subsystem_tool.py -w ∼/.bbc1 stop_geth “run_geth” — 2018-08-15 – p.88/94
  56. BBcAnchor.sol ( ) contract BBcAnchor { mapping (uint256 => uint)

    public _digests; constructor () public { } function getStored(uint256 digest) public returns (uint block_no) { return (_digests[digest]); } function isStored(uint256 digest) public returns (bool isStored) { return (_digests[digest] > 0); } function store(uint256 digest) public returns (bool isAlreadyStored) { bool isRes = _digests[digest] > 0; if (!isRes) { _digests[digest] = block.number; } return (isRes); } } — 2018-08-15 – p.89/94
  57. (“bbc_core.py” ) $ eth_subsystem_tool.py -w ∼/.bbc1 config_demo 100 30 domain_id

    ( ) “bbc_core.py” $ eth_subsystem_tool.py -w ∼/.bbc1 -d enable — 2018-08-15 – p.91/94
  58. 3 $ eth_subsystem_tool.py -w ∼/.bbc1 -d register_demo 3 transaction_id (

    ) $ eth_subsystem_tool.py -w ∼/.bbc1 -d verify 30 verify — 2018-08-15 – p.92/94