Class: Merkle::HashTree
- Inherits:
-
Object
- Object
- Merkle::HashTree
- Defined in:
- lib/hash_tree.rb
Constant Summary collapse
Instance Attribute Summary collapse
-
#algorithm ⇒ Object
readonly
Returns the value of attribute algorithm.
-
#audit_proof ⇒ Object
readonly
Returns the value of attribute audit_proof.
-
#audit_proof_head ⇒ Object
readonly
Returns the value of attribute audit_proof_head.
-
#consistency_proof ⇒ Object
readonly
Returns the value of attribute consistency_proof.
-
#consistency_proof_head ⇒ Object
readonly
Returns the value of attribute consistency_proof_head.
-
#digest ⇒ Object
readonly
Returns the value of attribute digest.
-
#hashed_data ⇒ Object
readonly
Returns the value of attribute hashed_data.
-
#head ⇒ Object
readonly
Returns the value of attribute head.
-
#incoming_data ⇒ Object
readonly
Returns the value of attribute incoming_data.
Instance Method Summary collapse
- #audit_proof_build(index) ⇒ Object
- #audit_proof_build_head(audit_proof_path, element) ⇒ Object
- #consistency_proof_build(index) ⇒ Object
- #consistency_proof_build_head(consistency_proof_path) ⇒ Object
- #head_build ⇒ Object
-
#initialize(incoming_data, digest = nil) ⇒ HashTree
constructor
A new instance of HashTree.
Constructor Details
#initialize(incoming_data, digest = nil) ⇒ HashTree
Returns a new instance of HashTree.
9 10 11 12 13 14 |
# File 'lib/hash_tree.rb', line 9 def initialize(incoming_data, digest = nil) @algorithm = ALGORITHM_CLASS @digest = digest @incoming_data = incoming_data @hashed_data = incoming_data_to_hashes end |
Instance Attribute Details
#algorithm ⇒ Object (readonly)
Returns the value of attribute algorithm.
16 17 18 |
# File 'lib/hash_tree.rb', line 16 def algorithm @algorithm end |
#audit_proof ⇒ Object (readonly)
Returns the value of attribute audit_proof.
16 17 18 |
# File 'lib/hash_tree.rb', line 16 def audit_proof @audit_proof end |
#audit_proof_head ⇒ Object (readonly)
Returns the value of attribute audit_proof_head.
16 17 18 |
# File 'lib/hash_tree.rb', line 16 def audit_proof_head @audit_proof_head end |
#consistency_proof ⇒ Object (readonly)
Returns the value of attribute consistency_proof.
16 17 18 |
# File 'lib/hash_tree.rb', line 16 def consistency_proof @consistency_proof end |
#consistency_proof_head ⇒ Object (readonly)
Returns the value of attribute consistency_proof_head.
16 17 18 |
# File 'lib/hash_tree.rb', line 16 def consistency_proof_head @consistency_proof_head end |
#digest ⇒ Object (readonly)
Returns the value of attribute digest.
16 17 18 |
# File 'lib/hash_tree.rb', line 16 def digest @digest end |
#hashed_data ⇒ Object (readonly)
Returns the value of attribute hashed_data.
16 17 18 |
# File 'lib/hash_tree.rb', line 16 def hashed_data @hashed_data end |
#head ⇒ Object (readonly)
Returns the value of attribute head.
16 17 18 |
# File 'lib/hash_tree.rb', line 16 def head @head end |
#incoming_data ⇒ Object (readonly)
Returns the value of attribute incoming_data.
16 17 18 |
# File 'lib/hash_tree.rb', line 16 def incoming_data @incoming_data end |
Instance Method Details
#audit_proof_build(index) ⇒ Object
24 25 26 27 |
# File 'lib/hash_tree.rb', line 24 def audit_proof_build(index) @audit_proof = algorithm.audit_proof(hashed_data, index, digest) end |
#audit_proof_build_head(audit_proof_path, element) ⇒ Object
29 30 31 32 |
# File 'lib/hash_tree.rb', line 29 def audit_proof_build_head(audit_proof_path, element) @audit_proof_head = algorithm.audit_proof_build_head(audit_proof_path, element, digest) end |
#consistency_proof_build(index) ⇒ Object
34 35 36 37 |
# File 'lib/hash_tree.rb', line 34 def consistency_proof_build(index) @consistency_proof = algorithm.consistency_proof(hashed_data, index, digest) end |
#consistency_proof_build_head(consistency_proof_path) ⇒ Object
39 40 41 42 |
# File 'lib/hash_tree.rb', line 39 def consistency_proof_build_head(consistency_proof_path) @consistency_proof_head = algorithm.consistency_proof_build_head(consistency_proof_path, digest) end |
#head_build ⇒ Object
19 20 21 22 |
# File 'lib/hash_tree.rb', line 19 def head_build @head = algorithm.merkle_tree(hashed_data, digest) end |