This repository has been archived by the owner on Dec 10, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
init_operations_example.py
51 lines (43 loc) · 1.77 KB
/
init_operations_example.py
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
import Aono
from Aono import *
keysgen = key_gen()
keys1 = keysgen.generate_key(100, 64, 40, 8, 4, 7)
message = 11
print "Plaintext message: " + str(message)
ct = ciphertext(create_message_matrix(message, 64), keys1.pk)
ct1 = ciphertext(create_message_matrix(3, 64), keys1.pk)
keys2 = keysgen.generate_key(100, 64, 20, 16, 4, 7)
keys3 = keysgen.generate_key(100, 64, 60, 16, 4, 7)
ukgen = updation_key_gen()
print "Reducing security with key switching"
uk = ukgen.generate_key(keys1, keys2)
a = uk.cipher_switch(ct)
print "Decrypted message: "
print_GEN(get_element(get_element(a.decrypt(keys2.sk), 0), 0))
print "Increasing security with key switching"
uk = ukgen.generate_key(keys1, keys3)
a = uk.cipher_switch(ct)
print "Decrypted message: "
print_GEN(get_element(get_element(a.decrypt(keys3.sk), 0), 0))
uk = ukgen.generate_key(keys1, keys3)
a = uk.cipher_switch(ct)
b = uk.cipher_switch(ct1)
ct = ciphertext(create_message_matrix(4, 64), keys3.pk)
print "Multiplying rotated-ciphertext with normal-ciphetext"
c = a * ct
print_GEN(get_element(get_element(c.decrypt(keys3.sk), 0), 0))
print "Adding mult-ciphertext with normal-ciphetext"
c1 = c + ct
print_GEN(get_element(get_element(c1.decrypt(keys3.sk), 0), 0))
print "Adding mult-ciphertext with nested normal-ciphetexts"
c2 = ct + (c1 + ct)
print_GEN(get_element(get_element(c2.decrypt(keys3.sk), 0), 0))
print "Adding mult-ciphertext with nested rotated-ciphetexts"
c2 = (c1 + a) + a
print_GEN(get_element(get_element(c2.decrypt(keys3.sk), 0), 0))
print "Adding rotated-ciphertext with normal-ciphetext"
c = (a + ct)
print_GEN(get_element(get_element(c.decrypt(keys3.sk), 0), 0))
print "Plaintext multiplication and adding rotated-ciphertext with normal-ciphetext"
c = (2 * a) + ct
print_GEN(get_element(get_element(c.decrypt(keys3.sk), 0), 0))