$30 off During Our Annual Pro Sale. View Details »

DBFS - ElixirConf EU 2018 (Lightning Talk)

DBFS - ElixirConf EU 2018 (Lightning Talk)

My lightning talk about building a naive blockchain-based file storage in Elixir and React, with scalability and distribution in mind.

Sheharyar Naseer

April 16, 2018
Tweet

More Decks by Sheharyar Naseer

Other Decks in Technology

Transcript

  1. BLOCKCHAIN BASED FILE STORAGE

  2. SHEHARYAR NASEER sheharyarn shyr.io

  3. DIDN'T HODL

  4. blockchain noun /ˈbläkˌCHān/ A decentralized, distributed digital ledger that is

    used to record transactions across many computers so that the record cannot be altered retroactively without the alteration of all subsequent blocks [...]
  5. BLOCK 5 Data: Timestamp: Previous: Current: 34k0scf 2018-01-05 13:24:56 3662c6f8dc7b519123c

    f9d644657c3d7c80a6f rth760ls 2018-01-07 18:43:12 f9d644657c3d7c80a6f bbd658cb57bb0d2138 BLOCK 6 Data: Timestamp: Previous: Current: qnb49f0 2018-01-08 06:11:34 bbd658cb57bb0d2138 8327ed293f7834c6572 BLOCK 7 Data: Timestamp: Previous: Current:
  6. ARCHITECTURE – Blockchain Structure – File Storage – Cryptography –

    Synchronization – Client API
  7. BLOCKCHAIN %Block{ type: ..., timestamp: ..., data: %{ file_name: ...,

    file_hash: ..., file_key: ..., }, prev: ..., creator: ..., hash: ..., signature: ... }
  8. FILE STORAGE – Nothing fancy – Directly on the disk

    – Encrypted – Block hash as identifier
  9. CRYPTOGRAPHY – Public Key: RSA – Symmetric: AES

  10. CRYPTOGRAPHY – Public Key: RSA – Symmetric: AES – Hashing:

    SHA256 – Encoding: Base64
  11. SYNCHRONIZATION – Erlang VM: Easy Distribution – Consensus: Raft –

    Elect 'leader' – Use it as a reference
  12. SYNCHRONIZATION – Find where the chain diverges – Send the

    succeeding block def sync_next(leader, hash) do %{block: block, file: file} = :rpc.call(leader, Blockchain, :next, [hash]) Blockchain.insert(block, file) end
  13. CLIENT API – Phoenix – List, Upload, Download – Ecto

    Validations – Status Channel
  14. CLIENT API – React – Encrypt the file on client-side

    – Form the block – Sign it and calculate hash – Insert it into the blockchain
  15. DEMO

  16. OUTRO Elixir App: to.shyr.io/dbfs React App: to.shyr.io/dbfs-web shyr.io ~@shyr.io sheharyarn