Module: BSV::Wallet::Serializer::CreateHmac::Result

Defined in:
lib/bsv/wallet/serializer/create_hmac.rb

Overview

Result wire layout:

[32 bytes: HMAC-SHA-256]

Class Method Summary collapse

Class Method Details

.deserialize(bytes) ⇒ Object

Raises:

  • (ArgumentError)


58
59
60
61
62
# File 'lib/bsv/wallet/serializer/create_hmac.rb', line 58

def deserialize(bytes)
  raise ArgumentError, "HMAC result too short: #{bytes.bytesize}" if bytes.bytesize < HMAC_SIZE

  { hmac: bytes.byteslice(0, HMAC_SIZE) }
end

.serialize(result) ⇒ Object

Raises:

  • (ArgumentError)


51
52
53
54
55
56
# File 'lib/bsv/wallet/serializer/create_hmac.rb', line 51

def serialize(result)
  hmac = Common.to_binary(result[:hmac])
  raise ArgumentError, "HMAC must be #{HMAC_SIZE} bytes, got #{hmac.bytesize}" unless hmac.bytesize == HMAC_SIZE

  hmac
end