Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save and load: SystemError: <method 'decryptInt'> returned a result with an error set #40

Closed
lorepieri8 opened this issue Sep 9, 2019 · 5 comments
Labels

Comments

@lorepieri8
Copy link

from Pyfhel import Pyfhel, PyPtxt, PyCtxt

def save_and_load():

	HE = Pyfhel()
	HE.contextGen(p=65537)
	HE.keyGen()
	integer1 = 10
	ctxt = HE.encryptInt(integer1)
	ctxt.save("ctxt.c1")
	m = PyCtxt()
	result = m.load("ctxt.c1")
	print(result)
	print(HE.decryptInt(result))


if __name__ == "__main__":
	save_and_load()
	print('------------')

Output:

------------
None
Traceback (most recent call last):
  File "Pyfhel/Pyfhel.pyx", line 338, in Pyfhel.Pyfhel.Pyfhel.decryptInt
RuntimeError: <Pyfhel ERROR> wrong encoding type in PyCtxt

The above exception was the direct cause of the following exception:

[...]
SystemError: <method 'decryptInt' of 'Pyfhel.Pyfhel.Pyfhel' objects> returned a result with an error set

@lorepieri8
Copy link
Author

Related to #33 .

@lorepieri8
Copy link
Author

lorepieri8 commented Sep 18, 2019

The following code correctly saving-loading:

        HE = Pyfhel()
	HE.contextGen(p=65537)
	HE.keyGen()
	integer1 = 10
	ctxt = HE.encryptInt(integer1)
	ctxt.save("ctxt.txt")
	m = PyCtxt()
	m.load("ctxt.txt")
	if integer1 == HE.decryptInt(m):
		print("Save and Load is working correctly!")

What was causing the error is this assignment:

result = m.load("ctxt.txt")
print(HE.decryptInt(result))

@767472021
Copy link

contextGen

You can try Windows, but it's not solved.

@767472021
Copy link

The following code correctly saving-loading:

        HE = Pyfhel()
	HE.contextGen(p=65537)
	HE.keyGen()
	integer1 = 10
	ctxt = HE.encryptInt(integer1)
	ctxt.save("ctxt.txt")
	m = PyCtxt()
	m.load("ctxt.txt")
	if integer1 == HE.decryptInt(m):
		print("Save and Load is working correctly!")

What was causing the error is this assignment:

result = m.load("ctxt.txt")
print(HE.decryptInt(result))

You can try Windows, but it's not solved.

@ibarrond
Copy link
Owner

Related to #54, solved in 73434f1 . Saving and loading works correctly in Windows and in Linux.

@ibarrond ibarrond added the bug label Oct 10, 2020
@ibarrond ibarrond changed the title save and load Save and load: SystemError: <method 'decryptInt'> returned a result with an error set Oct 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants