Skip to main content

airbender_host/
security.rs

1/// Cryptographic security target for real Airbender proofs.
2///
3/// Airbender exposes 80-bit and 100-bit security as independent proving modes.
4/// The host SDK keeps that choice explicit in the proof and verification-key
5/// envelopes so callers cannot accidentally verify a proof with artifacts built
6/// for a different security target.
7#[derive(
8    Clone, Copy, Debug, Default, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize,
9)]
10pub enum SecurityLevel {
11    /// Use the 80-bit security configuration.
12    Bits80,
13    /// Use the 100-bit security configuration.
14    #[default]
15    Bits100,
16}
17
18impl SecurityLevel {
19    pub fn bits(self) -> u16 {
20        match self {
21            Self::Bits80 => 80,
22            Self::Bits100 => 100,
23        }
24    }
25}
26
27impl From<SecurityLevel> for verifier_common::SecurityModel {
28    fn from(security: SecurityLevel) -> Self {
29        match security {
30            SecurityLevel::Bits80 => Self::Security80,
31            SecurityLevel::Bits100 => Self::Security100,
32        }
33    }
34}
35
36impl std::fmt::Display for SecurityLevel {
37    fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
38        write!(formatter, "{}", self.bits())
39    }
40}