# state.rs - source
Source of the Rust file `crates/tlsn/src/prover/state.rs`.

Skip to main content

#
tlsn/prover/
state.rs

    1//! TLS prover states.
    2
    3use std::sync::Arc;
    4
    5use futures_plex::DuplexStream;
    6use mpc_tls::{MpcTlsLeader, SessionKeys};
    7use tlsn_core::{
    8    connection::ServerName,
    9    transcript::{TlsTranscript, Transcript},
    10};
    11use tlsn_deap::Deap;
    12use tokio::sync::Mutex;
    13
    14use crate::{
    15    Error,
    16    mpz::{ProverMpc, ProverZk},
    17    prover::client::{TlsClient, TlsOutput},
    18};
    19
    20/// Entry state
    21pub struct Initialized;
    22
    23opaque_debug::implement!(Initialized);
    24
    25/// State after the verifier has accepted the proposed TLS commitment protocol
    26/// configuration and preprocessing has completed.
    27pub struct CommitAccepted {
    28    pub(crate) mpc_tls: MpcTlsLeader,
    29    pub(crate) keys: SessionKeys,
    30    pub(crate) vm: Arc<Mutex<Deap<ProverMpc, ProverZk>>>,
    31}
    32
    33opaque_debug::implement!(CommitAccepted);
    34
    35pin_project_lite::pin_project! {
    36    /// State during the MPC-TLS connection.
    37    #[project = ConnectedProj]
    38    pub struct Connected<S> {
    39        pub(crate) server_name: ServerName,
    40        pub(crate) tls_client: Box<dyn TlsClient<Error = Error> + Send>,
    41        #[pin]
    42        pub(crate) client_io: DuplexStream,
    43        pub(crate) output: Option<TlsOutput>,
    44        #[pin]
    45        pub(crate) server_socket: S,
    46        #[pin]
    47        pub(crate) client_to_server: DuplexStream,
    48        #[pin]
    49        pub(crate) server_to_client: DuplexStream,
    50        pub(crate) client_closed: bool,
    51        pub(crate) server_closed: bool
    52    }
    53}
    54
    55opaque_debug::implement!(Connected<S>);
    56
    57/// State after the TLS transcript has been committed.
    58pub struct Committed {
    59    pub(crate) vm: ProverZk,
    60    pub(crate) server_name: ServerName,
    61    pub(crate) keys: SessionKeys,
    62    pub(crate) tls_transcript: TlsTranscript,
    63    pub(crate) transcript: Transcript,
    64}
    65
    66opaque_debug::implement!(Committed);
    67
    68#[allow(missing_docs)]
    69pub trait ProverState: sealed::Sealed {}
    70
    71impl ProverState for Initialized {}
    72impl ProverState for CommitAccepted {}
    73impl<S> ProverState for Connected<S> {}
    74impl ProverState for Committed {}
    75
    76mod sealed {
    77    pub trait Sealed {}
    78    impl Sealed for super::Initialized {}
    79    impl Sealed for super::CommitAccepted {}
    80    impl<S> Sealed for super::Connected<S> {}
    81    impl Sealed for super::Committed {}
    82}