Class: WOTS::Address

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

Overview

WOTS+ hash function address. Each field is packed into a fixed width big endian integer by #to_payload, so a value outside its range would silently wrap and collide with another address, breaking the domain separation the chaining function relies on.

Constant Summary collapse

UINT32_MAX =
0xFFFFFFFF
UINT64_MAX =
0xFFFFFFFFFFFFFFFF

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(layer_addr: 0, tree_addr: 0, ots_addr: 0, chain_addr: 0, hash_addr: 0, key_and_mask: 0) ⇒ Address

Returns a new instance of Address.



17
18
19
20
21
22
23
24
# File 'lib/wots/address.rb', line 17

def initialize(layer_addr: 0, tree_addr: 0, ots_addr: 0, chain_addr: 0, hash_addr: 0, key_and_mask: 0)
  self.layer_addr = layer_addr
  self.tree_addr = tree_addr
  self.ots_addr = ots_addr
  self.chain_addr = chain_addr
  self.hash_addr = hash_addr
  self.key_and_mask = key_and_mask
end

Instance Attribute Details

#chain_addrObject

Returns the value of attribute chain_addr.



13
14
15
# File 'lib/wots/address.rb', line 13

def chain_addr
  @chain_addr
end

#hash_addrObject

Returns the value of attribute hash_addr.



14
15
16
# File 'lib/wots/address.rb', line 14

def hash_addr
  @hash_addr
end

#key_and_maskObject

0: key generation, 1: bitmask generation



15
16
17
# File 'lib/wots/address.rb', line 15

def key_and_mask
  @key_and_mask
end

#layer_addrObject

Returns the value of attribute layer_addr.



10
11
12
# File 'lib/wots/address.rb', line 10

def layer_addr
  @layer_addr
end

#ots_addrObject

Returns the value of attribute ots_addr.



12
13
14
# File 'lib/wots/address.rb', line 12

def ots_addr
  @ots_addr
end

#tree_addrObject

Returns the value of attribute tree_addr.



11
12
13
# File 'lib/wots/address.rb', line 11

def tree_addr
  @tree_addr
end

Instance Method Details

#to_payloadObject



54
55
56
# File 'lib/wots/address.rb', line 54

def to_payload
  [layer_addr, tree_addr, type, ots_addr, chain_addr, hash_addr, key_and_mask].pack('NQ>NNNNN')
end

#typeObject



50
51
52
# File 'lib/wots/address.rb', line 50

def type
  0
end