ed448_goldilocks/sign/context.rs
1/// Ed448 contexts as used by Ed448ph.
2///
3/// Contexts are domain separator strings that can be used to isolate uses of
4/// the algorithm between different protocols (which is very hard to reliably do
5/// otherwise) and between different uses within the same protocol.
6///
7/// To create a context, call either of the following:
8///
9/// - [`SigningKey::with_context`](crate::SigningKey::with_context)
10/// - [`VerifyingKey::with_context`](crate::VerifyingKey::with_context)
11#[derive(Copy, Clone, Debug)]
12pub struct Context<'k, 'v, K> {
13 pub(crate) key: &'k K,
14 pub(crate) value: &'v [u8],
15}
16
17impl<'k, 'v, K> Context<'k, 'v, K> {
18 /// Maximum length of a context string.
19 pub const MAX_LENGTH: usize = 255;
20
21 /// Borrow the key
22 pub fn key(&self) -> &'k K {
23 self.key
24 }
25
26 /// Borrow the value
27 pub fn value(&self) -> &'v [u8] {
28 self.value
29 }
30}