diff --git a/doc/.build b/doc/.build new file mode 100644 index 0000000..d03fd00 --- /dev/null +++ b/doc/.build @@ -0,0 +1,17 @@ +dist/search_items-2371477b19.js +dist/html-de2388dc2f8074b0a4db.css +dist/html-de2388dc2f8074b0a4db.js +dist/html/fonts/icomoon.eot +dist/html/fonts/icomoon.svg +dist/html/fonts/icomoon.ttf +dist/html/fonts/icomoon.woff +dist/sidebar_items-cb3c6640da.js +api-reference.html +search.html +404.html +MerkleTree.html +MerkleTree.Crypto.html +MerkleTree.Node.html +MerkleTree.Proof.html +MerkleTree.ArgumentError.html +index.html diff --git a/doc/404.html b/doc/404.html index 8225943..6a92e39 100644 --- a/doc/404.html +++ b/doc/404.html @@ -1,91 +1,106 @@ - + - - 404 – merkle_tree v1.6.1 - - - - - + + + 404 — merkle_tree v2.0.0 + + + + - +
- +
-

Page not found

Sorry, but the page you were trying to get to, does not exist. You -may want to try searching this site using the sidebar or using our -API Reference page to find what -you were looking for.

+may want to try searching this site using the sidebar + or using our API Reference page +to find what you were looking for.

- - diff --git a/doc/MerkleTree.ArgumentError.html b/doc/MerkleTree.ArgumentError.html index ae75d60..6dcd89d 100644 --- a/doc/MerkleTree.ArgumentError.html +++ b/doc/MerkleTree.ArgumentError.html @@ -1,178 +1,106 @@ - - + + - - MerkleTree.ArgumentError – merkle_tree v1.6.1 - - - - - + + + MerkleTree.ArgumentError — merkle_tree v2.0.0 + + + + + +
-
- +
-

- merkle_tree v1.6.1 - MerkleTree.ArgumentError - - exception - - -

- - - - -
-

- - - - Summary -

- - - -
-

- Functions -

-
- - -
- - -
- - - - - + merkle_tree v2.0.0 +MerkleTree.ArgumentError exception -
- - - - - -
-

- - - - Functions -

-
-
- - - - exception(msg) - - -
- -
- -
-
-
-
- - - - message(exception) - - -
- -
- -
-
-
- - - -
+

Built using - ExDoc (v0.12.0), + ExDoc (v0.21.2), designed by - Friedel Ziegelmayer. - + Friedel Ziegelmayer. + +

+

+ + + +

-
- - diff --git a/doc/MerkleTree.Crypto.html b/doc/MerkleTree.Crypto.html index 326b44d..810c568 100644 --- a/doc/MerkleTree.Crypto.html +++ b/doc/MerkleTree.Crypto.html @@ -1,235 +1,206 @@ - - + + - - MerkleTree.Crypto – merkle_tree v1.6.1 - - - - - + + + MerkleTree.Crypto — merkle_tree v2.0.0 + + + + + +
-
- +
-

- merkle_tree v1.6.1 - MerkleTree.Crypto - - -

+ merkle_tree v2.0.0 +MerkleTree.Crypto - -
-

This module defines some cryptographic hash functions used to hash block - contents.

+
+

This module defines some cryptographic hash functions used to hash block + contents.

- -

- + + Link to this section Summary

-

Types

-
+ -
- - -
- - -
+

- + + Link to this section - Types -

+Types
-
-
algorithm ::
-  :md5 |
-  :sha |
-  :sha224 |
-  :sha256 |
-  :sha384 |
-  :sha512
- -
- +
+
+ + + Link to this type + +

algorithm()

+
+
algorithm() :: :md5 | :sha | :sha224 | :sha256 | :sha384 | :sha512
+
+
+
+
+
- - -

- + + Link to this section - Functions -

-
+Functions +
+
- + + Link to this function - hash(data, algorithm) - - -
- -
-

Specs

-
- -
hash(String.t, algorithm) :: String.t
- +

hash(data, algorithm)

+
+
hash(String.t(), algorithm()) :: String.t()
-
- +
-
-
-
+
+
- + + Link to this function - sha256(data) - - -
- -
-

Specs

-
- -
sha256(String.t) :: String.t
- +

sha256(data)

+
+
sha256(String.t()) :: String.t()
-
- +
-
-
- +
+
- - - - - -
- - diff --git a/doc/MerkleTree.Node.html b/doc/MerkleTree.Node.html index 1b1c1d1..0837cb6 100644 --- a/doc/MerkleTree.Node.html +++ b/doc/MerkleTree.Node.html @@ -1,163 +1,175 @@ - - + + - - MerkleTree.Node – merkle_tree v1.6.1 - - - - - + + + MerkleTree.Node — merkle_tree v2.0.0 + + + + + +
-
- +
-

- merkle_tree v1.6.1 - MerkleTree.Node - - -

+ merkle_tree v2.0.0 +MerkleTree.Node - -
-

This module implements a tree node abstraction.

+
+

This module implements a tree node abstraction.

- -

- + + Link to this section Summary

-

Types

-
+
-
t()
-
-
- - - - - - - -
- - -
+

- + + Link to this section - Types -

+Types
-
-
hash :: binary | String.t
- -
-
-
t :: %MerkleTree.Node{children: [MerkleTree.Node.t], height: non_neg_integer, value: hash}
- -
- +
+
+ + + Link to this type + +

hash()

+
+
hash() :: binary() | String.t()
+
+
+
+
+
+
+
+ + + Link to this type + +

t()

+
+
t() :: %MerkleTree.Node{
+  children: [t()],
+  height: non_neg_integer(),
+  value: hash()
+}
+
+
+
+
+
- - - - - - - -
+

Built using - ExDoc (v0.12.0), + ExDoc (v0.21.2), designed by - Friedel Ziegelmayer. - + Friedel Ziegelmayer. + +

+

+ + + +

-
- - diff --git a/doc/MerkleTree.Proof.html b/doc/MerkleTree.Proof.html index bdaea4d..484b30a 100644 --- a/doc/MerkleTree.Proof.html +++ b/doc/MerkleTree.Proof.html @@ -1,244 +1,221 @@ - - + + - - MerkleTree.Proof – merkle_tree v1.6.1 - - - - - + + + MerkleTree.Proof — merkle_tree v2.0.0 + + + + + +
-
- +
-

- merkle_tree v1.6.1 - MerkleTree.Proof - - -

- - -
-

Generate and verify merkle proofs

-
## Usage Example
-iex> proof = MerkleTree.new(~w/a b c d/) |>
-...> MerkleTree.Proof.prove(1)
-%MerkleTree.Proof{hash_function: &MerkleTree.Crypto.sha256/1,
- hashes: ["d3a0f1c792ccf7f1708d5422696263e35755a86917ea76ef9242bd4a8cf4891a",
-  "ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb"]}
-iex> MerkleTree.Proof.proven?({"b", 1}, "58c89d709329eb37285837b042ab6ff72c7c8f74de0446b091b6a0131c102cfd", proof)
-true
- + merkle_tree v2.0.0 +MerkleTree.Proof + + +
+

Generate and verify merkle proofs

+
## Usage Example
+iex> proof = MerkleTree.new(~w/a b c d/) |>
+...> MerkleTree.Proof.prove(1)
+["40e2511a6323177e537acb2e90886e0da1f84656fd6334b89f60d742a3967f09",
+  "022a6979e6dab7aa5ae4c3e5e45f7e977112a7e63593820dbec1ec738a24f93c"]
+iex> MerkleTree.Proof.proven?({"b", 1}, "9dc1674ae1ee61c90ba50b6261e8f9a47f7ea07d92612158edfe3c2a37c6d74c", &MerkleTree.Crypto.sha256/1, proof)
+true
- -

- + + Link to this section Summary

-

Types

-
+
-
-
- - -

Functions

-
+
- -

Generates proof for a block at a specific index

-
- +

Generates proof for a block at a specific index

- -

Verifies proof for a block at a specific index

-
- +

Verifies proof for a block at a specific index

-
- - - - - -
- - -
+

- + + Link to this section - Types -

+Types
-
-
t :: %MerkleTree.Proof{hash_function: MerkleTree.hash_function | nil, hashes: [String.t, ...]}
- -
- +
+
+ + + Link to this type + +

proof_t()

+
+
proof_t() :: [String.t()]
+
+
+
+
+
- - -

- + + Link to this section - Functions -

-
+Functions +
+
- + + Link to this function - prove(tree, index) - - -
- -
-

Specs

-
- -
prove(MerkleTree.t | MerkleTree.Node.t, non_neg_integer) :: t
- +

prove(root, index)

+ -
- +
-

Generates proof for a block at a specific index

- +

Generates proof for a block at a specific index

-
-
+
+
- + + Link to this function - proven?(arg, root_hash, hash_function, proof) - - -
- -
-

Specs

-
- -
proven?({String.t, non_neg_integer}, String.t, MerkleTree.hash_function, t) :: boolean
- +

proven?(arg, root_hash, hash_function, proof)

+
+
proven?(
+  {String.t(), non_neg_integer()},
+  String.t(),
+  MerkleTree.hash_function(),
+  proof_t()
+) :: boolean()
-
- +
-

Verifies proof for a block at a specific index

- +

Verifies proof for a block at a specific index

-
- +
+
- - - - - -
- - diff --git a/doc/MerkleTree.html b/doc/MerkleTree.html index aea8b2e..567c8c0 100644 --- a/doc/MerkleTree.html +++ b/doc/MerkleTree.html @@ -1,337 +1,353 @@ - - + + - - MerkleTree – merkle_tree v1.6.1 - - - - - + + + MerkleTree — merkle_tree v2.0.0 + + + + + +
-
- +
-

- merkle_tree v1.6.1 - MerkleTree - - -

+ merkle_tree v2.0.0 +MerkleTree - -
-

A hash tree or Merkle tree is a tree in which every non-leaf node is labelled + +

+

A hash tree or Merkle tree is a tree in which every non-leaf node is labelled with the hash of the labels or values (in case of leaves) of its child nodes. Hash trees are useful because they allow efficient and secure verification of the contents of large data structures.

-
## Usage Example
-
-iex> MerkleTree.new ['a', 'b', 'c', 'd']
-%MerkleTree{blocks: ['a', 'b', 'c', 'd'], hash_function: &MerkleTree.Crypto.sha256/1,
-      root: %MerkleTree.Node{children: [%MerkleTree.Node{children: [%MerkleTree.Node{children: [], height: 0,
-           value: "ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb"},
-          %MerkleTree.Node{children: [], height: 0, value: "3e23e8160039594a33894f6564e1b1348bbd7a0088d42c4acb73eeaed59c009d"}], height: 1,
-         value: "62af5c3cb8da3e4f25061e829ebeea5c7513c54949115b1acc225930a90154da"},
-        %MerkleTree.Node{children: [%MerkleTree.Node{children: [], height: 0,
-           value: "2e7d2c03a9507ae265ecf5b5356885a53393a2029d241394997265a1a25aefc6"},
-          %MerkleTree.Node{children: [], height: 0, value: "18ac3e7343f016890c510e93f935261169d9e3f565436429830faf0934f4f8e4"}], height: 1,
-         value: "d3a0f1c792ccf7f1708d5422696263e35755a86917ea76ef9242bd4a8cf4891a"}], height: 2,
-       value: "58c89d709329eb37285837b042ab6ff72c7c8f74de0446b091b6a0131c102cfd"}}
- +
## Usage Example
+

iex> MerkleTree.new ["a", "b", "c", "d"] + %MerkleTree{

+
blocks: ["a", "b", "c", "d"],
+hash_function: &MerkleTree.Crypto.sha256/1,
+root: %MerkleTree.Node{
+  children: [
+    %MerkleTree.Node{
+      children: [
+        %MerkleTree.Node{
+          children: [],
+          height: 0,
+          value: "022a6979e6dab7aa5ae4c3e5e45f7e977112a7e63593820dbec1ec738a24f93c"
+        },
+        %MerkleTree.Node{
+          children: [],
+          height: 0,
+          value: "57eb35615d47f34ec714cacdf5fd74608a5e8e102724e80b24b287c0c27b6a31"
+        }
+      ],
+      height: 1,
+      value: "4c64254e6636add7f281ff49278beceb26378bd0021d1809974994e6e233ec35"
+    },
+    %MerkleTree.Node{
+      children: [
+        %MerkleTree.Node{
+          children: [],
+          height: 0,
+          value: "597fcb31282d34654c200d3418fca5705c648ebf326ec73d8ddef11841f876d8"
+        },
+        %MerkleTree.Node{
+          children: [],
+          height: 0,
+          value: "d070dc5b8da9aea7dc0f5ad4c29d89965200059c9a0ceca3abd5da2492dcb71d"
+        }
+      ],
+      height: 1,
+      value: "40e2511a6323177e537acb2e90886e0da1f84656fd6334b89f60d742a3967f09"
+    }
+  ],
+  height: 2,
+  value: "9dc1674ae1ee61c90ba50b6261e8f9a47f7ea07d92612158edfe3c2a37c6d74c"
+}
+

}

- -

- + + Link to this section Summary

-

Types

- - - -

Functions

-
+
- -

Builds a root MerkleTree.Node structure of a merkle tree

-
- +

Builds a root MerkleTree.Node structure of a merkle tree

- -

Calculates the root of the merkle tree without building the entire tree explicitly,

-
- +

Calculates the root of the merkle tree without building the entire tree explicitly,

- -

Creates a new merkle tree, given a blocks and hash function or opts. - available options:

-
:hash_function - used hash in mercle tree default :sha256 from :cryto
-:hash_leaves - flag says whether the leaves should be hashed, default true
-:height - allows to construct tree of provided height,
-    empty leaves data will be taken from `:default_data_block` parameter
-:default_data_block - this data will be used to supply empty
-    leaves in case where there isn't enough blocks provided
-

Check out MerkleTree.Crypto for other available cryptographic hashes. -Alternatively, you can supply your own hash function that has the spec -(String.t -> String.t)

-
- +

Creates a new merkle tree, given a blocks and hash function or opts. + available options

-
- - - - - -
- - -
+

- + + Link to this section - Types -

+Types
-
-
blocks :: [String.t, ...]
- -
- - -
-
t :: %MerkleTree{blocks: blocks, hash_function: hash_function, root: root}
- -
- +
+
+ + + Link to this type + +

blocks()

+
+
blocks() :: [String.t(), ...]
+
+
+
+
+
+
+
+ + + Link to this type + +

hash_function()

+
+
hash_function() :: (String.t() -> String.t())
+
+
+
+
+
+
+
+ + + Link to this type + +

root()

+
+
root() :: MerkleTree.Node.t()
+
+
+
+
+
+
+
+ + + Link to this type + +

t()

+
+
t() :: %MerkleTree{
+  blocks: blocks(),
+  hash_function: hash_function(),
+  root: root()
+}
+
+
+
+
+
- - -

- + + Link to this section - Functions -

-
+Functions +
+
+
- + + Link to this function - build(blocks, hash_function_or_opts \\ []) - - -
- -
-

Specs

-
- -
build(blocks, hash_function | Keyword.t) :: root
- +

build(blocks, hash_function_or_opts \\ [])

+
+
build(blocks(), hash_function() | Keyword.t()) :: root()
-
- +
-

Builds a root MerkleTree.Node structure of a merkle tree

+

Builds a root MerkleTree.Node structure of a merkle tree

See new/2 for a rundown of options

-
-
-
+
+
+
- + + Link to this function - fast_root(blocks, opts \\ []) - - -
- -
-

Specs

-
- -
fast_root(blocks, Keyword.t) :: MerkleTree.Node.hash
- +

fast_root(blocks, opts \\ [])

+
+
fast_root(blocks(), Keyword.t()) :: MerkleTree.Node.hash()
-
- +
-

Calculates the root of the merkle tree without building the entire tree explicitly,

+

Calculates the root of the merkle tree without building the entire tree explicitly,

See new/2 for a rundown of options

-
-
-
+
+
+
- + + Link to this function - new(blocks, hash_function_or_opts \\ []) - - -
- -
-

Specs

-
- -
new(blocks, hash_function | Keyword.t) :: t
- +

new(blocks, hash_function_or_opts \\ [])

+
+
new(blocks(), hash_function() | Keyword.t()) :: t()
-
- +
-

Creates a new merkle tree, given a blocks and hash function or opts. +

Creates a new merkle tree, given a blocks and hash function or opts. available options:

-
:hash_function - used hash in mercle tree default :sha256 from :cryto
-:hash_leaves - flag says whether the leaves should be hashed, default true
-:height - allows to construct tree of provided height,
-    empty leaves data will be taken from `:default_data_block` parameter
-:default_data_block - this data will be used to supply empty
-    leaves in case where there isn't enough blocks provided
+
:hash_function - used hash in mercle tree default :sha256 from :cryto
+:height - allows to construct tree of provided height,
+    empty leaves data will be taken from `:default_data_block` parameter
+:default_data_block - this data will be used to supply empty
+    leaves in case where there isn't enough blocks provided

Check out MerkleTree.Crypto for other available cryptographic hashes. Alternatively, you can supply your own hash function that has the spec (String.t -> String.t).

-
-
- + +
- - - - - -