Keyboard shortcuts

Press or to navigate between chapters

Press ? to show this help

Press Esc to hide this help

public_key_to_bytes

Serializes a Bitcoin public key to its byte representation.

Converts a public key to either compressed (33 bytes) or uncompressed (65 bytes) format according to SEC 1 standard:

  • Compressed: 0x02/0x03 prefix + x-coordinate (33 bytes)
  • Uncompressed: 0x04 prefix + x-coordinate + y-coordinate (65 bytes)

Arguments

  • public_key - The Bitcoin public key to serialize

Returns

  • Array<u8> - Serialized public key bytes (33 or 65 bytes)

Fully qualified path: alexandria_btc::keys::public_key_to_bytes

pub fn public_key_to_bytes(public_key: BitcoinPublicKey) -> Array<u8>