libcrux_secrets/int/
public_integers.rs

1/// This crate defines classification and declassification over public integers
2/// All functions and types here are transparent (identities) and have no performance impact
3use crate::traits::*;
4pub type I8 = i8;
5pub type U8 = u8;
6pub type I16 = i16;
7pub type U16 = u16;
8pub type I32 = i32;
9pub type U32 = u32;
10pub type I64 = i64;
11pub type U64 = u64;
12#[cfg(not(eurydice))]
13pub type I128 = i128;
14#[cfg(not(eurydice))]
15pub type U128 = u128;
16
17/// Construct a public integer (identity)
18#[inline(always)]
19pub const fn secret<T>(x: T) -> T {
20    x
21}
22
23// Classify any type (identity)
24impl<T> Classify for T {
25    type Classified = T;
26    #[inline(always)]
27    fn classify(self) -> Self {
28        self
29    }
30}
31
32// Delassify any type (identity)
33impl<T> Declassify for T {
34    type Declassified = T;
35    #[inline(always)]
36    fn declassify(self) -> T {
37        self
38    }
39}
40
41// Classify any reference (identity)
42impl<'a, T> ClassifyRef for &'a T {
43    type ClassifiedRef = &'a T;
44    #[inline(always)]
45    fn classify_ref(self) -> &'a T {
46        self
47    }
48}
49
50// Delassify any reference (identity)
51impl<'a, T> DeclassifyRef for &'a T {
52    type DeclassifiedRef = &'a T;
53    #[inline(always)]
54    fn declassify_ref(self) -> &'a T {
55        self
56    }
57}
58
59/// Classify a mutable slice (identity)
60/// We define a separate function for this because hax has limited support for &mut-returning functions
61#[inline(always)]
62pub fn classify_mut_slice<T>(x: T) -> T {
63    x
64}
65/// Classify a mutable slice (identity)
66/// We define a separate function for this because hax has limited support for &mut-returning functions
67#[inline(always)]
68pub fn declassify_mut_slice<T>(x: T) -> T {
69    x
70}