poulpy/core/src/encryption.rs
core/src/encryption.rsRaw
1use base2k::{Backend, Module, Scratch};
2use sampling::source::Source;
3
4pub trait EncryptSkScratchSpace {
5 fn encrypt_sk_scratch_space<B: Backend>(module: &Module<B>, ct_size: usize) -> usize;
6}
7
8pub trait EncryptSk<DataCt, DataPt, DataSk, B: Backend> {
9 type Ciphertext;
10 type Plaintext;
11 type SecretKey;
12
13 fn encrypt_sk(
14 &self,
15 module: &Module<B>,
16 ct: &mut Self::Ciphertext,
17 pt: &Self::Plaintext,
18 sk: &Self::SecretKey,
19 source_xa: &mut Source,
20 source_xe: &mut Source,
21 sigma: f64,
22 bound: f64,
23 scratch: &mut Scratch,
24 );
25}
26
27pub trait EncryptZeroSkScratchSpace {
28 fn encrypt_zero_sk_scratch_space<B: Backend>(module: &Module<B>, ct_size: usize) -> usize;
29}
30
31pub trait EncryptZeroSk<DatCt, DataSk, B: Backend> {
32 type Ciphertext;
33 type SecretKey;
34
35 fn encrypt_zero_sk(
36 &self,
37 module: &Module<B>,
38 ct: &mut Self::Ciphertext,
39 sk: &Self::SecretKey,
40 source_xa: &mut Source,
41 source_xe: &mut Source,
42 sigma: f64,
43 bound: f64,
44 scratch: &mut Scratch,
45 );
46}
47
48pub trait EncryptPkScratchSpace {
49 fn encrypt_pk_scratch_space<B: Backend>(module: &Module<B>, ct_size: usize) -> usize;
50}
51
52pub trait EncryptPk<DataCt, DataPt, DataPk, B: Backend> {
53 type Ciphertext;
54 type Plaintext;
55 type PublicKey;
56
57 fn encrypt_pk(
58 &self,
59 module: &Module<B>,
60 ct: &mut Self::Ciphertext,
61 pt: &Self::Plaintext,
62 pk: &Self::PublicKey,
63 source_xu: &mut Source,
64 source_xe: &mut Source,
65 sigma: f64,
66 bound: f64,
67 scratch: &mut Scratch,
68 );
69}
70
71pub trait EncryptZeroPkScratchSpace {
72 fn encrypt_zero_pk_scratch_space<B: Backend>(module: &Module<B>, ct_size: usize) -> usize;
73}
74
75pub trait EncryptZeroPk<DataCt, DataPk, B: Backend> {
76 type Ciphertext;
77 type PublicKey;
78
79 fn encrypt_zero_pk(
80 &self,
81 module: &Module<B>,
82 ct: &mut Self::Ciphertext,
83 pk: &Self::PublicKey,
84 source_xu: &mut Source,
85 source_xe: &mut Source,
86 sigma: f64,
87 bound: f64,
88 scratch: &mut Scratch,
89 );
90}
91
92pub trait Decrypt<DataPt, DataCt, DataSk, B: Backend> {
93 type Plaintext;
94 type Ciphertext;
95 type SecretKey;
96
97 fn decrypt(
98 &self,
99 module: &Module<B>,
100 pt: &mut Self::Plaintext,
101 ct: &Self::Ciphertext,
102 sk: &Self::SecretKey,
103 scratch: &mut Scratch,
104 );
105}