-
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.
Added links and overview to @JavaDoc
- Loading branch information
Showing
3 changed files
with
65 additions
and
2 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
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,58 @@ | ||
<html> | ||
<body> | ||
<h1 id="merkletree">Merkle Tree</h1> | ||
|
||
<p>A generic implementation of Merkle trees</p> | ||
|
||
<h2 id="usage">Usage</h2> | ||
|
||
<p>Add <em>merkle-tree</em> as a dependency to your project.</p> | ||
|
||
<ul> | ||
<li>Gradle</li> | ||
</ul> | ||
|
||
<pre><code> implementation 'ascelion.public:merkle-tree:1.0.0' | ||
</code></pre> | ||
|
||
<ul> | ||
<li>Maven</li> | ||
</ul> | ||
|
||
<pre><code class="` language-`"> <dependency> | ||
<groupId>ascelion.public</groupId> | ||
<artifactId>merkle-tree</artifactId> | ||
<version>1.0.0</version> | ||
</dependency> | ||
</code></pre> | ||
|
||
<p>`</p> | ||
|
||
<p>Use the TreeBuilder to create a Merkle tree</p> | ||
|
||
<pre><code> // create a hash function | ||
UnaryOperator<String> hashFn = ... | ||
|
||
// create a concatenation function | ||
BinaryOperator<String, String> concatFn = (s1, s2) -> s1 + s2; | ||
|
||
// create a tree builder | ||
TreeBuilder<String> tbd = new TreeBuilder<>(hashFn, concatFn, ""); | ||
|
||
// add some nodes and build the tree | ||
TreeRoot<String> root = tbd | ||
.collect( new TreeLeaf<>(hashFn, "s1" ) | ||
// .... | ||
.collect( new TreeLeaf<>(hashFn, "s2") ) | ||
.build(); | ||
|
||
// get a leaf | ||
TreeLeaf<String> leaf1 = root.getLeaf( 0 ); | ||
|
||
// validate the hash chain | ||
assertTrue( tbd.validate( leaf1.getChain() ) ); | ||
</code></pre> | ||
|
||
<p>You may also want to check the <a href="https://github.com/ascelion/merkle-tree/tree/master/demo">demo project</a> for a real example.</p> | ||
</body> | ||
</html> |
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