A Merkle tree is a data structure for representing a key-value store as a tree. Each node of a Merkle tree is equipped with a hash value computed from those of their descendants. A Merkle tree is often used for representing a state of a blockchain system since it can be used for efficiently auditing the state in a trustless manner. Due to the safety-critical nature of blockchains, ensuring the correctness of their implementation is paramount. We show our formally verified implementation of the core part of Plebeia using F*. Plebeia is a library to manipulate an extension of Merkle trees (called Plebeia trees). It is being implemented as a part of the storage system of the Tezos blockchain system. To this end, we gradually ported Plebeia to F*; the OCaml code extracted from the modules ported to F* is linked with the unverified part of Plebeia. By this gradual porting process, we can obtain a working code from our partially verified implementation of Plebeia; we confirmed that the binary passes all the unit tests of Plebeia. More specifically, we verified the following properties on the implementation of Plebeia: (1) Each tree-manipulating function preserves the invariants on the data structure of a Plebeia tree and satisfies the functional requirements as a nested key-value store; (2) Each function for serializing/deserializing a Plebeia tree to/from the low-level storage is implemented correctly; and (3) The hash function for a Plebeia tree is relatively collision-resistant with respect to the cryptographic safety of the blake2b hash function. During porting Plebeia to F*, we found a bug in an old version of Plebeia, which was overlooked by the tests bundled with the original implementation. To the best of our knowledge, this is the first work that verifies a production-level implementation of a Merkle-tree library by F*.
翻译:Merkle 树是一个代表关键值树的树的数据结构。 Merkle 树的每个节点都配有从后代身上计算出来的散数值。 Merkle 树通常用于代表一个链链系统状态, 因为可以无信任的方式使用这一系统来高效地审计国家。 由于块链的安全临界性质, 确保其执行的正确性是至关紧要的。 我们用 F* 展示了我们正式核实的普列贝亚核心部分的执行情况。 Plebeia 是一个管理Merkle 树的延伸( 称为 Plebea 树 ) 的图书馆图书馆库库库。 正在作为Tezos 链系统存储系统的一部分实施Merkle kle kree 树。 为此,我们逐渐将Plebea 移植到 F* ; 从连接 F* 的模块提取的OCaml 代码与未核实部分执行的Plebeya 程序连接。 通过这个渐进的移植程序, 我们从我们部分核实了Plebea 执行过程获得工作代码; 我们确认的是, 将Plebea 的系统的所有单位测试的功能从一个相对的运行运行的功能运行运行功能。