Module: BSV::Wallet::Serializer::RevealSpecificKeyLinkage::Result
- Defined in:
- lib/bsv/wallet/serializer/reveal_specific_key_linkage.rb
Overview
Result wire layout:
[33 bytes: prover pubkey]
[33 bytes: verifier pubkey]
[33 bytes: counterparty pubkey]
[1 byte: security_level][VarInt protocol_name_len][protocol_name bytes]
[VarInt key_id_len][key_id bytes]
[VarInt encrypted_linkage_len][encrypted_linkage bytes]
[VarInt encrypted_linkage_proof_len][encrypted_linkage_proof bytes]
[1 byte: proof_type]
Class Method Summary collapse
Class Method Details
.deserialize(bytes) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/bsv/wallet/serializer/reveal_specific_key_linkage.rb', line 81 def deserialize(bytes) r = BSV::Wallet::Wire::Reader.new(bytes) prover = r.read_bytes(PUBKEY_SIZE) verifier = r.read_bytes(PUBKEY_SIZE) counterparty = r.read_bytes(PUBKEY_SIZE) protocol_id = Common.read_protocol(r) key_id_len = r.read_varint key_id = r.read_bytes(key_id_len).force_encoding('UTF-8') el_len = r.read_varint encrypted_linkage = r.read_bytes(el_len) elp_len = r.read_varint encrypted_linkage_proof = r.read_bytes(elp_len) proof_type = r.read_byte { prover: prover, verifier: verifier, counterparty: counterparty, protocol_id: protocol_id, key_id: key_id, encrypted_linkage: encrypted_linkage, encrypted_linkage_proof: encrypted_linkage_proof, proof_type: proof_type } end |
.serialize(result) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/bsv/wallet/serializer/reveal_specific_key_linkage.rb', line 62 def serialize(result) w = BSV::Wallet::Wire::Writer.new w.write_bytes(pubkey_bytes(result[:prover])) w.write_bytes(pubkey_bytes(result[:verifier])) w.write_bytes(pubkey_bytes(result[:counterparty])) Common.write_protocol(w, result[:protocol_id]) key_id_bytes = result[:key_id].to_s.b w.write_varint(key_id_bytes.bytesize) w.write_bytes(key_id_bytes) encrypted_linkage = Common.to_binary(result[:encrypted_linkage]) w.write_varint(encrypted_linkage.bytesize) w.write_bytes(encrypted_linkage) encrypted_linkage_proof = Common.to_binary(result[:encrypted_linkage_proof]) w.write_varint(encrypted_linkage_proof.bytesize) w.write_bytes(encrypted_linkage_proof) w.write_byte(result[:proof_type].to_i) w.buf end |