tlsn_core/transcript/
hash.rs1use serde::{Deserialize, Serialize};
4
5use crate::{
6 hash::{impl_domain_separator, Blinder, HashAlgId, HashAlgorithm, TypedHash},
7 transcript::{Direction, Idx},
8};
9
10pub fn hash_plaintext(hasher: &dyn HashAlgorithm, msg: &[u8], blinder: &Blinder) -> TypedHash {
14 TypedHash {
15 alg: hasher.id(),
16 value: hasher.hash_prefixed(msg, blinder.as_bytes()),
17 }
18}
19
20#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
22pub struct PlaintextHash {
23 pub direction: Direction,
25 pub idx: Idx,
27 pub hash: TypedHash,
29}
30
31impl_domain_separator!(PlaintextHash);
32
33#[derive(Clone, Serialize, Deserialize)]
35pub struct PlaintextHashSecret {
36 pub direction: Direction,
38 pub idx: Idx,
40 pub alg: HashAlgId,
42 pub blinder: Blinder,
44}
45
46opaque_debug::implement!(PlaintextHashSecret);