diff --git a/.gitignore b/.gitignore index 62fe02f..1e7caa9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -target/debug Cargo.lock +target/ diff --git a/docs/implementors/core/cmp/trait.PartialEq.js b/docs/implementors/core/cmp/trait.PartialEq.js new file mode 100644 index 0000000..043586b --- /dev/null +++ b/docs/implementors/core/cmp/trait.PartialEq.js @@ -0,0 +1,10 @@ +(function() {var implementors = {}; +implementors["merkle"] = ["impl<T: PartialEq> PartialEq for Positioned<T>",]; + + if (window.register_implementors) { + window.register_implementors(implementors); + } else { + window.pending_implementors = implementors; + } + +})() diff --git a/docs/implementors/merkle/trait.Hashable.js b/docs/implementors/merkle/trait.Hashable.js deleted file mode 100644 index c3b3263..0000000 --- a/docs/implementors/merkle/trait.Hashable.js +++ /dev/null @@ -1,10 +0,0 @@ -(function() {var implementors = {}; -implementors["merkle"] = []; - - if (window.register_implementors) { - window.register_implementors(implementors); - } else { - window.pending_implementors = implementors; - } - -})() diff --git a/docs/main.css b/docs/main.css index aee6d15..6a9a24f 100644 --- a/docs/main.css +++ b/docs/main.css @@ -26,7 +26,7 @@ h1.fqn { h2, h3:not(.impl):not(.method):not(.type):not(.tymethod), h4:not(.method):not(.type):not(.tymethod) { border-bottom-color: #DDDDDD; } -.in-band, code { +.in-band { background-color: white; } @@ -34,7 +34,7 @@ div.stability > em > code { background-color: initial; } -.docblock code { +.docblock code, .docblock-short code { background-color: #F5F5F5; } pre { @@ -107,13 +107,13 @@ nav.main .current { border-bottom-color: #000; } nav.main .separator { - border-color: 1px solid #000; + border: 1px solid #000; } a { color: #000; } -.docblock a, .stability a { +.docblock a, .docblock-short a, .stability a { color: #3873AD; } diff --git a/docs/main.js b/docs/main.js index 68035e5..9bb7246 100644 --- a/docs/main.js +++ b/docs/main.js @@ -34,7 +34,8 @@ "primitive", "associatedtype", "constant", - "associatedconstant"]; + "associatedconstant", + "union"]; // used for special search precedence var TY_PRIMITIVE = itemTypes.indexOf("primitive"); @@ -577,10 +578,6 @@ displayPath = item.path + '::'; href = rootPath + item.path.replace(/::/g, '/') + '/' + name + '/index.html'; - } else if (type === 'static' || type === 'reexport') { - displayPath = item.path + '::'; - href = rootPath + item.path.replace(/::/g, '/') + - '/index.html'; } else if (type === "primitive") { displayPath = ""; href = rootPath + item.path.replace(/::/g, '/') + @@ -591,9 +588,14 @@ } else if (item.parent !== undefined) { var myparent = item.parent; var anchor = '#' + type + '.' + name; - displayPath = item.path + '::' + myparent.name + '::'; + var parentType = itemTypes[myparent.ty]; + if (parentType === "primitive") { + displayPath = myparent.name + '::'; + } else { + displayPath = item.path + '::' + myparent.name + '::'; + } href = rootPath + item.path.replace(/::/g, '/') + - '/' + itemTypes[myparent.ty] + + '/' + parentType + '.' + myparent.name + '.html' + anchor; } else { diff --git a/docs/merkle/MerkleDigest.t.html b/docs/merkle/MerkleDigest.t.html new file mode 100644 index 0000000..d8c8889 --- /dev/null +++ b/docs/merkle/MerkleDigest.t.html @@ -0,0 +1,10 @@ + + + + + + +

Redirecting to trait.MerkleDigest.html...

+ + + \ No newline at end of file diff --git a/docs/merkle/MerkleTree.t.html b/docs/merkle/MerkleTree.t.html new file mode 100644 index 0000000..878b8fc --- /dev/null +++ b/docs/merkle/MerkleTree.t.html @@ -0,0 +1,10 @@ + + + + + + +

Redirecting to struct.MerkleTree.html...

+ + + \ No newline at end of file diff --git a/docs/merkle/Positioned.t.html b/docs/merkle/Positioned.t.html new file mode 100644 index 0000000..22306db --- /dev/null +++ b/docs/merkle/Positioned.t.html @@ -0,0 +1,10 @@ + + + + + + +

Redirecting to enum.Positioned.html...

+ + + \ No newline at end of file diff --git a/docs/merkle/Proof.t.html b/docs/merkle/Proof.t.html new file mode 100644 index 0000000..8e3d026 --- /dev/null +++ b/docs/merkle/Proof.t.html @@ -0,0 +1,10 @@ + + + + + + +

Redirecting to struct.Proof.html...

+ + + \ No newline at end of file diff --git a/docs/merkle/ProofBlock.t.html b/docs/merkle/ProofBlock.t.html new file mode 100644 index 0000000..4c0cf0e --- /dev/null +++ b/docs/merkle/ProofBlock.t.html @@ -0,0 +1,10 @@ + + + + + + +

Redirecting to struct.ProofBlock.html...

+ + + \ No newline at end of file diff --git a/docs/merkle/enum.Positioned.html b/docs/merkle/enum.Positioned.html new file mode 100644 index 0000000..b710609 --- /dev/null +++ b/docs/merkle/enum.Positioned.html @@ -0,0 +1,126 @@ + + + + + + + + + + merkle::Positioned - Rust + + + + + + + + + + + + + + + + + +
+

Enum merkle::Positioned + + [] + + [src]

+
pub enum Positioned<T> {
+    Nowhere,
+    Left(T),
+    Right(T),
+}

Tags a value so that we know from in branch (if any) it was found.

+

Variants

+

No value was found

+

The value was found in the left branch

+

The value was found in the right branch

+

Trait Implementations

impl<T: PartialEq> PartialEq for Positioned<T>
[src]

+

+

This method tests for self and other values to be equal, and is used by ==. Read more

+

+

This method tests for !=.

+
+ + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/merkle/enum.Tree.html b/docs/merkle/enum.Tree.html deleted file mode 100644 index 61669b0..0000000 --- a/docs/merkle/enum.Tree.html +++ /dev/null @@ -1,137 +0,0 @@ - - - - - - - - - - merkle::Tree - Rust - - - - - - - - - - - - - - - - - -
-

Enum merkle::Tree - - [] - - [src]

-
pub enum Tree<T> {
-    Leaf {
-        hash: Vec<u8>,
-        value: T,
-    },
-    Node {
-        hash: Vec<u8>,
-        left: Box<Tree<T>>,
-        right: Box<Tree<T>>,
-    },
-}

Binary Tree where leaves hold a stand-alone value.

-

Variants

-Leaf

Fields

- -
hash: Vec<u8>
value: T
Node

Fields

- -
hash: Vec<u8>
left: Box<Tree<T>>
right: Box<Tree<T>>

Methods

impl<T> Tree<T> where T: Hashable
[src]

-

fn new(hash: Vec<u8>, value: T) -> Self

-

Create a new tree

-

fn get_hash(&self) -> &Vec<u8>

-

Returns a hash from the tree.

-

fn make_leaf<D: Digest>(digest: &mut D, value: T) -> Tree<T>

-

Create a new leaf

-
- - - - - - - - - - - - - - - \ No newline at end of file diff --git a/docs/merkle/hashable/trait.Hashable.html b/docs/merkle/hashable/trait.Hashable.html deleted file mode 100644 index ed01c03..0000000 --- a/docs/merkle/hashable/trait.Hashable.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - -

Redirecting to ../../merkle/trait.Hashable.html...

- - - \ No newline at end of file diff --git a/docs/merkle/index.html b/docs/merkle/index.html index 0ecd6f0..6c36c95 100644 --- a/docs/merkle/index.html +++ b/docs/merkle/index.html @@ -47,39 +47,52 @@ [] - [src] + [src]

merkle implements a Merkle Tree in Rust.

-

Reexports

-
pub extern crate crypto;

Structs

+

Structs

- + + + + + + + +
MerkleTree -

The Merkle tree

+
+

A Merkle tree is a binary tree, with values of type T at the leafs, +and where every node holds the hash of the concatenation of the hashes of +its children nodes.

+
Proof +

An inclusion proof represent the fact that value is a member of a MerkleTree +with root hash root_hash, and hash function digest. +A proof is a linked-list of ProofBlocks. +TODO: Represent a proof as a vector of ProofBlock instead of a linked-list?

+
ProofBlock +

A ProofBlock is a linked-list holding the hash of the node, the hash of its sibling node, +and the rest of the inclusion proof.

Enums

- - +
Tree -

Binary Tree where leaves hold a stand-alone value.

+
Positioned +

Tags a value so that we know from in branch (if any) it was found.

Traits

- - - - -
Hashable -

By definition, data in the Merkle Tree must implement Hashable

-
MerkleDigest -

Extends the standard crypto::digest::Digest to play nicely with our Merkle Tree

+
+

The sole purpose of this trait is to extend the standard +crypto::digest::Digest with a couple utility functions.

@@ -137,11 +150,9 @@ - \ No newline at end of file diff --git a/docs/merkle/merkledigest/MerkleDigest.t.html b/docs/merkle/merkledigest/MerkleDigest.t.html new file mode 100644 index 0000000..d8c8889 --- /dev/null +++ b/docs/merkle/merkledigest/MerkleDigest.t.html @@ -0,0 +1,10 @@ + + + + + + +

Redirecting to trait.MerkleDigest.html...

+ + + \ No newline at end of file diff --git a/docs/merkle/merkletree/MerkleTree.t.html b/docs/merkle/merkletree/MerkleTree.t.html new file mode 100644 index 0000000..878b8fc --- /dev/null +++ b/docs/merkle/merkletree/MerkleTree.t.html @@ -0,0 +1,10 @@ + + + + + + +

Redirecting to struct.MerkleTree.html...

+ + + \ No newline at end of file diff --git a/docs/merkle/merkletree/Proof.t.html b/docs/merkle/merkletree/Proof.t.html new file mode 100644 index 0000000..8e3d026 --- /dev/null +++ b/docs/merkle/merkletree/Proof.t.html @@ -0,0 +1,10 @@ + + + + + + +

Redirecting to struct.Proof.html...

+ + + \ No newline at end of file diff --git a/docs/merkle/merkletree/ProofBlock.t.html b/docs/merkle/merkletree/ProofBlock.t.html new file mode 100644 index 0000000..4c0cf0e --- /dev/null +++ b/docs/merkle/merkletree/ProofBlock.t.html @@ -0,0 +1,10 @@ + + + + + + +

Redirecting to struct.ProofBlock.html...

+ + + \ No newline at end of file diff --git a/docs/merkle/merkletree/struct.Proof.html b/docs/merkle/merkletree/struct.Proof.html new file mode 100644 index 0000000..3c58e04 --- /dev/null +++ b/docs/merkle/merkletree/struct.Proof.html @@ -0,0 +1,10 @@ + + + + + + +

Redirecting to ../../merkle/struct.Proof.html...

+ + + \ No newline at end of file diff --git a/docs/merkle/merkletree/struct.ProofBlock.html b/docs/merkle/merkletree/struct.ProofBlock.html new file mode 100644 index 0000000..9e28ba8 --- /dev/null +++ b/docs/merkle/merkletree/struct.ProofBlock.html @@ -0,0 +1,10 @@ + + + + + + +

Redirecting to ../../merkle/struct.ProofBlock.html...

+ + + \ No newline at end of file diff --git a/docs/merkle/proof/Positioned.t.html b/docs/merkle/proof/Positioned.t.html new file mode 100644 index 0000000..22306db --- /dev/null +++ b/docs/merkle/proof/Positioned.t.html @@ -0,0 +1,10 @@ + + + + + + +

Redirecting to enum.Positioned.html...

+ + + \ No newline at end of file diff --git a/docs/merkle/proof/Proof.t.html b/docs/merkle/proof/Proof.t.html new file mode 100644 index 0000000..8e3d026 --- /dev/null +++ b/docs/merkle/proof/Proof.t.html @@ -0,0 +1,10 @@ + + + + + + +

Redirecting to struct.Proof.html...

+ + + \ No newline at end of file diff --git a/docs/merkle/proof/ProofBlock.t.html b/docs/merkle/proof/ProofBlock.t.html new file mode 100644 index 0000000..4c0cf0e --- /dev/null +++ b/docs/merkle/proof/ProofBlock.t.html @@ -0,0 +1,10 @@ + + + + + + +

Redirecting to struct.ProofBlock.html...

+ + + \ No newline at end of file diff --git a/docs/merkle/proof/enum.Positioned.html b/docs/merkle/proof/enum.Positioned.html new file mode 100644 index 0000000..9703976 --- /dev/null +++ b/docs/merkle/proof/enum.Positioned.html @@ -0,0 +1,10 @@ + + + + + + +

Redirecting to ../../merkle/enum.Positioned.html...

+ + + \ No newline at end of file diff --git a/docs/merkle/proof/struct.Proof.html b/docs/merkle/proof/struct.Proof.html new file mode 100644 index 0000000..3c58e04 --- /dev/null +++ b/docs/merkle/proof/struct.Proof.html @@ -0,0 +1,10 @@ + + + + + + +

Redirecting to ../../merkle/struct.Proof.html...

+ + + \ No newline at end of file diff --git a/docs/merkle/proof/struct.ProofBlock.html b/docs/merkle/proof/struct.ProofBlock.html new file mode 100644 index 0000000..9e28ba8 --- /dev/null +++ b/docs/merkle/proof/struct.ProofBlock.html @@ -0,0 +1,10 @@ + + + + + + +

Redirecting to ../../merkle/struct.ProofBlock.html...

+ + + \ No newline at end of file diff --git a/docs/merkle/sidebar-items.js b/docs/merkle/sidebar-items.js index e6dfbf4..81b8be3 100644 --- a/docs/merkle/sidebar-items.js +++ b/docs/merkle/sidebar-items.js @@ -1 +1 @@ -initSidebarItems({"enum":[["Tree","Binary Tree where leaves hold a stand-alone value."]],"struct":[["MerkleTree","The Merkle tree"]],"trait":[["Hashable","By definition, data in the Merkle Tree must implement Hashable"],["MerkleDigest","Extends the standard `crypto::digest::Digest` to play nicely with our Merkle Tree"]]}); \ No newline at end of file +initSidebarItems({"enum":[["Positioned","Tags a value so that we know from in branch (if any) it was found."]],"struct":[["MerkleTree","A Merkle tree is a binary tree, with values of type `T` at the leafs, and where every node holds the hash of the concatenation of the hashes of its children nodes."],["Proof","An inclusion proof represent the fact that `value` is a member of a `MerkleTree` with root hash `root_hash`, and hash function `digest`. A proof is a linked-list of `ProofBlock`s. TODO: Represent a proof as a vector of ProofBlock instead of a linked-list?"],["ProofBlock","A `ProofBlock` is a linked-list holding the hash of the node, the hash of its sibling node, and the rest of the inclusion proof."]],"trait":[["MerkleDigest","The sole purpose of this trait is to extend the standard `crypto::digest::Digest` with a couple utility functions."]]}); \ No newline at end of file diff --git a/docs/merkle/struct.MerkleTree.html b/docs/merkle/struct.MerkleTree.html index 06645fd..849193f 100644 --- a/docs/merkle/struct.MerkleTree.html +++ b/docs/merkle/struct.MerkleTree.html @@ -47,19 +47,39 @@ [] - [src] -
pub struct MerkleTree<D, T> {
+               [src]
+
pub struct MerkleTree<D, T> {
+    pub digest: D,
+    pub tree: Tree<T>,
     pub height: usize,
     pub count: usize,
-    // some fields omitted
-}

The Merkle tree

-

Fields

height: usize - count: usize -

Methods

impl<D, T> MerkleTree<D, T> where D: Digest, T: Hashable
[src]

-

fn from_vec(digest: D, values: Vec<T>) -> Self

-

Constructs a Merkle Tree from a vector of data blocks.

-

fn root_hash(&self) -> &Vec<u8>

-

Returns the tree's root hash.

+}

A Merkle tree is a binary tree, with values of type T at the leafs, +and where every node holds the hash of the concatenation of the hashes of +its children nodes.

+

Fields

+

The hashing function used by this Merkle tree

+
+

The inner binary tree

+
+

The height of the tree

+
+

The number of leaf nodes in the tree

+

Methods

impl<D, T> MerkleTree<D, T> where D: Digest + Clone, T: Into<Vec<u8>> + Clone
[src]

+

+

Constructs a Merkle Tree from a vector of data blocks

+

+

Returns the tree's root hash

+

+

Generate an inclusion proof for the given value. +None is returned if the given value is not found in the tree.

@@ -116,11 +136,9 @@ - \ No newline at end of file diff --git a/docs/merkle/struct.Proof.html b/docs/merkle/struct.Proof.html new file mode 100644 index 0000000..553d1a6 --- /dev/null +++ b/docs/merkle/struct.Proof.html @@ -0,0 +1,136 @@ + + + + + + + + + + merkle::Proof - Rust + + + + + + + + + + + + + + + + + +
+

Struct merkle::Proof + + [] + + [src]

+
pub struct Proof<D, T> {
+    pub digest: D,
+    pub root_hash: Vec<u8>,
+    pub block: ProofBlock,
+    pub value: T,
+}

An inclusion proof represent the fact that value is a member of a MerkleTree +with root hash root_hash, and hash function digest. +A proof is a linked-list of ProofBlocks. +TODO: Represent a proof as a vector of ProofBlock instead of a linked-list?

+

Fields

+ + + +

Methods

impl<D, T> Proof<D, T> where D: Digest + Clone, T: Into<Vec<u8>> + Clone
[src]

+

+

+
+ + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/merkle/struct.ProofBlock.html b/docs/merkle/struct.ProofBlock.html new file mode 100644 index 0000000..eaf5b2e --- /dev/null +++ b/docs/merkle/struct.ProofBlock.html @@ -0,0 +1,130 @@ + + + + + + + + + + merkle::ProofBlock - Rust + + + + + + + + + + + + + + + + + +
+

Struct merkle::ProofBlock + + [] + + [src]

+
pub struct ProofBlock {
+    pub node_hash: Vec<u8>,
+    pub sibling_hash: Positioned<Vec<u8>>,
+    pub sub_proof: Option<Box<ProofBlock>>,
+}

A ProofBlock is a linked-list holding the hash of the node, the hash of its sibling node, +and the rest of the inclusion proof.

+

Fields

+ + +

Methods

impl ProofBlock
[src]

+

+

Attempt to generate a proof that the hash needle is a member of the given tree.

+
+ + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/merkle/trait.Hashable.html b/docs/merkle/trait.Hashable.html deleted file mode 100644 index cbb4961..0000000 --- a/docs/merkle/trait.Hashable.html +++ /dev/null @@ -1,128 +0,0 @@ - - - - - - - - - - merkle::Hashable - Rust - - - - - - - - - - - - - - - - - -
-

Trait merkle::Hashable - - [] - - [src]

-
pub trait Hashable {
-    fn to_bytes(&self) -> Vec<u8>;
-}

By definition, data in the Merkle Tree must implement Hashable

-
-

Required Methods

-
-

fn to_bytes(&self) -> Vec<u8>

-

Implementors

-
- - - - - - - - - - - - - - - \ No newline at end of file diff --git a/docs/merkle/trait.MerkleDigest.html b/docs/merkle/trait.MerkleDigest.html index 7ddceb8..4c6e3cf 100644 --- a/docs/merkle/trait.MerkleDigest.html +++ b/docs/merkle/trait.MerkleDigest.html @@ -47,15 +47,18 @@ [] - [src] + [src]
pub trait MerkleDigest {
     fn hash_bytes(&mut self, bytes: &Vec<u8>) -> Vec<u8>;
     fn combine_hashes(&mut self, left: &Vec<u8>, right: &Vec<u8>) -> Vec<u8>;
-}

Extends the standard crypto::digest::Digest to play nicely with our Merkle Tree

+}

The sole purpose of this trait is to extend the standard +crypto::digest::Digest with a couple utility functions.

Required Methods

-

fn hash_bytes(&mut self, bytes: &Vec<u8>) -> Vec<u8>

fn combine_hashes(&mut self, left: &Vec<u8>, right: &Vec<u8>) -> Vec<u8>

+

Compute the hash the given byte array

+

Compute the hash of the concatenation of left and right

+

Implementors