Module: BSV::Wallet::Serializer::GetPublicKey::Result
- Defined in:
- lib/bsv/wallet/serializer/get_public_key.rb
Overview
Result wire layout:
[33 bytes: compressed public key]
The wire bytes are 33-byte compressed binary by the BRC-103 protocol, but the Ruby return shape is hex per the BRC-100 PubKeyHex contract (ADR-001 — pubkeys are the documented hex exception to binary-internal).
Class Method Summary collapse
Class Method Details
.deserialize(bytes) ⇒ Object
81 82 83 84 85 |
# File 'lib/bsv/wallet/serializer/get_public_key.rb', line 81 def deserialize(bytes) raise ArgumentError, "public key too short: #{bytes.bytesize}" if bytes.bytesize < PUBKEY_SIZE { public_key: bytes.byteslice(0, PUBKEY_SIZE).unpack1('H*') } end |
.serialize(result) ⇒ Object
76 77 78 79 |
# File 'lib/bsv/wallet/serializer/get_public_key.rb', line 76 def serialize(result) pubkey = result[:public_key] || ''.b pubkey.bytesize == PUBKEY_SIZE ? pubkey.b : [pubkey.to_s].pack('H*') end |