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

Public key export deletes private key #18

Closed
gR0OT opened this issue Jan 24, 2024 · 1 comment
Closed

Public key export deletes private key #18

gR0OT opened this issue Jan 24, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@gR0OT
Copy link

gR0OT commented Jan 24, 2024

When performing export_keys() in lightphe.init in case of exporting (publishing) the public key, it deletes private key in the process. This leaves the LightPHE object (who should have private key, because it generated it) unable to decrypt.

246: if public is True and keys.get("private_key") is not None:
247:     del keys["private_key"]

Current workaround:

gm = LightPHE('Paillier')
gm.export_keys('private.key', public=False)
gm.export_keys('public.key', public=True)
gm = LightPHE('Paillier', key_file='private.key')

Proposed fix:
Don't delete the private_key from keys when performing export_keys(), just export the public_key

pubkey = {'public_key': keys['public_key']}
with open(target_file, "w", encoding="UTF-8") as file:
    file.write(pubkey)
@serengil serengil added the enhancement New feature or request label Jan 24, 2024
@serengil
Copy link
Owner

Closed with PR - #19

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants