parsePublicKey
function parsePublicKey(publicKeyHex, label): Buffer;Defined in: src/protocol/pubkey.ts:14
Decode a full 32-byte public key from hex, rejecting anything that isn’t
exactly 64 valid hex chars. Buffer.from(hex, 'hex') silently truncates an
odd trailing nibble, stops at the first non-hex char, and over-allocates for
overlong input — so a bare length < 32 check lets malformed/overlong keys
alias to the same 32 bytes on the wire. Validating up front keeps distinct
invalid inputs distinct (they throw) instead of being truncated. label
names the caller for the error message.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
publicKeyHex | string |
label | string |
Returns
Section titled “Returns”Buffer