oxabl_cache_crypto/
keys.rs1use crate::domain::CTX_LOOKUP;
4#[cfg(feature = "seal")]
5use crate::domain::{CTX_RECORD, CTX_SEGMENT};
6use crate::error::Result;
7use crate::random;
8use crate::secret::secret_key;
9
10secret_key!(
11 RootKey
13);
14secret_key!(
15 LookupKey
17);
18#[cfg(feature = "seal")]
19secret_key!(
20 SegmentKey
22);
23#[cfg(feature = "seal")]
24secret_key!(
25 RecordKey
27);
28
29impl RootKey {
30 pub fn generate() -> Result<Self> {
32 random::array().map(Self)
33 }
34
35 pub fn lookup_key(&self) -> LookupKey {
36 LookupKey(blake3::derive_key(CTX_LOOKUP, &self.0))
37 }
38
39 #[cfg(feature = "seal")]
40 pub fn segment_key(&self) -> SegmentKey {
41 SegmentKey(blake3::derive_key(CTX_SEGMENT, &self.0))
42 }
43
44 #[cfg(feature = "seal")]
45 pub fn record_key(&self) -> RecordKey {
46 RecordKey(blake3::derive_key(CTX_RECORD, &self.0))
47 }
48}