Skip to main content

PairRequestMessage

Struct PairRequestMessage 

Source
pub struct PairRequestMessage {
    pub sender_kind: i32,
    pub mlkem_ciphertext: Vec<u8>,
    pub ecies_public_key: Vec<u8>,
    pub channel_id: u64,
    pub communication_info: Option<CommunicationInfo>,
    pub nonce: u64,
    pub parameter_range: Option<ParameterRange>,
    pub transport_protocol: Option<TransportProtocol>,
    pub timestamp: Option<Timestamp>,
}
Expand description

PairRequestMessage is the first message in the pairing protocol, sent from the initiator to the responder after receiving a ContactMessage.

§Preconditions

Before sending this message:

  • The initiator MUST have received a valid ContactMessage from the responder
  • The initiator MUST use the responder’s public encryption material from the ContactMessage to construct this request

§Purpose

This message establishes:

  • the initiator’s identity and role (Owner/Helper, recovery mode or not)
  • fresh cryptographic material for the responder to use in subsequent messages
  • agreement negotiation inputs (parameter ranges)
  • binding between the out-of-band contact exchange and this pairing attempt
  • transport information for future communication

§Security Properties

  • The nonce binds this request to the ContactMessage exchange
  • The ciphertext and public keys bootstrap a secure communication channel
  • The message is encrypted and authenticated at the DeRecMessage layer

§Outcome

Upon successful processing, the responder replies with PairResponseMessage. After this exchange:

  • both parties know each other’s public keys
  • a secure communication channel is established for subsequent protocol flows

Fields§

§sender_kind: i32

The role of the sender of this message.

This informs the responder whether the initiator is:

  • an Owner (normal or recovery mode), or
  • a Helper

Recovery mode has special semantics for how Helpers associate this pairing with existing stored secrets.

§mlkem_ciphertext: Vec<u8>

ML-KEM-768 ciphertext.

This ciphertext is generated using the responder’s ML-KEM public key obtained from the ContactMessage. It is used to establish shared cryptographic material for securing subsequent communication.

§ecies_public_key: Vec<u8>

Serialized ECIES public key of the sender.

This key is provided to the responder so that future messages can be encrypted toward the initiator.

§channel_id: u64

Channel identifier chosen by the initiator.

This value identifies the logical communication channel that will be established upon successful pairing. The responder MUST use this value when sending subsequent messages to the initiator.

Implementations SHOULD ensure uniqueness to avoid collisions between concurrent or stored pairing sessions.

§communication_info: Option<CommunicationInfo>

Sender’s application-level identifying information.

This field is intended for user-facing identification and may include data such as name, phone number, or account identifiers.

It is not used directly by the protocol for security decisions.

§nonce: u64

Nonce binding this request to the ContactMessage exchange.

This value MUST match the nonce provided in the ContactMessage. It allows the responder to verify that the pairing request corresponds to the same out-of-band interaction, preventing mismatched or spoofed pairing attempts.

§parameter_range: Option<ParameterRange>

Parameter range supported by the sender.

This defines the acceptable configuration space (e.g., thresholds, limits) that the sender is willing to operate under.

The responder combines this with its own parameter range to determine whether pairing is possible and which parameters to use.

§transport_protocol: Option<TransportProtocol>

Transport information for reaching the initiator.

This specifies:

  • the endpoint where the initiator can receive messages
  • the protocol required to deliver those messages

After pairing, the responder uses this information to send responses and all subsequent protocol messages to the initiator.

§timestamp: Option<Timestamp>

Timestamp indicating when this message was created.

Used for observability and may assist in replay detection or timeout handling, depending on the implementation.

Implementations§

Source§

impl PairRequestMessage

Source

pub fn sender_kind(&self) -> SenderKind

Returns the enum value of sender_kind, or the default if the field is set to an invalid enum value.

Source

pub fn set_sender_kind(&mut self, value: SenderKind)

Sets sender_kind to the provided enum value.

Trait Implementations§

Source§

impl Clone for PairRequestMessage

Source§

fn clone(&self) -> PairRequestMessage

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for PairRequestMessage

Source§

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

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

impl Default for PairRequestMessage

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Message for PairRequestMessage

Source§

fn encoded_len(&self) -> usize

Returns the encoded length of the message without a length delimiter.
Source§

fn clear(&mut self)

Clears the message, resetting all fields to their default.
Source§

fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>
where Self: Sized,

Encodes the message to a buffer. Read more
Source§

fn encode_to_vec(&self) -> Vec<u8>
where Self: Sized,

Encodes the message to a newly allocated buffer.
Source§

fn encode_length_delimited( &self, buf: &mut impl BufMut, ) -> Result<(), EncodeError>
where Self: Sized,

Encodes the message with a length-delimiter to a buffer. Read more
Source§

fn encode_length_delimited_to_vec(&self) -> Vec<u8>
where Self: Sized,

Encodes the message with a length-delimiter to a newly allocated buffer.
Source§

fn decode(buf: impl Buf) -> Result<Self, DecodeError>
where Self: Default,

Decodes an instance of the message from a buffer. Read more
Source§

fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>
where Self: Default,

Decodes a length-delimited instance of the message from the buffer.
Source§

fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>
where Self: Sized,

Decodes an instance of the message from a buffer, and merges it into self. Read more
Source§

fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>
where Self: Sized,

Decodes a length-delimited instance of the message from buffer, and merges it into self.
Source§

impl PartialEq for PairRequestMessage

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for PairRequestMessage

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