-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(frontend-python): Add minimal test of public key encryption API
- Loading branch information
1 parent
8a33519
commit fb95106
Showing
8 changed files
with
134 additions
and
40 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
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
55 changes: 55 additions & 0 deletions
55
frontends/concrete-python/tests/execution/test_public_keys.py
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,55 @@ | ||
import numpy as np | ||
import pytest | ||
|
||
from concrete import fhe | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"function", | ||
[ | ||
pytest.param( | ||
lambda x, y: x + y, | ||
id="x + y", | ||
), | ||
], | ||
) | ||
@pytest.mark.parametrize( | ||
"parameters", | ||
[ | ||
{ | ||
"x": {"range": [0, 60], "status": "clear"}, | ||
"y": {"range": [0, 60], "status": "encrypted"}, | ||
}, | ||
{ | ||
"x": {"range": [0, 60], "status": "encrypted"}, | ||
"y": {"range": [0, 60], "status": "clear"}, | ||
}, | ||
{ | ||
"x": {"range": [0, 60], "status": "encrypted"}, | ||
"y": {"range": [0, 60], "status": "encrypted"}, | ||
}, | ||
{ | ||
"x": {"range": [0, 60], "status": "clear", "shape": (3,)}, | ||
"y": {"range": [0, 60], "status": "encrypted", "shape": (3,)}, | ||
}, | ||
{ | ||
"x": {"range": [0, 60], "status": "encrypted", "shape": (3,)}, | ||
"y": {"range": [0, 60], "status": "clear", "shape": (3,)}, | ||
}, | ||
], | ||
) | ||
def test_add(function, parameters, helpers): | ||
""" | ||
Test add where both of the operators are dynamic. | ||
""" | ||
|
||
parameter_encryption_statuses = helpers.generate_encryption_statuses(parameters) | ||
configuration = helpers.configuration() | ||
configuration.with_public_keys = fhe.PublicKeyKind.COMPACT | ||
compiler = fhe.Compiler(function, parameter_encryption_statuses) | ||
|
||
inputset = helpers.generate_inputset(parameters) | ||
circuit = compiler.compile(inputset, configuration) | ||
sample = helpers.generate_sample(parameters) | ||
print(circuit.server.client_specs.client_parameters.serialize()) | ||
helpers.check_execution(circuit, function, sample, 1, False, True) |