Skip to content

Commit

Permalink
test(compiler/clientlib): Add test of decryption of a freshly compres…
Browse files Browse the repository at this point in the history
…sed ciphertext
  • Loading branch information
BourgerieQuentin committed Aug 23, 2024
1 parent 477b502 commit 96cff21
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,26 @@ def f(x):
circuit = f.compile(fhe.inputset(fhe.uint3), conf)
result = circuit.run(circuit.run(circuit.encrypt(2)))
assert circuit.decrypt(result) == f(f(2))


def test_composable_with_input_compression_decrypt_fresh_encrypted(helpers):
"""
Test that we can decrypt a value which has just been encrypted with compression,
it requires composability as we need to ensure input and output partitions are the same.
https://github.com/zama-ai/concrete-internal/issues/758
"""
conf = helpers.configuration()
if conf.parameter_selection_strategy != fhe.ParameterSelectionStrategy.MULTI:
# Composability is for now only valid with multi
return

@fhe.compiler({"x": "encrypted"})
def f(x):
return x**2

inputset = [2, 3, 4, 5]
conf.composable = True
conf.compress_input_ciphertexts = True
circuit = f.compile(inputset, conf)
assert circuit.decrypt(circuit.encrypt(2)) == 2

0 comments on commit 96cff21

Please sign in to comment.