Class: MSSMT::Proof
- Inherits:
-
Object
- Object
- MSSMT::Proof
- Defined in:
- lib/mssmt/proof.rb
Overview
Merkle proof for MS-SMT.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#nodes ⇒ Object
readonly
Returns the value of attribute nodes.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#compress ⇒ MSSMT::CompressedProof
Compresses a merkle proof by replacing its empty nodes with a bit vector.
-
#initialize(nodes) ⇒ Proof
constructor
Constructor its parents to arrive at the root of the MS-SMT.
Constructor Details
#initialize(nodes) ⇒ Proof
Constructor its parents to arrive at the root of the MS-SMT.
10 11 12 |
# File 'lib/mssmt/proof.rb', line 10 def initialize(nodes) @nodes = nodes end |
Instance Attribute Details
#nodes ⇒ Object (readonly)
Returns the value of attribute nodes.
5 6 7 |
# File 'lib/mssmt/proof.rb', line 5 def nodes @nodes end |
Instance Method Details
#==(other) ⇒ Object
29 30 31 32 |
# File 'lib/mssmt/proof.rb', line 29 def ==(other) return false unless other.is_a?(Proof) nodes == other.nodes end |
#compress ⇒ MSSMT::CompressedProof
Compresses a merkle proof by replacing its empty nodes with a bit vector.
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/mssmt/proof.rb', line 16 def compress bits = Array.new(nodes.length, false) compact_nodes = [] nodes.each.each_with_index do |node, i| if node.node_hash == Tree.empty_tree[Tree::MAX_LEVEL - i].node_hash bits[i] = true else compact_nodes << node end end CompressedProof.new(compact_nodes, bits) end |