Skip to main content

PeerKey

Struct PeerKey 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§algorithm: PeerKeyAlgorithm

Which scheme key belongs to.

§key: Vec<u8>

The raw public key bytes. Wire form: base64url-no-pad.

Implementations§

Source§

impl PeerKey

Source

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).

Source

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.

Source

pub fn algorithm(&self) -> &PeerKeyAlgorithm

Source

pub fn as_bytes(&self) -> &[u8]

Source

pub fn to_base64url(&self) -> String

The key’s wire encoding (base64url-no-pad), for logs and roster files.

Trait Implementations§

Source§

impl Clone for PeerKey

Source§

fn clone(&self) -> PeerKey

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PeerKey

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for PeerKey

Source§

fn deserialize<D: Deserializer<'de>>(de: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for PeerKey

Source§

impl Hash for PeerKey

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for PeerKey

Source§

fn eq(&self, other: &PeerKey) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for PeerKey

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for PeerKey

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.