Paper.tex 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. \documentclass{article}
  2. \usepackage{amsfonts,amssymb,amsmath}
  3. \usepackage[scale=0.75]{geometry}
  4. \usepackage{hyperref}
  5. \title{Blocktree \\
  6. \large A platform for distributed computing.}
  7. \author{Matthew Carr}
  8. \date{May 28, 2022}
  9. \begin{document}
  10. \maketitle
  11. \begin{abstract}
  12. Blocktree is a platform which aims to make developing reliable distributed systems easy and safe.
  13. It does this by defining a format for data stored in the system, a mechanism for replicating
  14. that data, and a programming interface for accessing it. It aims to solve the difficult problems
  15. of cryptographic key management, consensus, and global addressing so that user code can focus on
  16. solving problems germane to their application.
  17. \end{abstract}
  18. \section{Introduction}
  19. (Do I need this?)
  20. \section{An Individual Blocktree}
  21. The atomic unit of data storage and privacy and authenticity guarantees is called a block. A
  22. block contains a payload of data. Confidentiality of this data is achieved by encrypting it using
  23. a symmetric cipher using a random key. This random key is known as the block key.
  24. The block key is encapsualated using
  25. a public key cipher and the resulting cipher text is stored in the header of the block. Thus
  26. only the person possessing the corresponding private key will be able to access the contents of
  27. the block. Blocks are arranged into trees, and the parent of the block also has a block key.
  28. The child's block key is always encapsulated using the parent's key and stored in the block
  29. header. This ensures that if a principal is given access to a block, they automatically have
  30. access to every child of that block. The encapsulated block key is known as a read capability,
  31. or readcap, as it grants the holder the ability to the block.
  32. Authenticity guarantees are provided using a digital signature scheme. In order to change the
  33. contents of a block a data structure called a write capability, or writecap, is needed. A
  34. writecap is approximately an x509 certificate chain. A writecap contains the following data:
  35. \begin{itemize}
  36. \item The path the writecap can be used under.
  37. \item The principal that the writecap was issued to.
  38. \item The timestamp when the writecap expires.
  39. \item The public key of the principal who issued the writecap.
  40. \item A digital signature produced by the private key corresponding to the above public key.
  41. \item Optionally, the next writecap in the chain.
  42. \end{itemize}
  43. The last item is only excluded in the case of a self-signed writecap, i.e. one that was signed by
  44. the same principal it was issued to. A writecap is considered valid for use on a block if all
  45. of the following conditions are true:
  46. \begin{itemize}
  47. \item The signature on every writecap in the chain is valid.
  48. \item The signing principal matches the principal the next writecap was issued to for every
  49. write cap in the chain.
  50. \item The path of the block is contained in the path of every writecap in the chain.
  51. \item The current timestamp is strictly less than the expiration of all the writecaps in the
  52. chain.
  53. \item The principal corresponding to public key used to sign the last writecap in the chain,
  54. is the owner of the blocktree.
  55. \end{itemize}
  56. The intiution behind these rules is that a writecap is only valid if there is a chain of trust
  57. that leads back to the owner of the block tree. The owner may delegate their trust to any number
  58. of intermediaries by issuing them writecaps. These writecaps are scoped based on the path
  59. specified when they are issued. These intermediaries can then delegate this trust as well.
  60. A block is considered valid if it contains a valid writecap, it was signed using the key
  61. corresponding to the first writecap's public key, and this signature is valid.
  62. Blocks are used for more than just orgnaizing data, they also organize computation. A program
  63. participating in the blocktree network is referred to as a node. Multiple nodes may be run on
  64. a single computer. Every node is attached to the blocktree at a specific path. This information
  65. is recorded in the block where the node is attached. A node is responsible for the storage of
  66. the block where it is attached and the blocks that are descended from this block, unless there
  67. is another node attached to a descendent block.
  68. In this way data storage can be delegated, allowing
  69. the system to scale. When more than one node is attached to the same block they form a cluster.
  70. Each node in the cluster contains a copy of the data that the cluster is reponsible for. They
  71. maintain consistency of this data by running the Raft consensus protocol.
  72. \section{Connecting Blocktrees}
  73. In order to allow nodes to access blocks in other blocktrees, a global ledger of events is used.
  74. This ledger is implemented using a proof of work (PoW) blockchain and a corresponding
  75. cryptocurrency known as blockcoin. Nodes mine chain blocks (not to be confused with the tree
  76. blocks we've been discussing up till now) in the same way they do in other PoW blockchain
  77. systems such as BitCoin. The node which manages to mine the next chain block receives a reward,
  78. which is the sum of the fees for each event in the chain and a variable amount of newly minted
  79. blockcoin. The amount of new blockcoin created by a chain block is directly proportional to the
  80. amount of data storage events contained in the chain block. Thus the total amount of blockcoin
  81. in circulation has a direct relationship to the amount of data stored in the system, reflecting
  82. the fact that blockcoin exists to provide and accounting mechanism for data stored in the system.
  83. When a node writes data to a tree block, and it wishes this block to be globally accessible, then
  84. it produces what are called fragments. Fragments are the output symbols from an Erasure Coding
  85. algorithm (such as the RaptorQ code). These algorithms are a class of fountain codes which have
  86. the property that only $m$ out of $n$ (where $m < n$) symbols are needed to reconstruct the
  87. original data. Such a code ensures that even if some of the fragments are lost, as long as $m$
  88. remain, the original data can be recovered.
  89. Once these fragments have been computed an event is created for each one and published to the
  90. blockchain. This event indicates to other nodes that this node wishes to store a fragment and
  91. states the amount of blockcoin the node will pay to the first node that accepts the offer. When
  92. another nodes wishes to accept the offer, it directly contacts the first node, who then sends
  93. it the fragment an publishes and event stating that the fragment is stored with the second
  94. node. This event includes the path of the block the fragment was computed from, the fragment's
  95. ID (the sequence number from the erasure code), and the principal of the node which stored it.
  96. Thus any other node in the network can use the information contained in these events to
  97. determine the set of nodes which contain the fragments of any given path.
  98. In order for nodes to be able to conntact other nodes, a mechanism is required for associating
  99. an internet protocol (IP) address with a principal. This is done by having nodes publish events
  100. to the blockchain when their IP address changes. This event includes their new IP address,
  101. their public key, and a digital signature computed using their private key. Other nodes can
  102. then verify this signature to ensure that an attacker cannot bind the wrong
  103. IP address to a principal in order to receive messages it was not meant to have.
  104. While this event ledger is useful for appending new events, and ensuring that previous events
  105. cannot be changed, another data structure is required to ensure that queries on this data can
  106. be performed efficiently. In particular, it's important to be able to quickly perform the
  107. following queries:
  108. \begin{itemize}
  109. \item Find the set of nodes storing the fragments for a given path.
  110. \item Find the IP address of a node or owner given a principal.
  111. \item Find the public key associated with a principal.
  112. \end{itemize}
  113. These are enabled by creating a read model from the data in the event ledger. One possible
  114. implementation of this read model is the following SQL database.
  115. This database contains two tables:
  116. \begin{itemize}
  117. \item \emph{Fragments}: one column containing path, one for the fragment ID, and another for the principal. Indexed on the path column.
  118. \item \emph{Principals}: one column containing principal, one column for the public key, and
  119. one column for the IP address, one columns for the amount blockcoin the principal has.
  120. Indexed on the principal column.
  121. \end{itemize}
  122. This index is built from the event ledger by iterating over it, and modifying the database
  123. appropriately for each event. For instance when a fragment stored event is encountered then
  124. a row is added to the \emph{Fragments} table containing the path of the block, the fragment ID,
  125. and the principal which were recorded in the event. The reader who is experienced with software
  126. patterns will recognize that this is an event sourced architecture.
  127. \section{Programming Interface}
  128. \end{document}