add present files
This commit is contained in:
parent
de1d75360b
commit
0827b14ff2
23
line_present.py
Normal file
23
line_present.py
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import CoreAlgorithm as paillier
|
||||||
|
from line_profiler import profile
|
||||||
|
|
||||||
|
# kernprof -l line_present.py
|
||||||
|
|
||||||
|
@profile
|
||||||
|
def main():
|
||||||
|
Public_Key, Private_Key = paillier.generate_paillier_keypair() # 随机生成1024长的公钥和私钥
|
||||||
|
x = 90000.23
|
||||||
|
y = 90
|
||||||
|
z = 0.5
|
||||||
|
x_encrypted = Public_Key.encrypt(x) # 加密后的x
|
||||||
|
y_encrypted = Public_Key.encrypt(y) # 加密后的y
|
||||||
|
z_encrypted = Public_Key.encrypt(z) # 加密后的z
|
||||||
|
t_encrypted = (
|
||||||
|
x_encrypted + y_encrypted * 0.5
|
||||||
|
)
|
||||||
|
|
||||||
|
print(f"x + y * 0.5的结果是:{Private_Key.decrypt(t_encrypted)}") # 打印出t
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__": # 主函数
|
||||||
|
main()
|
23
mem_present.py
Normal file
23
mem_present.py
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import CoreAlgorithm as paillier
|
||||||
|
from memory_profiler import profile
|
||||||
|
|
||||||
|
# python -m memory_profiler mem_present.py
|
||||||
|
|
||||||
|
@profile
|
||||||
|
def main():
|
||||||
|
Public_Key, Private_Key = (
|
||||||
|
paillier.generate_paillier_keypair()
|
||||||
|
) # 随机生成1024长的公钥和私钥
|
||||||
|
x = 90000.23
|
||||||
|
y = 90
|
||||||
|
z = 0.5
|
||||||
|
x_encrypted = Public_Key.encrypt(x) # 加密后的x
|
||||||
|
y_encrypted = Public_Key.encrypt(y) # 加密后的y
|
||||||
|
z_encrypted = Public_Key.encrypt(z) # 加密后的z
|
||||||
|
t_encrypted = x_encrypted + y_encrypted * 0.5
|
||||||
|
|
||||||
|
print(f"x + y * 0.5的结果是:{Private_Key.decrypt(t_encrypted)}") # 打印出t
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__": # 主函数
|
||||||
|
main()
|
Loading…
x
Reference in New Issue
Block a user