Module: BSV::Wallet::Serializer::VerifyHmac::Args
- Defined in:
- lib/bsv/wallet/serializer/verify_hmac.rb
Overview
Args wire layout:
[key-related params]
[32 bytes: HMAC]
[VarInt data_len][data bytes]
[optional_bool seek_permission]
Class Method Summary collapse
Class Method Details
.deserialize(bytes) ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/bsv/wallet/serializer/verify_hmac.rb', line 41 def deserialize(bytes) r = BSV::Wallet::Wire::Reader.new(bytes) params = Common.(r) hmac = r.read_bytes(HMAC_SIZE) data_len = r.read_varint data = r.read_bytes(data_len) = r.read_optional_bool params.merge(hmac: hmac, data: data, seek_permission: ) end |
.serialize(args) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/bsv/wallet/serializer/verify_hmac.rb', line 20 def serialize(args) hmac = Common.to_binary(args[:hmac]) raise BSV::Wallet::InvalidParameterError.new('hmac', "exactly #{HMAC_SIZE} bytes") unless hmac.bytesize == HMAC_SIZE w = BSV::Wallet::Wire::Writer.new Common.( w, protocol_id: args[:protocol_id], key_id: args[:key_id], counterparty: args[:counterparty], privileged: args[:privileged], privileged_reason: args[:privileged_reason] ) w.write_bytes(hmac) data = Common.to_binary(args[:data]) w.write_varint(data.bytesize) w.write_bytes(data) w.write_optional_bool(args[:seek_permission]) w.buf end |