IEEE Computational Intelligence Magazine - August 2022 - 20

To create polynomials the function Poly is used; it accepts a
dictionary of coefficients, and returns the corresponding
NumPy polynomial. NumPy polynomials implement the basic
operations of polynomial additions, multiplications, and evaluation
among others.
For instance, the cyclotomic polynomial
U which is used16 ,
in the following operations, is generated as follows:
cyclotomic_poly = Poly({0: 1, 16: 1})
print(cyclotomic_poly)
------------------------------------------X**16
+ 1
The function GENERATE_KEYS generates a pair of public
and secret keys (ks, kp) according to Eq. (2), given .H
ks, kp = generate_keys(theta)
print( " Secret key: " + ks)
print( " Public key: " + kp)
------------------------------------------Secret
key: X**15 - X**14 - X**13 - X**12 + X
**11 + X**10 - X**9 - X**8 - X**7 + X**6 -
X**5 + X**4 - X**3 - X**2 + 1
Public key: 61199X**15 + 48133X**14 +... +
62895X**2 + 113586X + 92746, 80534X**15 +
36864X**14 + ... + 27318X**2 + 35006X +
72552
It is now possible to encode and encrypt the two values of
m 71
= and m .22
=
An example of addition and multiplication
is provided as follows.
First, the two values must be encoded as specified in Section
II-B. To achieve this, the function ENCODE_BINARY takes as
input an unsigned integer and returns the corresponding polynomial
encoded with binary encoding. The DECODE_BINARY
function is defined accordingly.
m1 = encode_binary(7)
m2 = encode_binary(2)
print( " m1: " + m1)
print( " m2: " + m2)
------------------------------------------m1:
X**2 + X + 1
m2: X
After the values have been encoded in polynomial form, it
is possible to proceed with the encryption. First, the
ENCRYPT_POLY function creates a ciphertext mu
that starts
from an encoded polynomial m . To this end, random polynomials
ee u12
,,
following Eq. (3).
20 IEEE COMPUTATIONAL INTELLIGENCE MAGAZINE | AUGUST 2022
are generated and the ciphertext is created
enc_m1 = encrypt_poly(m1, kp, theta)
enc_m2 = encrypt_poly(m2, kp, theta)
print( " enc_m1: " + enc_m1)
print( " enc_m2: " + enc_m2)
------------------------------------------enc_m1:
74404X**15 + 9539X**14 + ... + 27250X
**2 + 64856X + 51090, 121602X**15 + 100582
X**14 + ... + 60289X**2 + 80948X + 13677
enc_m2: 14068X**15 + 6425X**14 + ... + 23691X
**2 + 53327X + 52978, 100091X**15 + 85920X
**14 + ... + 16044X**2 + 51146X + 117168
Notably, after the encryption, the coefficients of the involved
polynomials are now modulo q, that is in the range [, ).q0
maximum degree of the polynomials is 15, as this work is
being conducted in the modulo 16
U space.
It is now possible to sum up the two ciphertexts. The function
ADD_CIPHERTEXTS simply computes the element-wise
sum of the two ciphertexts while applying the modulus operations,
as specified in Eq. (7).
enc_sum = add_ciphertexts(enc_m1, enc_m2)
print( " Sum ciphertext: " + enc_sum)
------------------------------------------Sum
ciphertext: 88472X**15 + 15964X**14 + ...
+ 50941X**2 + 118183X + 104068, 97581X**15
+ 62390X**14 + ... + 76333X**2 + 7982X +
6733
Finally, the result of the addition can be decrypted. For this
purpose, the function DECRYPT_POLY, implemented according
to Eq. (4), can be used as follows:
decrypted = decrypt_poly(enc_sum, ks, theta)
decoded = decode_binary(decrypted)
print( " Decrypted encoded result: " +
decrypted)
print( " Decoded result: " + decoded))
------------------------------------------Decrypted
encoded result: X**2 + 2X + 1
Decoded result: 9
The result is the same as the result that would have been
obtained on plain data. The same holds for multiplications. To
this end, the function MUL_CIPHERTEXTS is defined. Note
that the function will return a three-terms ciphertext, as
depicted in Eq. (8).
The

IEEE Computational Intelligence Magazine - August 2022

Table of Contents for the Digital Edition of IEEE Computational Intelligence Magazine - August 2022

Contents
IEEE Computational Intelligence Magazine - August 2022 - Cover1
IEEE Computational Intelligence Magazine - August 2022 - Cover2
IEEE Computational Intelligence Magazine - August 2022 - Contents
IEEE Computational Intelligence Magazine - August 2022 - 2
IEEE Computational Intelligence Magazine - August 2022 - 3
IEEE Computational Intelligence Magazine - August 2022 - 4
IEEE Computational Intelligence Magazine - August 2022 - 5
IEEE Computational Intelligence Magazine - August 2022 - 6
IEEE Computational Intelligence Magazine - August 2022 - 7
IEEE Computational Intelligence Magazine - August 2022 - 8
IEEE Computational Intelligence Magazine - August 2022 - 9
IEEE Computational Intelligence Magazine - August 2022 - 10
IEEE Computational Intelligence Magazine - August 2022 - 11
IEEE Computational Intelligence Magazine - August 2022 - 12
IEEE Computational Intelligence Magazine - August 2022 - 13
IEEE Computational Intelligence Magazine - August 2022 - 14
IEEE Computational Intelligence Magazine - August 2022 - 15
IEEE Computational Intelligence Magazine - August 2022 - 16
IEEE Computational Intelligence Magazine - August 2022 - 17
IEEE Computational Intelligence Magazine - August 2022 - 18
IEEE Computational Intelligence Magazine - August 2022 - 19
IEEE Computational Intelligence Magazine - August 2022 - 20
IEEE Computational Intelligence Magazine - August 2022 - 21
IEEE Computational Intelligence Magazine - August 2022 - 22
IEEE Computational Intelligence Magazine - August 2022 - 23
IEEE Computational Intelligence Magazine - August 2022 - 24
IEEE Computational Intelligence Magazine - August 2022 - 25
IEEE Computational Intelligence Magazine - August 2022 - 26
IEEE Computational Intelligence Magazine - August 2022 - 27
IEEE Computational Intelligence Magazine - August 2022 - 28
IEEE Computational Intelligence Magazine - August 2022 - 29
IEEE Computational Intelligence Magazine - August 2022 - 30
IEEE Computational Intelligence Magazine - August 2022 - 31
IEEE Computational Intelligence Magazine - August 2022 - 32
IEEE Computational Intelligence Magazine - August 2022 - 33
IEEE Computational Intelligence Magazine - August 2022 - 34
IEEE Computational Intelligence Magazine - August 2022 - 35
IEEE Computational Intelligence Magazine - August 2022 - 36
IEEE Computational Intelligence Magazine - August 2022 - 37
IEEE Computational Intelligence Magazine - August 2022 - 38
IEEE Computational Intelligence Magazine - August 2022 - 39
IEEE Computational Intelligence Magazine - August 2022 - 40
IEEE Computational Intelligence Magazine - August 2022 - 41
IEEE Computational Intelligence Magazine - August 2022 - 42
IEEE Computational Intelligence Magazine - August 2022 - 43
IEEE Computational Intelligence Magazine - August 2022 - 44
IEEE Computational Intelligence Magazine - August 2022 - 45
IEEE Computational Intelligence Magazine - August 2022 - 46
IEEE Computational Intelligence Magazine - August 2022 - 47
IEEE Computational Intelligence Magazine - August 2022 - 48
IEEE Computational Intelligence Magazine - August 2022 - 49
IEEE Computational Intelligence Magazine - August 2022 - 50
IEEE Computational Intelligence Magazine - August 2022 - 51
IEEE Computational Intelligence Magazine - August 2022 - 52
IEEE Computational Intelligence Magazine - August 2022 - 53
IEEE Computational Intelligence Magazine - August 2022 - 54
IEEE Computational Intelligence Magazine - August 2022 - 55
IEEE Computational Intelligence Magazine - August 2022 - 56
IEEE Computational Intelligence Magazine - August 2022 - 57
IEEE Computational Intelligence Magazine - August 2022 - 58
IEEE Computational Intelligence Magazine - August 2022 - 59
IEEE Computational Intelligence Magazine - August 2022 - 60
IEEE Computational Intelligence Magazine - August 2022 - 61
IEEE Computational Intelligence Magazine - August 2022 - 62
IEEE Computational Intelligence Magazine - August 2022 - 63
IEEE Computational Intelligence Magazine - August 2022 - 64
IEEE Computational Intelligence Magazine - August 2022 - 65
IEEE Computational Intelligence Magazine - August 2022 - 66
IEEE Computational Intelligence Magazine - August 2022 - 67
IEEE Computational Intelligence Magazine - August 2022 - 68
IEEE Computational Intelligence Magazine - August 2022 - Cover3
IEEE Computational Intelligence Magazine - August 2022 - Cover4
https://www.nxtbook.com/nxtbooks/ieee/computationalintelligence_202311
https://www.nxtbook.com/nxtbooks/ieee/computationalintelligence_202308
https://www.nxtbook.com/nxtbooks/ieee/computationalintelligence_202305
https://www.nxtbook.com/nxtbooks/ieee/computationalintelligence_202302
https://www.nxtbook.com/nxtbooks/ieee/computationalintelligence_202211
https://www.nxtbook.com/nxtbooks/ieee/computationalintelligence_202208
https://www.nxtbook.com/nxtbooks/ieee/computationalintelligence_202205
https://www.nxtbook.com/nxtbooks/ieee/computationalintelligence_202202
https://www.nxtbook.com/nxtbooks/ieee/computationalintelligence_202111
https://www.nxtbook.com/nxtbooks/ieee/computationalintelligence_202108
https://www.nxtbook.com/nxtbooks/ieee/computationalintelligence_202105
https://www.nxtbook.com/nxtbooks/ieee/computationalintelligence_202102
https://www.nxtbook.com/nxtbooks/ieee/computationalintelligence_202011
https://www.nxtbook.com/nxtbooks/ieee/computationalintelligence_202008
https://www.nxtbook.com/nxtbooks/ieee/computationalintelligence_202005
https://www.nxtbook.com/nxtbooks/ieee/computationalintelligence_202002
https://www.nxtbook.com/nxtbooks/ieee/computationalintelligence_201911
https://www.nxtbook.com/nxtbooks/ieee/computationalintelligence_201908
https://www.nxtbook.com/nxtbooks/ieee/computationalintelligence_201905
https://www.nxtbook.com/nxtbooks/ieee/computationalintelligence_201902
https://www.nxtbook.com/nxtbooks/ieee/computationalintelligence_201811
https://www.nxtbook.com/nxtbooks/ieee/computationalintelligence_201808
https://www.nxtbook.com/nxtbooks/ieee/computationalintelligence_201805
https://www.nxtbook.com/nxtbooks/ieee/computationalintelligence_201802
https://www.nxtbook.com/nxtbooks/ieee/computational_intelligence_winter17
https://www.nxtbook.com/nxtbooks/ieee/computational_intelligence_fall17
https://www.nxtbook.com/nxtbooks/ieee/computational_intelligence_summer17
https://www.nxtbook.com/nxtbooks/ieee/computational_intelligence_spring17
https://www.nxtbook.com/nxtbooks/ieee/computational_intelligence_winter16
https://www.nxtbook.com/nxtbooks/ieee/computational_intelligence_fall16
https://www.nxtbook.com/nxtbooks/ieee/computational_intelligence_summer16
https://www.nxtbook.com/nxtbooks/ieee/computational_intelligence_spring16
https://www.nxtbook.com/nxtbooks/ieee/computational_intelligence_winter15
https://www.nxtbook.com/nxtbooks/ieee/computational_intelligence_fall15
https://www.nxtbook.com/nxtbooks/ieee/computational_intelligence_summer15
https://www.nxtbook.com/nxtbooks/ieee/computational_intelligence_spring15
https://www.nxtbook.com/nxtbooks/ieee/computational_intelligence_winter14
https://www.nxtbook.com/nxtbooks/ieee/computational_intelligence_fall14
https://www.nxtbook.com/nxtbooks/ieee/computational_intelligence_summer14
https://www.nxtbook.com/nxtbooks/ieee/computational_intelligence_spring14
https://www.nxtbook.com/nxtbooks/ieee/computational_intelligence_winter13
https://www.nxtbook.com/nxtbooks/ieee/computational_intelligence_fall13
https://www.nxtbook.com/nxtbooks/ieee/computational_intelligence_summer13
https://www.nxtbook.com/nxtbooks/ieee/computational_intelligence_spring13
https://www.nxtbook.com/nxtbooks/ieee/computational_intelligence_winter12
https://www.nxtbook.com/nxtbooks/ieee/computational_intelligence_fall12
https://www.nxtbookmedia.com