From 96cff21ec44b6b4ae5f4bb23a39e30599101a952 Mon Sep 17 00:00:00 2001 From: Bourgerie Quentin Date: Tue, 13 Aug 2024 17:24:26 +0200 Subject: [PATCH] test(compiler/clientlib): Add test of decryption of a freshly compressed ciphertext --- .../execution/test_composition_compression.py | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/frontends/concrete-python/tests/execution/test_composition_compression.py b/frontends/concrete-python/tests/execution/test_composition_compression.py index e5758a4b0f..02012176c5 100644 --- a/frontends/concrete-python/tests/execution/test_composition_compression.py +++ b/frontends/concrete-python/tests/execution/test_composition_compression.py @@ -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