use crate::domain::CTX_LOOKUP;
#[cfg(feature = "seal")]
use crate::domain::{CTX_RECORD, CTX_SEGMENT};
use crate::error::Result;
use crate::random;
use crate::secret::secret_key;
secret_key!(
RootKey
);
secret_key!(
LookupKey
);
#[cfg(feature = "seal")]
secret_key!(
SegmentKey
);
#[cfg(feature = "seal")]
secret_key!(
RecordKey
);
impl RootKey {
pub fn generate() -> Result<Self> {
random::array().map(Self)
}
pub fn lookup_key(&self) -> LookupKey {
LookupKey(blake3::derive_key(CTX_LOOKUP, &self.0))
}
#[cfg(feature = "seal")]
pub fn segment_key(&self) -> SegmentKey {
SegmentKey(blake3::derive_key(CTX_SEGMENT, &self.0))
}
#[cfg(feature = "seal")]
pub fn record_key(&self) -> RecordKey {
RecordKey(blake3::derive_key(CTX_RECORD, &self.0))
}
}