tlsn_prover/
state.rs

1//! TLS prover states.
2
3use std::sync::Arc;
4
5use mpz_common::Context;
6
7use mpc_tls::{MpcTlsLeader, SessionKeys};
8use tlsn_common::{
9    mux::{MuxControl, MuxFuture},
10    transcript::TranscriptRefs,
11    zk_aes::ZkAesCtr,
12};
13use tlsn_core::{
14    connection::{ConnectionInfo, ServerCertData},
15    transcript::Transcript,
16};
17use tlsn_deap::Deap;
18use tokio::sync::Mutex;
19
20use crate::{Mpc, Zk};
21
22/// Entry state
23pub struct Initialized;
24
25opaque_debug::implement!(Initialized);
26
27/// State after MPC setup has completed.
28pub struct Setup {
29    pub(crate) mux_ctrl: MuxControl,
30    pub(crate) mux_fut: MuxFuture,
31    pub(crate) mpc_tls: MpcTlsLeader,
32    pub(crate) zk_aes: ZkAesCtr,
33    pub(crate) keys: SessionKeys,
34    pub(crate) vm: Arc<Mutex<Deap<Mpc, Zk>>>,
35}
36
37opaque_debug::implement!(Setup);
38
39/// State after the TLS connection has been committed and closed.
40pub struct Committed {
41    pub(crate) mux_ctrl: MuxControl,
42    pub(crate) mux_fut: MuxFuture,
43    pub(crate) ctx: Context,
44    pub(crate) _keys: SessionKeys,
45    pub(crate) vm: Zk,
46    pub(crate) connection_info: ConnectionInfo,
47    pub(crate) server_cert_data: ServerCertData,
48    pub(crate) transcript: Transcript,
49    pub(crate) transcript_refs: TranscriptRefs,
50}
51
52opaque_debug::implement!(Committed);
53
54#[allow(missing_docs)]
55pub trait ProverState: sealed::Sealed {}
56
57impl ProverState for Initialized {}
58impl ProverState for Setup {}
59impl ProverState for Committed {}
60
61mod sealed {
62    pub trait Sealed {}
63    impl Sealed for super::Initialized {}
64    impl Sealed for super::Setup {}
65    impl Sealed for super::Committed {}
66}