Class: WOTS::Signature

Inherits:
Object
  • Object
show all
Includes:
Util
Defined in:
lib/wots/signature.rb

Overview

WOTS+ signature.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Util

#bin_to_hex, #hex_string?, #hex_to_bin

Constructor Details

#initialize(param, sigs) ⇒ Signature

Returns a new instance of Signature.

Raises:

  • (ArgumentError)


8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/wots/signature.rb', line 8

def initialize(param, sigs)
  raise ArgumentError, "param must be WOTS::Param." unless param.is_a?(WOTS::Param)
  raise ArgumentError, "sigs must be Array." unless sigs.is_a?(Array)
  raise ArgumentError, "The length of sigs must be the same as param#len." unless sigs.length == param.len
  sigs.each do |sig|
    raise ArgumentError, "sig must be hex string." unless hex_string?(sig)
    raise ArgumentError, "sig must be #{param.n} bytes." unless hex_to_bin(sig).bytesize == param.n
  end

  @param = param
  @sigs = sigs
end

Instance Attribute Details

#paramObject (readonly)

Returns the value of attribute param.



6
7
8
# File 'lib/wots/signature.rb', line 6

def param
  @param
end

#sigsObject (readonly)

Returns the value of attribute sigs.



6
7
8
# File 'lib/wots/signature.rb', line 6

def sigs
  @sigs
end