Class: Merkle::HashTree

Inherits:
Object
  • Object
show all
Defined in:
lib/hash_tree.rb

Constant Summary collapse

ALGORITHM_CLASS =
Merkle::Algorithm

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#algorithmObject (readonly)

Returns the value of attribute algorithm.



16
17
18
# File 'lib/hash_tree.rb', line 16

def algorithm
  @algorithm
end

#audit_proofObject (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_headObject (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_proofObject (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_headObject (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

#digestObject (readonly)

Returns the value of attribute digest.



16
17
18
# File 'lib/hash_tree.rb', line 16

def digest
  @digest
end

#hashed_dataObject (readonly)

Returns the value of attribute hashed_data.



16
17
18
# File 'lib/hash_tree.rb', line 16

def hashed_data
  @hashed_data
end

#headObject (readonly)

Returns the value of attribute head.



16
17
18
# File 'lib/hash_tree.rb', line 16

def head
  @head
end

#incoming_dataObject (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_buildObject



19
20
21
22
# File 'lib/hash_tree.rb', line 19

def head_build
  @head =
    algorithm.merkle_tree(hashed_data, digest)
end