Class: MSSMT::ComputedNode

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

Overview

Node within a MS-SMT that has already had its node_hash and sum computed, i.e., its preimage is not available.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node_hash, sum) ⇒ ComputedNode

Constructor

Parameters:

  • node_hash (String)

    node hash with binary format.

  • sum (Integer)

Raises:



12
13
14
15
16
17
18
# File 'lib/mssmt/computed_node.rb', line 12

def initialize(node_hash, sum)
  @node_hash = node_hash
  if sum > Tree::MAX_SUM_VALUE
    raise OverflowError, "sum: #{sum} is overflow"
  end
  @sum = sum
end

Instance Attribute Details

#node_hashObject (readonly)

Returns the value of attribute node_hash.



6
7
8
# File 'lib/mssmt/computed_node.rb', line 6

def node_hash
  @node_hash
end

#sumObject (readonly)

Returns the value of attribute sum.



6
7
8
# File 'lib/mssmt/computed_node.rb', line 6

def sum
  @sum
end

Instance Method Details

#==(other) ⇒ Object



20
21
22
23
# File 'lib/mssmt/computed_node.rb', line 20

def ==(other)
  return false unless [BranchNode, ComputedNode].include?(other.class)
  node_hash == other.node_hash && sum == other.sum
end