tlsn_verifier/
state.rs

1//! TLS Verifier state.
2
3use std::sync::Arc;
4
5use crate::{Mpc, Zk};
6use mpc_tls::{MpcTlsFollower, SessionKeys};
7use mpz_common::Context;
8use mpz_memory_core::correlated::Delta;
9use tlsn_common::{
10    mux::{MuxControl, MuxFuture},
11    transcript::TranscriptRefs,
12    zk_aes_ctr::ZkAesCtr,
13};
14use tlsn_core::connection::{ConnectionInfo, ServerEphemKey};
15use tlsn_deap::Deap;
16use tokio::sync::Mutex;
17
18/// TLS Verifier state.
19pub trait VerifierState: sealed::Sealed {}
20
21/// Initialized state.
22pub struct Initialized;
23
24opaque_debug::implement!(Initialized);
25
26/// State after setup has completed.
27pub struct Setup {
28    pub(crate) mux_ctrl: MuxControl,
29    pub(crate) mux_fut: MuxFuture,
30    pub(crate) delta: Delta,
31    pub(crate) mpc_tls: MpcTlsFollower,
32    pub(crate) zk_aes_ctr: ZkAesCtr,
33    pub(crate) _keys: SessionKeys,
34    pub(crate) vm: Arc<Mutex<Deap<Mpc, Zk>>>,
35}
36
37/// State after the TLS connection has been closed.
38pub struct Committed {
39    pub(crate) mux_ctrl: MuxControl,
40    pub(crate) mux_fut: MuxFuture,
41    pub(crate) delta: Delta,
42    pub(crate) ctx: Context,
43    pub(crate) vm: Zk,
44    pub(crate) server_ephemeral_key: ServerEphemKey,
45    pub(crate) connection_info: ConnectionInfo,
46    pub(crate) transcript_refs: TranscriptRefs,
47}
48
49opaque_debug::implement!(Committed);
50
51impl VerifierState for Initialized {}
52impl VerifierState for Setup {}
53impl VerifierState for Committed {}
54
55mod sealed {
56    pub trait Sealed {}
57    impl Sealed for super::Initialized {}
58    impl Sealed for super::Setup {}
59    impl Sealed for super::Committed {}
60}