Oct-09-2021, 08:31 AM
I use some recently GitHub publish code ----->https://github.com/ibarrond/Pyfhel it return me error
Where Pyfhel i have installed from git command line and as well from terminal shown in the GitHub code readme file and PyPtxt mean plaintext and PyCtxt ciphertext.
How to solve this error if i just write from Pyfhel import* instead of from Pyfhel import Pyfhel, PyPtxt, PyCtxt still it give me an error.
Error:ImportError: cannot import name 'Pyfhel' from 'Pyfhel' Where Pyfhel i have installed from git command line and as well from terminal shown in the GitHub code readme file and PyPtxt mean plaintext and PyCtxt ciphertext.
How to solve this error if i just write from Pyfhel import* instead of from Pyfhel import Pyfhel, PyPtxt, PyCtxt still it give me an error.
import time
from Pyfhel import Pyfhel, PyPtxt, PyCtxt
# Pyfhel class contains most of the functions.
# PyPtxt is the plaintext class
# PyCtxt is the ciphertext class
print("==============================================================")
print("================== Pyfhel CONTEXT PARAMETERS =================")
print("==============================================================")
print("1. p (long): Plaintext modulus. All operations are modulo p. ")
HE = Pyfhel() # Creating empty Pyfhel object
HE.contextGen(p=65537) # Generating context. The value of p is important.
# There are many configurable parameters on this step
HE.keyGen() # Key Generation.
print("2. m (long=2048): Polynomial coefficient modulus.")
print(" Higher allows more encrypted operations. In batch mode it is the number of integers per ciphertext.")
def time_demo_helloworld(integer1=127, integer2=-2):
start = time.time()
ctxt1 = HE.encryptInt(integer1) # Encryption makes use of the public key
ctxt2 = HE.encryptInt(integer2) # For integers, encryptInt function is used.
ctxtSum = ctxt1 + ctxt2 # `ctxt1 += ctxt2` for quicker inplace operation
ctxtSub = ctxt1 - ctxt2 # `ctxt1 -= ctxt2` for quicker inplace operation
ctxtMul = ctxt1 * ctxt2 # `ctxt1 *= ctxt2` for quicker inplace operation
resSum = HE.decryptInt(ctxtSum)
resSub = HE.decryptInt(ctxtSub)
resMul = HE.decryptInt(ctxtMul)
end = time.time()
print(f"Elapsed time: {end - start}")
results = (resSum==125, resSub==129, resMul==-254)
return end - start, resultsError: Error:Traceback (most recent call last):
File "D:/Clustering/Pyfhel-master/Pyfhel-master/examples/Demo_ContextParameters.py", line 12, in <module>
from Pyfhel import Pyfhel, PyPtxt, PyCtxt
ImportError: cannot import name 'Pyfhel' from 'Pyfhel' (D:\Clustering\Pyfhel-master\Pyfhel-master\Pyfhel\__init__.py)Process finished with exit code 1
