mirror of
https://github.com/zama-ai/concrete.git
synced 2026-01-08 20:38:06 -05:00
docs(frontend): edits
This commit is contained in:
committed by
Benoit Chevallier-Mames
parent
fac2d60c22
commit
c9be0f3b40
@@ -1,7 +1,9 @@
|
||||
# Compression
|
||||
This document explains the compression feature in **Concrete** and its performance impact.
|
||||
|
||||
Fully Homomorphic Encryption (FHE) needs both ciphertexts (encrypted data) and evaluation keys to carry out the homomorphic evaluation of a function. Both elements are large, which may critically affect the application's performance depending on the use case, application deployment, and the method for transmitting and storing ciphertexts and evaluation keys.
|
||||
|
||||
## Enabling compression
|
||||
During compilation, you can enable compression options to enforce the use of compression features. The two available compression options are:
|
||||
|
||||
* **compress\_evaluation\_keys**: bool = False,
|
||||
@@ -9,7 +11,7 @@ During compilation, you can enable compression options to enforce the use of com
|
||||
* **compress\_input\_ciphertexts**: bool = False,
|
||||
* This specifies that serialization takes the compressed form of input ciphertexts.
|
||||
|
||||
You can see the impact of compression by comparing the size of the serialized form of input ciphertexts and evaluation keys with a sample code.
|
||||
You can see the impact of compression by comparing the size of the serialized form of input ciphertexts and evaluation keys with a sample code:
|
||||
|
||||
```python
|
||||
from concrete import fhe
|
||||
@@ -29,10 +31,11 @@ def test_compression(compression):
|
||||
test_compression(False)
|
||||
test_compression(True)
|
||||
```
|
||||
## Compression algorithms
|
||||
|
||||
The compression factor largely depends on the cryptographic parameters identified and the compression algorithms selected during the compilation.
|
||||
|
||||
Currently, Concrete uses the seeded compression algorithms. These algorithms rely on the fact that CSPRNGs are deterministic. Consequently, the chain of random values can be replaced by the seed and later recalculated using the same seed.
|
||||
Currently, **Concrete** uses the seeded compression algorithms. These algorithms rely on the fact that CSPRNGs are deterministic. Consequently, the chain of random values can be replaced by the seed and later recalculated using the same seed.
|
||||
|
||||
Typically, the size of a ciphertext is `(lwe dimension + 1) * 8` bytes, while the size of a seeded ciphertext is constant, equal to `3 * 8` bytes. Thus, the compression factor ranges from a hundred to thousands. Understanding the compression factor of evaluation keys is complex. The compression factor of evaluation keys typically ranges between 0 and 10.
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
# Reuse Arguments
|
||||
This document explains how to reuse encrypted arguments in applications where the same arguments are used repeatedly.
|
||||
|
||||
Encryption can take quite some time, memory, and network bandwidth if encrypted data is to be transported. Some applications use the same argument, or a set of arguments as one of the inputs. In such applications, it doesn't make sense to encrypt and transfer the arguments each time. Instead, arguments can be encrypted separately, and reused:
|
||||
Encrypting data can be resource-intensive, especially when the same argument or set of arguments is used multiple times. In such cases, it’s inefficient to encrypt and transfer the arguments repeatedly. Instead, you can encrypt the arguments separately and reuse them as needed. By encrypting the arguments once and reusing them, you can optimize performance by reducing encryption time, memory usage, and network bandwidth.
|
||||
|
||||
Here is an example:
|
||||
|
||||
```python
|
||||
from concrete import fhe
|
||||
@@ -23,9 +26,12 @@ for sample_x in range(3, 6):
|
||||
|
||||
assert result == sample_x + sample_y
|
||||
```
|
||||
|
||||
If you have multiple arguments, the `encrypt` method would return a `tuple`, and if you specify `None` as one of the arguments, `None` is placed at the same location in the resulting `tuple` (e.g., `circuit.encrypt(a, None, b, c, None)` would return `(encrypted_a, None, encrypted_b, encrypted_c, None)`). Each value returned by `encrypt` can be stored and reused anytime.
|
||||
Note when you use `encrypt` method:
|
||||
- If you have multiple arguments, the `encrypt` method would return a `tuple`.
|
||||
- If you specify `None` as one of the arguments, `None` is placed at the same location in the resulting `tuple`.
|
||||
- For example, `circuit.encrypt(a, None, b, c, None)` returns `(encrypted_a, None, encrypted_b, encrypted_c, None)`.
|
||||
- Each value returned by `encrypt` can be stored and reused anytime.
|
||||
|
||||
{% hint style="warning" %}
|
||||
The ordering of the arguments must be kept consistent! Encrypting an `x` and using it as a `y` could result in undefined behavior.
|
||||
The order of arguments must be consistent when encrypting and using them. Encrypting an `x` and using it as a `y` could result in undefined behavior.
|
||||
{% endhint %}
|
||||
|
||||
Reference in New Issue
Block a user