Skip to main content

StartProtocol

Enum StartProtocol 

Source
pub enum StartProtocol<I, T, C, G, K, D> {
    StartSession(StartInitiation<T, C>),
    SessionEstablished(StartEstablished<I>),
    SsaCommit(SsaClientCommitmentMessage<I, G, K>),
    SsaRequest(SsaServerCommitmentMessage<I, G, D>),
    SessionError(StartErrorType<I>),
    KeepAlive(KeepAliveMessage<I>),
}
Expand description

Lists all messages of the Start protocol for a session establishment.

§Generic parameters

  • I is the session identifier.
  • T is the session target.
  • C are session capabilities.
  • G is the type of the commitment to the Session Stealth Address (SSA).
  • K is the wire form of the proof of knowledge going with a client SSA commitment.
  • D is the type of the deposit data carried in the Server’s SSA commitment.

§Diagram of the protocol

sequenceDiagram Entry->>Exit: SessionInitiation (Challenge) alt If Exit can accept a new session Note right of Exit: SessionID [Pseudonym, Tag] Exit->>Entry: SessionEstablished (Challenge, SessionID) Note left of Entry: SessionID [Pseudonym, Tag] Exit->>Entry: SsaRequest (SessionID, SsaIndex, ServerCommitments) Entry->>Exit: SsaCommit (SessionID, SsaIndex, CoeffIndex, PolyCoeffs) Entry->>Exit: KeepAlive (SessionID) Exit->>Entry: KeepAlive (SessionID) Note over Entry,Exit: Data else If Exit cannot accept a new session Exit->>Entry: SessionError (Challenge, Reason) end opt If initiation attempt times out Note left of Entry: Failure end

Variants§

§

StartSession(StartInitiation<T, C>)

Request to initiate a new session.

§

SessionEstablished(StartEstablished<I>)

Confirmation that a new session has been established by the counterparty.

§

SsaCommit(SsaClientCommitmentMessage<I, G, K>)

Client’s message to fill Client commitments to establish a Session Stealth Address (SSA).

§

SsaRequest(SsaServerCommitmentMessage<I, G, D>)

Server-side commitment to Session Stealth Address (SSA).

§

SessionError(StartErrorType<I>)

Counterparty could not establish a new session due to an error.

§

KeepAlive(KeepAliveMessage<I>)

A ping message to keep the session alive.

Implementations§

Source§

impl<I, T, C, G, K, D> StartProtocol<I, T, C, G, K, D>

Source

pub const MAX_DEPOSIT_DATA_SIZE: usize

Maximum size of the CBOR-serialized deposit_data map an SsaRequest message can carry.

Source

pub const MAX_SSAS_PER_REQUEST: u16

Maximum number of SSAs that can be requested in a single SsaRequest message.

Source

pub const MISSING_RUN_ENTRY_SIZE: usize

Wire size of one missing table entry: the SSA index it belongs to, then the run’s inclusive first and last polynomial index.

Source

pub const PIX_COEFF_COMMITMENT_REPR_SIZE: usize

Size of the PIX coefficient commitment representation in bytes.

Source

pub const PIX_COMMITMENT_PROOF_SIZE: usize

Size of the serialized client SSA commitment proof of knowledge in bytes.

Carried only by constant-term SsaCommit messages, so it reduces the entry budget of those and of no others.

Source

pub const START_HEADER_SIZE: usize

Size of the Start protocol message header in bytes.

Source

pub const START_PROTOCOL_MESSAGE_TAG: Tag

Fixed [Tag] of every protocol message.

Source

pub const START_PROTOCOL_VERSION: u8 = 0x04

Current version of the Start protocol.

Source

pub fn ssa_commit_chunking( session_id: &I, ) -> Result<SsaCommitChunking, StartProtocolError>
where I: Serialize,

How many commitment entries one SsaCommit message can carry, for each of the two delivery phases.

This is the bound SsaClientCommitmentMessage::new_multiple chunks by, exposed so that a caller predicting the message count for a commitment does not have to restate the encode layout. Restating it is error-prone in a way that hides: the copy this replaced used SsaIndex (4 B) where an SsaCommit entry prefix is a PolynomialIndex (2 B), against a different fixed overhead, and agreed with the encoder only because the two mistakes floored to the same divisor at the dimensions it ran at.

Takes the session_id itself rather than a precomputed length: its CBOR encoding is part of the layout, so leaving the caller to measure it is the same footgun one level up.

Source

pub fn max_missing_runs(session_id: &I) -> Result<usize, StartProtocolError>
where I: Serialize,

How many missing runs one retransmission request can carry.

Exposed for the same reason as ssa_commit_chunking: the caller choosing the scope must not restate the encode layout, because a copy that drifts either overflows a packet or silently under-reports what is missing. It takes the session_id itself rather than a length, since the id’s CBOR encoding is part of that layout.

Derived against a request built by SsaServerCommitmentMessage::recommit, which carries no commitments and an empty deposit_data map:

  header:    version(1) + disc(1) + data_len(2) = 4
  fixed:     params(4) + empty CBOR map(1) + num_commitments(2) + num_missing_runs(2) = 9
  per-entry: MISSING_RUN_ENTRY_SIZE
  trailer:   CBOR-encoded session_id

At least one, so a caller can always ask for something: a budget that rounded to zero would leave a repairable cycle with no way to be repaired.

Source§

impl<I, T, C, G, K, D> StartProtocol<I, T, C, G, K, D>
where I: Serialize, T: Serialize, C: Into<u8>, G: AsRef<[u8]>, K: AsRef<[u8]>, D: Serialize,

Source

pub fn encode(self) -> Result<(Tag, Box<[u8]>)>

Tries to encode the message into binary format and [Tag]

Source§

impl<I, T, C, G, K, D> StartProtocol<I, T, C, G, K, D>
where I: for<'de> Deserialize<'de>, T: for<'de> Deserialize<'de>, C: TryFrom<u8>, G: for<'a> TryFrom<&'a [u8]>, K: for<'a> TryFrom<&'a [u8]>, D: for<'de> Deserialize<'de>,

Source

pub fn decode(tag: Tag, data: &[u8]) -> Result<Self>

Tries to decode the message from the binary representation and [Tag].

The tag must be currently START_PROTOCOL_MESSAGE_TAG and version START_PROTOCOL_VERSION.

Trait Implementations§

Source§

impl<I: Clone, T: Clone, C: Clone, G: Clone, K: Clone, D: Clone> Clone for StartProtocol<I, T, C, G, K, D>

Source§

fn clone(&self) -> StartProtocol<I, T, C, G, K, D>

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<I: Debug, T: Debug, C: Debug, G: Debug, K: Debug, D: Debug> Debug for StartProtocol<I, T, C, G, K, D>

Source§

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

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

impl<I: Eq, T: Eq, C: Eq, G: Eq, K: Eq, D: Eq> Eq for StartProtocol<I, T, C, G, K, D>

Source§

impl<'_enum, I, T, C, G, K, D> From<&'_enum StartProtocol<I, T, C, G, K, D>> for StartProtocolDiscriminants

Source§

fn from( val: &'_enum StartProtocol<I, T, C, G, K, D>, ) -> StartProtocolDiscriminants

Converts to this type from the input type.
Source§

impl<I, T, C, G, K, D> From<StartProtocol<I, T, C, G, K, D>> for StartProtocolDiscriminants

Source§

fn from(val: StartProtocol<I, T, C, G, K, D>) -> StartProtocolDiscriminants

Converts to this type from the input type.
Source§

impl<I, T, C, G, K, D> IntoDiscriminant for StartProtocol<I, T, C, G, K, D>

Source§

type Discriminant = StartProtocolDiscriminants

Enum listing the same variants as this enum but without any data fields
Source§

fn discriminant(&self) -> Self::Discriminant

Source§

impl<I: PartialEq, T: PartialEq, C: PartialEq, G: PartialEq, K: PartialEq, D: PartialEq> PartialEq for StartProtocol<I, T, C, G, K, D>

Source§

fn eq(&self, other: &StartProtocol<I, T, C, G, K, D>) -> bool

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

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

Inequality operator !=. Read more
Source§

impl<I: PartialEq, T: PartialEq, C: PartialEq, G: PartialEq, K: PartialEq, D: PartialEq> StructuralPartialEq for StartProtocol<I, T, C, G, K, D>

Source§

impl<I, T, C, G, K, D> TryFrom<ApplicationData> for StartProtocol<I, T, C, G, K, D>
where I: Serialize + for<'de> Deserialize<'de>, T: Serialize + for<'de> Deserialize<'de>, C: Into<u8> + TryFrom<u8>, G: AsRef<[u8]> + for<'a> TryFrom<&'a [u8]>, K: AsRef<[u8]> + for<'a> TryFrom<&'a [u8]>, D: Serialize + for<'de> Deserialize<'de>,

Source§

type Error = StartProtocolError

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

fn try_from(value: ApplicationData) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<I, T, C, G, K, D> TryFrom<StartProtocol<I, T, C, G, K, D>> for ApplicationData
where I: Serialize + for<'de> Deserialize<'de>, T: Serialize + for<'de> Deserialize<'de>, C: Into<u8> + TryFrom<u8>, G: AsRef<[u8]> + for<'a> TryFrom<&'a [u8]>, K: AsRef<[u8]> + for<'a> TryFrom<&'a [u8]>, D: Serialize + for<'de> Deserialize<'de>,

Source§

type Error = StartProtocolError

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

fn try_from(value: StartProtocol<I, T, C, G, K, D>) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl<I, T, C, G, K, D> Freeze for StartProtocol<I, T, C, G, K, D>
where T: Freeze, C: Freeze, I: Freeze, K: Freeze,

§

impl<I, T, C, G, K, D> RefUnwindSafe for StartProtocol<I, T, C, G, K, D>

§

impl<I, T, C, G, K, D> Send for StartProtocol<I, T, C, G, K, D>
where T: Send, C: Send, I: Send, K: Send, G: Send, D: Send,

§

impl<I, T, C, G, K, D> Sync for StartProtocol<I, T, C, G, K, D>
where T: Sync, C: Sync, I: Sync, K: Sync, G: Sync, D: Sync,

§

impl<I, T, C, G, K, D> Unpin for StartProtocol<I, T, C, G, K, D>
where T: Unpin, C: Unpin, I: Unpin, K: Unpin, G: Unpin, D: Unpin,

§

impl<I, T, C, G, K, D> UnsafeUnpin for StartProtocol<I, T, C, G, K, D>

§

impl<I, T, C, G, K, D> UnwindSafe for StartProtocol<I, T, C, G, K, D>

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> DynClone for T
where T: Clone,

§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FutureExt for T

§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more