#[non_exhaustive]pub struct PeerKey {
pub algorithm: PeerKeyAlgorithm,
pub key: Vec<u8>,
}Expand description
A long-lived, client-held public key a session token can be bound to.
Raw bytes plus an algorithm discriminant — deliberately not an
ed25519-dalek (or any other crypto crate’s) type. Consumers straddle a
real version split (iroh resolves ed25519-dalek 3.0.0-pre, other trust
crates resolve 2.2), so a crypto type here would hand every consumer a
version pin it cannot satisfy. cheers only ever compares these bytes; it
never verifies a signature under them, so it needs no crypto to hold one.
Wire form is {"alg": "<label>", "key": "<base64url-no-pad>"} — the same
base64url-no-pad encoding UserDelegation uses,
which every cross-platform Ed25519 toolchain agrees on.
Nothing secret lives in this type (a public key is public), so equality is
plain ==, not constant-time.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.algorithm: PeerKeyAlgorithmWhich scheme key belongs to.
key: Vec<u8>The raw public key bytes. Wire form: base64url-no-pad.
Implementations§
Source§impl PeerKey
impl PeerKey
Sourcepub fn new(
algorithm: PeerKeyAlgorithm,
key: impl Into<Vec<u8>>,
) -> Result<Self, PeerKeyError>
pub fn new( algorithm: PeerKeyAlgorithm, key: impl Into<Vec<u8>>, ) -> Result<Self, PeerKeyError>
Construct + validate: rejects empty bytes, and a length that disagrees
with an algorithm that names one (expected_key_len).
Sourcepub fn ed25519(key: [u8; 32]) -> Self
pub fn ed25519(key: [u8; 32]) -> Self
The common case — an Ed25519 node public key. Infallible: the length invariant is carried by the array type.
pub fn algorithm(&self) -> &PeerKeyAlgorithm
pub fn as_bytes(&self) -> &[u8] ⓘ
Sourcepub fn to_base64url(&self) -> String
pub fn to_base64url(&self) -> String
The key’s wire encoding (base64url-no-pad), for logs and roster files.