tlsn_core/
secrets.rs

1use serde::{Deserialize, Serialize};
2
3use crate::{
4    connection::{ServerCertOpening, ServerIdentityProof, ServerName},
5    transcript::{Transcript, TranscriptCommitment, TranscriptProofBuilder, TranscriptSecret},
6};
7
8/// Secret data of an [`Attestation`](crate::attestation::Attestation).
9#[derive(Clone, Serialize, Deserialize)]
10pub struct Secrets {
11    pub(crate) server_name: ServerName,
12    pub(crate) server_cert_opening: ServerCertOpening,
13    pub(crate) transcript: Transcript,
14    pub(crate) transcript_commitments: Vec<TranscriptCommitment>,
15    pub(crate) transcript_commitment_secrets: Vec<TranscriptSecret>,
16}
17
18opaque_debug::implement!(Secrets);
19
20impl Secrets {
21    /// Returns the server name.
22    pub fn server_name(&self) -> &ServerName {
23        &self.server_name
24    }
25
26    /// Returns the transcript.
27    pub fn transcript(&self) -> &Transcript {
28        &self.transcript
29    }
30
31    /// Returns a server identity proof.
32    pub fn identity_proof(&self) -> ServerIdentityProof {
33        ServerIdentityProof::new(self.server_name.clone(), self.server_cert_opening.clone())
34    }
35
36    /// Returns a transcript proof builder.
37    pub fn transcript_proof_builder(&self) -> TranscriptProofBuilder<'_> {
38        TranscriptProofBuilder::new(&self.transcript, &self.transcript_commitment_secrets)
39    }
40}