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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
use c_void;
use c_int;
use null_mut;
use cratebindgen;
use crate*;
use crateEncryptionParameters;
use crateSecurityLevel;
/**
* Performs sanity checks (validation) and pre-computations for a given set of encryption
* parameters. While the EncryptionParameters class is intended to be a light-weight class
* to store the encryption parameters, the SEALContext class is a heavy-weight class that
* is constructed from a given set of encryption parameters. It validates the parameters
* for correctness, evaluates their properties, and performs and stores the results of
* several costly pre-computations.
*
* After the user has set at least the PolyModulus, CoeffModulus, and PlainModulus
* parameters in a given EncryptionParameters instance, the parameters can be validated
* for correctness and functionality by constructing an instance of SEALContext. The
* constructor of SEALContext does all of its work automatically, and concludes by
* constructing and storing an instance of the EncryptionParameterQualifiers class, with
* its flags set according to the properties of the given parameters. If the created
* instance of EncryptionParameterQualifiers has the ParametersSet flag set to true, the
* given parameter set has been deemed valid and is ready to be used. If the parameters
* were for some reason not appropriately set, the ParametersSet flag will be false,
* and a new SEALContext will have to be created after the parameters are corrected.
*
* By default, SEALContext creates a chain of SEALContext.ContextData instances. The
* first one in the chain corresponds to special encryption parameters that are reserved
* to be used by the various key classes (PrivateKey, PublicKey, etc.). These are the
* exact same encryption parameters that are created by the user and passed to the
* constructor of SEALContext. The properties KeyContextData and KeyParmsId return the
* ContextData and the ParmsId corresponding to these special parameters. The rest of the
* ContextData instances in the chain correspond to encryption parameters that are derived
* from the first encryption parameters by always removing the last one of the moduli in
* the CoeffModulus, until the resulting parameters are no longer valid, e.g., there are
* no more primes left. These derived encryption parameters are used by ciphertexts and
* plaintexts and their respective ContextData can be accessed through the
* GetContextData(ParmsId) function. The properties FirstContextData and LastContextData
* return the ContextData corresponding to the first and the last set of parameters in
* the "data" part of the chain, i.e., the second and the last element in the full chain.
* The chain is a doubly linked list and is referred to as the modulus switching chain.
*/
unsafe
unsafe