Skip to content

Commit

Permalink
test(compiler/clientlib): Add test of decprytion of a freshly compres…
Browse files Browse the repository at this point in the history
…sed ciphertext
  • Loading branch information
BourgerieQuentin committed Aug 13, 2024
1 parent b86def6 commit 732251e
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,24 @@ 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 732251e

Please sign in to comment.