try_parse_pubkey

Function try_parse_pubkey 

Source
pub fn try_parse_pubkey(token: &str) -> Option<PublicKey>
Expand description

Decode a <peer-ref> token into a PublicKey. Alias lookup is the caller’s concern; this helper only handles the encoded forms.

The canonical forms (44-char base58 and 64-char hex, distinguished by length) are tried first via [PublicKey::from_str], then base64.

After successful decoding the bytes are validated as a well-formed Ed25519 compressed public-key point on the curve (when the software-crypto feature is enabled). Bytes that decode to 32 bytes but do not lie on the curve return None so a typo’d hex string can never be accepted as a peer key.

Returns None if the token doesn’t decode to a full 32-byte key in any of the supported encodings, or if the decoded bytes are not a valid Ed25519 point.