@@ -8,39 +8,185 @@ extern "C" {
8
8
#include "Channel.h"
9
9
#include "Polynomial.h"
10
10
11
- #define EPROB 0.5
12
-
11
+ /**
12
+ * @brief Represents the public key for the arithmetic channel.
13
+ *
14
+ * This structure represents the public key for the arithmetic channel,
15
+ * consisting of the polynomial 'u' and 3D matrix 'lambda'.
16
+ *
17
+ * @param u Polynomial representing the parameter 'u'.
18
+ * @param lambda 3D matrix representing intermediate values. Each element
19
+ * λ[k][i][j] in the matrix corresponds to the coefficients of the generated
20
+ * secret key.
21
+ */
13
22
typedef struct {
14
23
Polynomial u ;
15
- Lambda lambda ;
24
+ Matrix3D lambda ;
16
25
} PublicKey ;
17
26
27
+ /**
28
+ * @brief Represents the private key for the arithmetic channel.
29
+ *
30
+ * This structure represents the private key for the arithmetic channel,
31
+ * consisting of the polynomial array 'x', polynomial array 'f0', and polynomial
32
+ * 'f1'.
33
+ *
34
+ * @param x Polynomial array representing the secret key.
35
+ * @param f0 Polynomial array representing the public key component 'f0'.
36
+ * @param f1 Polynomial representing the public key component 'f1'.
37
+ */
18
38
typedef struct {
19
39
PolyArray x ;
20
40
PolyArray f0 ;
21
41
Polynomial f1 ;
22
42
} PrivateKey ;
23
43
44
+ /**
45
+ * @brief Represents the shared information for the arithmetic channel.
46
+ *
47
+ * This structure represents the shared information for the arithmetic channel,
48
+ * including the channel parameters, public key, and other necessary parameters.
49
+ *
50
+ * @param channel The arithmetic channel.
51
+ * @param param Parameters for the arithmetic channel.
52
+ * @param pk Public key for the arithmetic channel.
53
+ */
24
54
typedef struct {
25
55
Channel channel ;
26
56
Parameters param ;
27
57
PublicKey pk ;
28
58
} SharedInfo ;
29
59
60
+ /**
61
+ * @brief Represents an instance of the ACES (Arithmetic Channel Encryption
62
+ * Scheme).
63
+ *
64
+ * This structure represents an instance of the Arithmetic Channel Encryption
65
+ * Scheme (ACES), including shared information and private key components.
66
+ *
67
+ * @param shared_info Shared information for the ACES instance.
68
+ * @param private_key Private key components for the ACES instance.
69
+ */
30
70
typedef struct {
31
- SharedInfo info ;
32
- PrivateKey privte_key ;
71
+ SharedInfo shared_info ;
72
+ PrivateKey private_key ;
33
73
} Aces ;
34
74
75
+ /**
76
+ * @brief Represents a ciphertext in the ACES framework.
77
+ *
78
+ * The ACES framework encrypts a message m ∈ ℤₚ as a ciphertext (c,c') according
79
+ * to the following procedure:
80
+ *
81
+ * 1. The first component c is an n-vector over ℤ_q[X]_u given by c = f₀ᵀb,
82
+ * where:
83
+ * - f₀ is an n × N matrix over ℤ_q[X]_u (chosen during key generation).
84
+ * - b = (bᵢ)ᵢ is an N-vector over ℤ_q[X]_u such that bᵢ(ω) ∈ {0,1,…,p}
85
+ * (selected by the sender).
86
+ *
87
+ * 2. The second component c' is an element of ℤ_q[X] defined as
88
+ * c' = r_m + cᵀx + e, where:
89
+ * - r_m is an element over ℤ_q[X]_u chosen such that its evaluation in ℤ_q
90
+ * at the integer ω equals m (chosen by the sender).
91
+ * - x is an n-vector over ℤ_q[X]_u (considered the private key).
92
+ * - e is a scalar product in the form of bᵀe', where e' = (eᵢ')ᵢ is an
93
+ * N-vector over ℤ_q[X]_u such that the evaluation of eᵢ' in ℤ_q at the integer
94
+ * ω is equal to a product pℓ where ℓ ∈ {0,1}.
95
+ *
96
+ * @param c1 First component of the ciphertext, represented as a polynomial
97
+ * array.
98
+ * @param c2 Second component of the ciphertext, represented as a polynomial.
99
+ * @param level The level parameter associated with the ciphertext.
100
+ */
35
101
typedef struct {
36
102
PolyArray c1 ;
37
103
Polynomial c2 ;
38
104
uint64_t level ;
39
105
} CipherMessage ;
40
106
41
- int aces_encrypt (const Aces * , const uint64_t * , size_t , CipherMessage * );
107
+ /**
108
+ * @brief Initializes an instance of the ACES (Arithmetic Channel Encryption
109
+ * Scheme).
110
+ *
111
+ * @param p Parameter p for the ACES channel.
112
+ * @param q Parameter q for the ACES channel.
113
+ * @param dim Dimension of the ACES parameters.
114
+ * @param[out] aces Pointer to the ACES structure to be initialized.
115
+ * @return int Returns 0 upon successful initialization, or an error code
116
+ * otherwise.
117
+ */
118
+ int init_aces (uint64_t p , uint64_t q , uint64_t dim , Aces * aces );
119
+
120
+ /**
121
+ * @brief Encrypts a message using the ACES (Arithmetic Channel Encryption
122
+ * Scheme).
123
+ *
124
+ * @param aces Pointer to the initialized ACES structure.
125
+ * @param message Pointer to the message to be encrypted.
126
+ * @param size Size of the message array.
127
+ * @param[out] result Pointer to the structure where the ciphertext will be
128
+ * stored.
129
+ * @return int Returns 0 upon successful encryption, or an error code otherwise.
130
+ */
131
+ int aces_encrypt (const Aces * aces , const uint64_t * message , size_t size ,
132
+ CipherMessage * result );
133
+
134
+ /**
135
+ * @brief Decrypts a ciphertext using the ACES (Arithmetic Channel Encryption
136
+ * Scheme).
137
+ *
138
+ * @param aces Pointer to the initialized ACES structure.
139
+ * @param message Pointer to the ciphertext to be decrypted.
140
+ * @param size Size of the ciphertext array.
141
+ * @param[out] result Pointer to the array where the decrypted message will be
142
+ * stored.
143
+ * @return int Returns 0 upon successful decryption, or an error code otherwise.
144
+ */
145
+ int aces_decrypt (const Aces * aces , const CipherMessage * message , size_t size ,
146
+ uint64_t * result );
147
+
148
+ /**
149
+ * @brief Performs addition on two ciphertexts encrypted under the ACES scheme.
150
+ *
151
+ * @param a Pointer to the first ciphertext.
152
+ * @param b Pointer to the second ciphertext.
153
+ * @param info Pointer to the shared information including parameters and keys.
154
+ * @param[out] result Pointer to the structure where the result of addition will
155
+ * be stored.
156
+ * @return int Returns 0 upon successful addition, or an error code otherwise.
157
+ */
158
+ int aces_add (const CipherMessage * , const CipherMessage * , const SharedInfo * ,
159
+ CipherMessage * );
160
+
161
+ /**
162
+ * @brief Performs multiplication on two ciphertexts encrypted under the ACES
163
+ * scheme.
164
+ *
165
+ * @param a Pointer to the first ciphertext.
166
+ * @param b Pointer to the second ciphertext.
167
+ * @param info Pointer to the shared information including parameters and keys.
168
+ * @param[out] result Pointer to the structure where the result of
169
+ * multiplication will be stored.
170
+ * @return int Returns 0 upon successful multiplication, or an error code
171
+ * otherwise.
172
+ */
173
+ int aces_mul (const CipherMessage * , const CipherMessage * , const SharedInfo * ,
174
+ CipherMessage * );
42
175
43
- int aces_decrypt (const Aces * , const CipherMessage * , size_t size , uint64_t * );
176
+ /**
177
+ * @brief Refreshes a ciphertext to mitigate level increase resulting from
178
+ * arithmetic operations.
179
+ *
180
+ * ACES is a fully homomorphic encryption scheme that initially relies on a
181
+ * leveled FHE framework. This function is designed to refresh a ciphertext,
182
+ * mitigating the level increase resulting from arithmetic operations.
183
+ *
184
+ * @param info Pointer to the shared information including parameters and keys.
185
+ * @param[in,out] message Pointer to the ciphertext to be refreshed.
186
+ * @param level The desired level of the refreshed ciphertext.
187
+ * @return int Returns 0 upon successful refresh, or an error code otherwise.
188
+ */
189
+ int aces_refresh (const SharedInfo * info , CipherMessage * a , uint64_t k );
44
190
45
191
#ifdef __cplusplus
46
192
}
0 commit comments