1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
use crate::commons::crypto::secret::LweSecretKey as ImpLweSecretKey;
use crate::prelude::{BinaryKeyKind, LweDimension};
use crate::specification::entities::markers::LweSecretKeyKind;
use crate::specification::entities::{AbstractEntity, LweSecretKeyEntity};
#[cfg(feature = "backend_default_serialization")]
use serde::{Deserialize, Serialize};

/// A structure representing an LWE secret key with 32 bits of precision.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct LweSecretKey32(pub(crate) ImpLweSecretKey<BinaryKeyKind, Vec<u32>>);
impl AbstractEntity for LweSecretKey32 {
    type Kind = LweSecretKeyKind;
}
impl LweSecretKeyEntity for LweSecretKey32 {
    fn lwe_dimension(&self) -> LweDimension {
        self.0.key_size()
    }
}

#[cfg(feature = "backend_default_serialization")]
#[derive(Serialize, Deserialize)]
pub(crate) enum LweSecretKey32Version {
    V0,
    #[serde(other)]
    Unsupported,
}

/// A structure representing an LWE secret key with 64 bits of precision.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct LweSecretKey64(pub(crate) ImpLweSecretKey<BinaryKeyKind, Vec<u64>>);
impl AbstractEntity for LweSecretKey64 {
    type Kind = LweSecretKeyKind;
}
impl LweSecretKeyEntity for LweSecretKey64 {
    fn lwe_dimension(&self) -> LweDimension {
        self.0.key_size()
    }
}

#[cfg(feature = "backend_default_serialization")]
#[derive(Serialize, Deserialize)]
pub(crate) enum LweSecretKey64Version {
    V0,
    #[serde(other)]
    Unsupported,
}