tlsn_core/connection/
commit.rs1use serde::{Deserialize, Serialize};
4
5use crate::{
6 connection::ServerCertData,
7 hash::{impl_domain_separator, Blinded, HashAlgorithm, HashAlgorithmExt, TypedHash},
8};
9
10#[derive(Clone, Serialize, Deserialize)]
12pub struct ServerCertOpening(Blinded<ServerCertData>);
13
14impl_domain_separator!(ServerCertOpening);
15
16opaque_debug::implement!(ServerCertOpening);
17
18impl ServerCertOpening {
19 pub(crate) fn new(data: ServerCertData) -> Self {
20 Self(Blinded::new(data))
21 }
22
23 pub(crate) fn commit(&self, hasher: &dyn HashAlgorithm) -> ServerCertCommitment {
24 ServerCertCommitment(TypedHash {
25 alg: hasher.id(),
26 value: hasher.hash_separated(self),
27 })
28 }
29
30 pub fn data(&self) -> &ServerCertData {
32 self.0.data()
33 }
34}
35
36#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
38pub struct ServerCertCommitment(pub(crate) TypedHash);
39
40impl_domain_separator!(ServerCertCommitment);