Skip to main content

PairingProtocol

Struct PairingProtocol 

Source
pub struct PairingProtocol { /* private fields */ }
Expand description

Transport-agnostic pairing protocol state machine.

EphemeralSecret from x25519-dalek is !Clone + !Serialize, so this state machine is inherently ephemeral — it lives in memory only and cannot be persisted across app restarts.

Usage:

// Initiator side:
let (protocol, token) = PairingProtocol::initiate(now, controller_did, endpoint, caps)?;
let token_bytes = serde_json::to_vec(&token)?;
// Send token_bytes to peer over transport (HTTP, BLE, QR, etc.)

// After receiving response bytes from peer:
let completed = protocol.complete(now, response_bytes)?;
// completed.shared_secret, completed.peer_did are now available

Implementations§

Source§

impl PairingProtocol

Source

pub fn initiate( now: DateTime<Utc>, controller_did: String, endpoint: String, capabilities: Vec<String>, ) -> Result<(Self, PairingToken), ProtocolError>

Initiate a pairing session.

Args:

  • now - Current time (injected, not fetched internally)
  • controller_did - The initiator’s identity DID
  • endpoint - Registry endpoint URL
  • capabilities - Capabilities to grant to the paired device

Usage:

let (protocol, token) = PairingProtocol::initiate(now, did, endpoint, caps)?;
Source

pub fn complete( self, now: DateTime<Utc>, response_bytes: &[u8], ) -> Result<CompletedPairing, ProtocolError>

Complete the pairing exchange with a received response.

Consumes the protocol state (ephemeral secret is used exactly once).

Args:

  • now - Current time for expiry checking
  • response_bytes - Serialized PairingResponse from the peer

Usage:

let completed = protocol.complete(now, &response_bytes)?;
Source

pub fn complete_with_response( self, now: DateTime<Utc>, response: PairingResponse, ) -> Result<CompletedPairing, ProtocolError>

Complete the pairing exchange with a structured response.

Args:

  • now - Current time for expiry checking
  • response - The peer’s PairingResponse
Source

pub fn token(&self) -> &PairingToken

Get a reference to the pairing token for display/transmission.

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> 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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V