forked from JiangChSo/PFLM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
testVElGamal.py
81 lines (51 loc) · 845 Bytes
/
testVElGamal.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
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
'''
x1 = 1.1
x2 = 4.3
g = 2
p = 11
y1 = pow(g,x1)
y2 = pow(g,x2)
print(y1,y2)
print(y1*y2)
y = y1*y2%p
print(y)
y = pow(g,x1+x2)%p
print(y)
'''
from VElGamal import *
veg = VEG()
print(veg.get_params())
k_n1, Kn1 = veg.generate_keys()
print("k_n1, Kn1:",k_n1, Kn1)
#x_n1 = [1.1, 1.02, 2.36]
x_n1 = [1,2,3]
Cn1 = veg.enc(x_n1,k_n1)
print(Cn1)
k_n2, Kn2 = veg.generate_keys()
print("k_n2, Kn2:",k_n2, Kn2)
#x_n2 = [3.1, 0.52, 1.22]
x_n2 = [4,5,6]
Cn2 = veg.enc(x_n2,k_n2)
print(Cn2)
Kn_list = [Kn1,Kn2]
Cn_list = [Cn1, Cn2]
z_list = []
for i in range(len(x_n1)):
z_list.append(x_n1[i]+x_n2[i])
print(z_list)
bool = veg.elverify(Kn_list,Cn_list, z_list)
print(bool)
'''
x1 = 1.101
x2 = 4.323
g = 2
p = 11
y1 = pow(g,x1)
y2 = pow(g,x2)
print(y1,y2)
print(y1*y2)
y = y1*y2%p
print(y)
y = pow(g,x1+x2)%p
print(y)
'''