-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(frontend): simplify the doc for the non-power user
- Loading branch information
1 parent
ba7229e
commit 9fffe8b
Showing
9 changed files
with
96 additions
and
65 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Combining compiled functions | ||
|
||
In various cases, deploying a server that contains many compatible functions is important. By compatible, we mean that the functions will be used together, with outputs of some of them being used as inputs of some other ones, without decryption in the middle. It also encompasses the use of recursive functions. | ||
|
||
To support this feature in Concrete, we have two ways: | ||
- using the `composable` flag in the compilation, when there is a unique function. This option is described in [this document](composition.md) | ||
- using the Concrete modules, when there are several functions, or when there is a unique function for which we want to more precisely detail how outputs are reused as further inputs. This functionality is described in [this document](composing_functions_with_modules.md) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Combining compiled functions with the composable flag | ||
|
||
A simple way to say that a function `f` should be compiled such that its outputs can be reused as inputs is to use the | ||
[`composable`](../guides/configure.md#options) configuration setting to `True` when compiling. Doing so, we can then easily compute `f(f(x))` or `f**i(x) = f(f(...(f(x) ..))` for a variable non-encrypted integer `i`, which is typically what happens for recursions. | ||
|
||
```python | ||
from concrete import fhe | ||
|
||
@fhe.compiler({"counter": "encrypted"}) | ||
def increment(counter): | ||
return (counter + 1) % 100 | ||
|
||
print("Compiling `increment` function") | ||
increment_fhe = increment.compile(list(range(0, 100)), composable=True) | ||
|
||
print("Generating keyset ...") | ||
increment_fhe.keygen() | ||
|
||
print("Encrypting the initial counter value") | ||
counter = 0 | ||
counter_enc = increment_fhe.encrypt(counter) | ||
|
||
print(f"| iteration || decrypted | cleartext |") | ||
for i in range(10): | ||
counter_enc = increment_fhe.run(counter_enc) | ||
counter = increment(counter) | ||
|
||
# For demo purpose; no decryption is needed. | ||
counter_dec = increment_fhe.decrypt(counter_enc) | ||
print(f"| {i} || {counter_dec:<9} | {counter:<9} |") | ||
``` | ||
|
||
Remark that this option is the equivalent of using the `fhe.AllComposable` policy of [modules](composing_functions_with_modules.md). In particular, the same limitations may occur (see [limitations documentation](composing_functions_with_modules.md#limitations) section). | ||
|
||
|
||
|
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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