@@ -15,8 +15,8 @@ use alloc::vec::Vec;
15
15
/// ## Examples
16
16
///
17
17
/// ```
18
- /// use homomorph::Parameters;
19
- ///
18
+ /// # use homomorph::Parameters;
19
+ /// #
20
20
/// let parameters = Parameters::new(6, 3, 2, 5);
21
21
/// ```
22
22
///
@@ -38,6 +38,7 @@ pub struct SecretKeyUnset;
38
38
39
39
impl Parameters {
40
40
#[ must_use]
41
+ #[ inline]
41
42
/// Creates a new set of parameters.
42
43
///
43
44
/// ## Arguments
@@ -64,8 +65,8 @@ impl Parameters {
64
65
/// ## Examples
65
66
///
66
67
/// ```
67
- /// use homomorph::Parameters;
68
- ///
68
+ /// # use homomorph::Parameters;
69
+ /// #
69
70
/// let parameters = Parameters::new(6, 3, 2, 5);
70
71
/// ```
71
72
pub const fn new ( d : u16 , dp : u16 , delta : u16 , tau : u16 ) -> Self {
@@ -78,21 +79,25 @@ impl Parameters {
78
79
}
79
80
80
81
#[ must_use]
82
+ #[ inline]
81
83
pub const fn d ( & self ) -> u16 {
82
84
self . d
83
85
}
84
86
85
87
#[ must_use]
88
+ #[ inline]
86
89
pub const fn dp ( & self ) -> u16 {
87
90
self . dp
88
91
}
89
92
90
93
#[ must_use]
94
+ #[ inline]
91
95
pub const fn delta ( & self ) -> u16 {
92
96
self . delta
93
97
}
94
98
95
99
#[ must_use]
100
+ #[ inline]
96
101
pub const fn tau ( & self ) -> u16 {
97
102
self . tau
98
103
}
@@ -104,6 +109,7 @@ pub struct SecretKey(Polynomial);
104
109
105
110
impl SecretKey {
106
111
#[ must_use]
112
+ #[ inline]
107
113
/// Creates a new secret key.
108
114
///
109
115
/// ## Arguments
@@ -122,8 +128,8 @@ impl SecretKey {
122
128
/// ## Examples
123
129
///
124
130
/// ```
125
- /// use homomorph::SecretKey;
126
- ///
131
+ /// # use homomorph::SecretKey;
132
+ /// #
127
133
/// // INSECURE!!! Only for demonstration purposes
128
134
/// let s = vec![5, 14, 8];
129
135
///
@@ -134,16 +140,20 @@ impl SecretKey {
134
140
}
135
141
136
142
#[ must_use]
143
+ #[ inline]
137
144
/// Generates a random secret key of the given degree
138
145
fn random ( d : u16 ) -> Self {
139
146
Self ( Polynomial :: random ( d as usize ) )
140
147
}
141
148
149
+ #[ must_use]
150
+ #[ inline]
142
151
pub ( crate ) const fn get_polynomial ( & self ) -> & Polynomial {
143
152
& self . 0
144
153
}
145
154
146
155
#[ must_use]
156
+ #[ inline]
147
157
/// Returns bytes representing the secret key.
148
158
///
149
159
/// ## Returns
@@ -157,8 +167,8 @@ impl SecretKey {
157
167
/// ## Examples
158
168
///
159
169
/// ```
160
- /// use homomorph::{Context, Parameters};
161
- ///
170
+ /// # use homomorph::{Context, Parameters};
171
+ /// #
162
172
/// let mut context = Context::new(Parameters::new(6, 3, 2, 5));
163
173
/// context.generate_secret_key();
164
174
///
@@ -204,8 +214,8 @@ impl PublicKey {
204
214
/// ## Examples
205
215
///
206
216
/// ```
207
- /// use homomorph::PublicKey;
208
- ///
217
+ /// # use homomorph::PublicKey;
218
+ /// #
209
219
/// // INSECURE!!! Only for demonstration purposes
210
220
/// let p = vec![vec![4, 7, 5], vec![1, 2, 3], vec![5, 4, 6]];
211
221
///
@@ -235,6 +245,8 @@ impl PublicKey {
235
245
Self ( list. into_boxed_slice ( ) )
236
246
}
237
247
248
+ #[ must_use]
249
+ #[ inline]
238
250
pub ( crate ) const fn get_polynomials ( & self ) -> & [ Polynomial ] {
239
251
& self . 0
240
252
}
@@ -253,8 +265,8 @@ impl PublicKey {
253
265
/// ## Examples
254
266
///
255
267
/// ```
256
- /// use homomorph::{Context, Parameters};
257
- ///
268
+ /// # use homomorph::{Context, Parameters};
269
+ /// #
258
270
/// let mut context = Context::new(Parameters::new(6, 3, 2, 5));
259
271
/// context.generate_secret_key();
260
272
/// context.generate_public_key().unwrap();
@@ -280,6 +292,7 @@ pub struct Context {
280
292
281
293
impl Context {
282
294
#[ must_use]
295
+ #[ inline]
283
296
/// Creates a new context.
284
297
///
285
298
/// ## Arguments
@@ -293,8 +306,8 @@ impl Context {
293
306
/// ## Examples
294
307
///
295
308
/// ```
296
- /// use homomorph::{Context, Parameters};
297
- ///
309
+ /// # use homomorph::{Context, Parameters};
310
+ /// #
298
311
/// let params = Parameters::new(6, 3, 2, 5);
299
312
/// let mut context = Context::new(params);
300
313
/// ```
@@ -307,11 +320,13 @@ impl Context {
307
320
}
308
321
309
322
#[ must_use]
323
+ #[ inline]
310
324
pub const fn parameters ( & self ) -> & Parameters {
311
325
& self . parameters
312
326
}
313
327
314
328
#[ must_use]
329
+ #[ inline]
315
330
/// Returns a reference to the secret key.
316
331
///
317
332
/// ## Returns
@@ -321,8 +336,8 @@ impl Context {
321
336
/// ## Examples
322
337
///
323
338
/// ```
324
- /// use homomorph::{Context, Parameters};
325
- ///
339
+ /// # use homomorph::{Context, Parameters};
340
+ /// #
326
341
/// let params = Parameters::new(6, 3, 2, 5);
327
342
/// let mut context = Context::new(params);
328
343
/// context.generate_secret_key();
@@ -333,6 +348,7 @@ impl Context {
333
348
}
334
349
335
350
#[ must_use]
351
+ #[ inline]
336
352
/// Returns a reference to the public key.
337
353
///
338
354
/// ## Returns
@@ -342,8 +358,8 @@ impl Context {
342
358
/// ## Examples
343
359
///
344
360
/// ```
345
- /// use homomorph::{Context, Parameters};
346
- ///
361
+ /// # use homomorph::{Context, Parameters};
362
+ /// #
347
363
/// let params = Parameters::new(6, 3, 2, 5);
348
364
/// let mut context = Context::new(params);
349
365
/// context.generate_secret_key();
@@ -354,6 +370,7 @@ impl Context {
354
370
self . public_key . as_ref ( )
355
371
}
356
372
373
+ #[ inline]
357
374
/// Generates a secret key.
358
375
///
359
376
/// ## Note
@@ -363,8 +380,8 @@ impl Context {
363
380
/// ## Examples
364
381
///
365
382
/// ```
366
- /// use homomorph::{Context, Parameters};
367
- ///
383
+ /// # use homomorph::{Context, Parameters};
384
+ /// #
368
385
/// let params = Parameters::new(6, 3, 2, 5);
369
386
/// let mut context = Context::new(params);
370
387
///
@@ -375,6 +392,7 @@ impl Context {
375
392
self . public_key = None ;
376
393
}
377
394
395
+ #[ inline]
378
396
/// Generates a public key out of the private key.
379
397
///
380
398
/// ## Errors
@@ -384,8 +402,8 @@ impl Context {
384
402
/// ## Examples
385
403
///
386
404
/// ```
387
- /// use homomorph::{Context, Parameters};
388
- ///
405
+ /// # use homomorph::{Context, Parameters};
406
+ /// #
389
407
/// let params = Parameters::new(6, 3, 2, 5);
390
408
/// let mut context = Context::new(params);
391
409
/// context.generate_secret_key();
@@ -403,6 +421,7 @@ impl Context {
403
421
Ok ( ( ) )
404
422
}
405
423
424
+ #[ inline]
406
425
/// Explicitly sets the secret key.
407
426
///
408
427
/// ## Arguments
@@ -412,8 +431,8 @@ impl Context {
412
431
/// ## Examples
413
432
///
414
433
/// ```
415
- /// use homomorph::{Context, Parameters, SecretKey};
416
- ///
434
+ /// # use homomorph::{Context, Parameters, SecretKey};
435
+ /// #
417
436
/// let mut context = Context::new(Parameters::new(6, 3, 2, 5));
418
437
///
419
438
/// // INSECURE!!! Only for demonstration purposes
@@ -426,6 +445,7 @@ impl Context {
426
445
self . secret_key = Some ( secret_key) ;
427
446
}
428
447
448
+ #[ inline]
429
449
/// Explicitly sets the public key.
430
450
///
431
451
/// ## Arguments
@@ -435,8 +455,8 @@ impl Context {
435
455
/// ## Examples
436
456
///
437
457
/// ```
438
- /// use homomorph::{Context, Parameters, PublicKey};
439
- ///
458
+ /// # use homomorph::{Context, Parameters, PublicKey};
459
+ /// #
440
460
/// let mut context = Context::new(Parameters::new(6, 3, 2, 5));
441
461
///
442
462
/// // INSECURE!!! Only for demonstration purposes
0 commit comments