-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
83 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ lightphe.egg-info | |
**/.DS_Store | ||
build/ | ||
dist/ | ||
*.pyc | ||
*.pyc | ||
tests/*.lphe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import os | ||
from lightphe import LightPHE | ||
from lightphe.commons.logger import Logger | ||
|
||
logger = Logger(module="tests/test_goldwasser.py") | ||
|
||
|
||
# pylint: disable=eval-used | ||
def test_private_available_after_export(): | ||
target_file = "my_public_key.lphe" | ||
cs = LightPHE(algorithm_name="RSA") | ||
# we are dropping private key while exporting public key | ||
cs.export_keys(public=True, target_file=target_file) | ||
assert cs.cs.keys.get("private_key") is not None | ||
logger.info("✅ private key is not available in public key file as expected") | ||
|
||
with open(target_file, "r", encoding="UTF-8") as file: | ||
key_str = file.read() | ||
keys = eval(key_str) | ||
assert keys.get("private_key") is None | ||
logger.info( | ||
"✅ private key is available in cryptosystem's keys after" | ||
"its public key exported as expected" | ||
) | ||
|
||
os.remove(target_file) |