1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//! The PRF's domain-separation context, as a view of a context.
//!
//! The bytes a PRF derives under for a context are the context's canonical
//! encoding, owned by [`vitaminc_context`]. This module adds nothing to that
//! encoding: [`IntoPrfContext`] is a blanket over [`IntoContext`], so a
//! context type implements `IntoContext` once and gets `IntoPrfContext` (and
//! the AEAD crate's `IntoAad`) for free, with byte-identical results on both
//! sides.
pub use ;
/// The context a PRF derives under. Kept as a name for the transition; it
/// is [`Context`].
pub type PrfContext<'a> = ;
/// Types that can be used as the domain-separation context of a PRF
/// derivation.
///
/// This is the PRF's view of a context. It is implemented for every type
/// that implements [`IntoContext`], and only through that blanket, so the
/// bytes a PRF derives under are always the context's canonical encoding
/// and always equal to what an AEAD authenticates for the same value. There
/// is nothing to implement here: give a type of your own an `IntoContext`
/// impl and it is an `IntoPrfContext`.
///
/// ```rust
/// use vitaminc_prf::{ContextPiece, IntoContext, IntoPrfContext};
///
/// struct TenantId(u64);
///
/// impl<'a> IntoContext<'a> for TenantId {
/// fn into_context(self) -> ContextPiece<'a> {
/// ("tenant", self.0).into_context()
/// }
/// }
///
/// assert_eq!(
/// TenantId(7).into_prf_context(),
/// ("tenant", 7u64).into_prf_context(),
/// );
/// ```