Skip to main content

ContactMessage

Struct ContactMessage 

Source
pub struct ContactMessage {
    pub mlkem_encapsulation_key: Vec<u8>,
    pub ecies_public_key: Vec<u8>,
    pub channel_id: u64,
    pub nonce: u64,
    pub transport_protocol: Option<TransportProtocol>,
    pub timestamp: Option<Timestamp>,
}
Expand description

ContactMessage is the only DeRec protocol message that is not wrapped inside a DeRecMessage.

This message is exchanged out-of-band before pairing begins. It provides the minimum information required for another party to initiate contact and send the first protocol message for a new pairing session.

Unlike normal DeRec protocol messages, a ContactMessage:

  • is not wrapped in a DeRecMessage
  • is not signed
  • is not encrypted
  • is not delivered through an already-established DeRec channel

Because it is exchanged before any secure channel exists, this message should only contain bootstrap information needed to establish that channel. It is typically transferred through a trusted or user-mediated mechanism.

Typical exchange mechanisms include:

  • QR codes displayed by either the Owner or Helper and scanned by the other party
  • distribution inside an application controlled by one of the parties
  • transmission over an already-existing communication channel when the parties have a prior relationship

The recipient of this message uses its contents to construct and send the initial pairing request. In particular, the ContactMessage conveys:

  • the public encryption key material needed to protect the first inbound pairing message
  • a channel identifier that the recipient must echo in subsequent protocol messages sent to this contact
  • a nonce that binds the pairing attempt to the out-of-band contact exchange
  • the transport information required to deliver the pairing request

The nonce may be transmitted together with the rest of the message or delivered separately by the application, depending on the authentication and pairing UX.

Fields§

§mlkem_encapsulation_key: Vec<u8>

Serialized ML-KEM-768 encapsulation key.

This public key is used by the sender of the first protocol message to establish confidentiality for the initial pairing exchange.

The exact cryptographic processing and message construction are defined by the DeRec pairing protocol and its implementation.

§ecies_public_key: Vec<u8>

Serialized ECIES public key.

This public key is used as part of the encryption scheme for the initial pairing message sent to the creator of this contact.

Together with mlkemEncapsulationKey, this field provides the public encryption material needed before the peers have established a secure DeRec channel.

§channel_id: u64

Channel identifier associated with this contact.

This value identifies the communication channel that the creator of this ContactMessage expects to use for the new pairing. After receiving this contact, the initiating party includes this channelId in subsequent protocol messages sent to the contact creator.

The recipient uses this identifier to determine which local key material and pairing state should be used when processing the message.

If an implementation generates multiple pending contact records or multiple encryption key pairs for different pairing attempts, it should retain the mapping from channelId to the corresponding local state so it can process inbound messages without trial decryption across all keys.

This value MUST be unique within the scope required by the implementation to disambiguate concurrent or stored pairing sessions.

§nonce: u64

Random nonce used to bind the pairing request to this contact exchange.

The initiator includes this value in the pairing request so the creator of the ContactMessage can confirm that the request corresponds to the same out-of-band contact information that was just shared.

This helps the application detect mismatched, stale, or spoofed pairing attempts during the bootstrap phase.

Applications may choose to reveal this nonce only after sufficient out-of-band authentication has taken place.

§transport_protocol: Option<TransportProtocol>

Transport information used to reach the creator of this contact.

This specifies both:

  • the endpoint to which the first protocol message should be sent
  • the transport protocol that determines how that endpoint is interpreted and used

The initiating party uses this field to deliver the initial pairing request. Subsequent protocol exchanges may continue using the same transport information or updated transport details, depending on the protocol and application behavior.

§timestamp: Option<Timestamp>

Timestamp indicating when the sender created this message.

This value is expressed in UTC and can be used for:

  • replay detection
  • timeout handling
  • logging and observability

Trait Implementations§

Source§

impl Clone for ContactMessage

Source§

fn clone(&self) -> ContactMessage

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 ContactMessage

Source§

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

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

impl Default for ContactMessage

Source§

fn default() -> Self

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

impl Hash for ContactMessage

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 Message for ContactMessage

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 ContactMessage

Source§

fn eq(&self, other: &ContactMessage) -> 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 Eq for ContactMessage

Source§

impl StructuralPartialEq for ContactMessage

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.