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
//! This module contains types to manage the different kinds of secret keys.
use serde::{Deserialize, Serialize};

/// This type is a marker for keys using binary elements as scalar.
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct BinaryKeyKind;
/// This type is a marker for keys using ternary elements as scalar.
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct TernaryKeyKind;
/// This type is a marker for keys using normaly sampled elements as scalar.
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct GaussianKeyKind;
/// This type is a marker for keys using uniformly sampled elements as scalar.
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct UniformKeyKind;

/// In concrete, secret keys can be based on different kinds of scalar values (put aside the
/// data type eventually used to store it in memory). This trait is implemented by marker types,
/// which are used to specify in the type system, what kind of keys we are currently using.
pub trait KeyKind: seal::SealedKeyKind + Sync + Clone {}

impl KeyKind for BinaryKeyKind {}
impl KeyKind for TernaryKeyKind {}
impl KeyKind for GaussianKeyKind {}
impl KeyKind for UniformKeyKind {}

mod seal {
    pub trait SealedKeyKind {}
    impl SealedKeyKind for super::BinaryKeyKind {}
    impl SealedKeyKind for super::TernaryKeyKind {}
    impl SealedKeyKind for super::GaussianKeyKind {}
    impl SealedKeyKind for super::UniformKeyKind {}
}