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

Skip to main content

#
tlsn/verifier/
state.rs

    1//! TLS Verifier state.
    2
    3use std::sync::Arc;
    4
    5use mpc_tls::{MpcTlsFollower, SessionKeys};
    6use tlsn_core::{
    7    config::{prove::ProveRequest, tls_commit::TlsCommitRequest},
    8    connection::{HandshakeData, ServerName},
    9    transcript::{PartialTranscript, TlsTranscript},
    10};
    11use tlsn_deap::Deap;
    12use tokio::sync::Mutex;
    13
    14use crate::mpz::{VerifierMpc, VerifierZk};
    15
    16/// TLS Verifier state.
    17pub trait VerifierState: sealed::Sealed {}
    18
    19/// Initialized state.
    20pub struct Initialized;
    21
    22opaque_debug::implement!(Initialized);
    23
    24/// State after receiving protocol configuration from the prover.
    25pub struct CommitStart {
    26    pub(crate) request: TlsCommitRequest,
    27}
    28
    29opaque_debug::implement!(CommitStart);
    30
    31/// State after accepting the proposed TLS commitment protocol configuration and
    32/// performing preprocessing.
    33pub struct CommitAccepted {
    34    pub(crate) mpc_tls: MpcTlsFollower,
    35    pub(crate) keys: SessionKeys,
    36    pub(crate) vm: Arc<Mutex<Deap<VerifierMpc, VerifierZk>>>,
    37}
    38
    39opaque_debug::implement!(CommitAccepted);
    40
    41/// State after the TLS transcript has been committed.
    42pub struct Committed {
    43    pub(crate) vm: VerifierZk,
    44    pub(crate) keys: SessionKeys,
    45    pub(crate) tls_transcript: TlsTranscript,
    46}
    47
    48opaque_debug::implement!(Committed);
    49
    50/// State after receiving a proving request.
    51pub struct Verify {
    52    pub(crate) vm: VerifierZk,
    53    pub(crate) keys: SessionKeys,
    54    pub(crate) tls_transcript: TlsTranscript,
    55    pub(crate) request: ProveRequest,
    56    pub(crate) handshake: Option<(ServerName, HandshakeData)>,
    57    pub(crate) transcript: Option<PartialTranscript>,
    58}
    59
    60opaque_debug::implement!(Verify);
    61
    62impl VerifierState for Initialized {}
    63impl VerifierState for CommitStart {}
    64impl VerifierState for CommitAccepted {}
    65impl VerifierState for Committed {}
    66impl VerifierState for Verify {}
    67
    68mod sealed {
    69    pub trait Sealed {}
    70    impl Sealed for super::Initialized {}
    71    impl Sealed for super::CommitStart {}
    72    impl Sealed for super::CommitAccepted {}
    73    impl Sealed for super::Committed {}
    74    impl Sealed for super::Verify {}
    75}