-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 0ce368d
Showing
10 changed files
with
1,170 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Revision history for merkle-log | ||
|
||
## 0.1.0.0 -- YYYY-mm-dd | ||
|
||
* First version. Released on an unsuspecting world. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
Copyright (c) 2019, Kadena LLC | ||
|
||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
|
||
* Redistributions in binary form must reproduce the above | ||
copyright notice, this list of conditions and the following | ||
disclaimer in the documentation and/or other materials provided | ||
with the distribution. | ||
|
||
* Neither the name of Lars Kuhtz nor the names of other | ||
contributors may be used to endorse or promote products derived | ||
from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# Haskell Implementation of Merkle Tree Logs | ||
|
||
This packages implements Merkle Tree Logs as described in RFC 6962 in Haskell. | ||
|
||
## Format | ||
|
||
The implementation stores Merkle trees in a packed format in memory. This allows | ||
for efficient construction, serialization, and querying. Trees are opaque | ||
objects that are allocated and deallocated as well as serialized and | ||
deserialized as a whole, which matches many use cases. Also, trees can be easily | ||
nested, by building larger Merkle trees that have smaller trees as inputs to | ||
their leafs. | ||
|
||
The overhead per indexed item is 64 bytes when 256 bit hashes are used. Thus, | ||
about 16,000 items can be index in 1MB of memory. | ||
|
||
We plan to make the trees extensible and support loading and storing trees in | ||
chunks that represent immutable full subtrees. Please file an issue on GitHub if | ||
you need this feature. | ||
|
||
## Proofs | ||
|
||
Proofs are self contained and don't rely on a particular implementation of | ||
Merkle tree. In particular, proofs don't depend on how the tree is balanced. | ||
|
||
A proof contains the proof subject (the input for which inclusion is proven) as | ||
a plain `ByteString`. The result of validating a proof is a Merkle tree root | ||
that must match the root of the Merkle tree that includes the subject. A proof | ||
doesn't include the root hash of the Merkle tree, because the root must be | ||
obtained from a trusted / authenticated source. Including it in the proof would | ||
thus be redundant and may even be misleading. | ||
|
||
At the moment only inclusion / audit proofs are supported. We plan to also | ||
implement consistency proofs. Please file an issue on GitHub if you need | ||
consistency proofs. | ||
|
||
## Build and Installation | ||
|
||
The package can be build with cabal via | ||
|
||
```sh | ||
cabal new-update | ||
cabal new-build merkle-log | ||
``` | ||
|
||
The test suite can be run with | ||
|
||
```sh | ||
cabal new-test merkle-log | ||
``` | ||
|
||
Benchmarks are available via | ||
|
||
|
||
```sh | ||
cabal new-bench merkle-log | ||
``` | ||
|
||
## Benchmarks | ||
|
||
The following benchmark results compare the performance of this package with | ||
the Merkle tree implementations in the packages | ||
[merkle-tree](http://hackage.haskell.org/package/merkle-tree) and | ||
[hash-tree](http://hackage.haskell.org/package/hash-tree) for different hash | ||
functions on a 64bit Intel CPU. | ||
|
||
Create tree: | ||
|
||
 | ||
|
||
Create inclusion proof: | ||
|
||
 | ||
|
||
Verify inclusion proof: | ||
|
||
 | ||
|
Oops, something went wrong.