Skip to content

Commit

Permalink
docs(frontend-python): Update API doc
Browse files Browse the repository at this point in the history
  • Loading branch information
BourgerieQuentin committed Sep 27, 2024
1 parent a1a76a6 commit c38f9d4
Show file tree
Hide file tree
Showing 49 changed files with 2,240 additions and 1,262 deletions.
53 changes: 33 additions & 20 deletions docs/dev/api/README.md

Large diffs are not rendered by default.

122 changes: 116 additions & 6 deletions docs/dev/api/concrete.compiler.client_parameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ Client parameters.

---

<a href="../../../compilers/concrete-compiler/compiler/lib/Bindings/Python/concrete/compiler/client_parameters.py#L18"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../../../compilers/concrete-compiler/compiler/lib/Bindings/Python/concrete/compiler/client_parameters.py#L19"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>class</kbd> `ClientParameters`
ClientParameters are public parameters used for key generation.

It's a compilation artifact that describes which and how public and private keys should be generated, and used to encrypt arguments of the compiled function.

<a href="../../../compilers/concrete-compiler/compiler/lib/Bindings/Python/concrete/compiler/client_parameters.py#L25"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../../../compilers/concrete-compiler/compiler/lib/Bindings/Python/concrete/compiler/client_parameters.py#L26"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `__init__`

Expand All @@ -43,7 +43,7 @@ Wrap the native Cpp object.

---

<a href="../../../compilers/concrete-compiler/compiler/lib/Bindings/Python/concrete/compiler/client_parameters.py#L64"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../../../compilers/concrete-compiler/compiler/lib/Bindings/Python/concrete/compiler/client_parameters.py#L131"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `deserialize`

Expand Down Expand Up @@ -73,7 +73,56 @@ Unserialize ClientParameters from bytes of serialized_params.

---

<a href="../../../compilers/concrete-compiler/compiler/lib/Bindings/Python/concrete/compiler/client_parameters.py#L40"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../../../compilers/concrete-compiler/compiler/lib/Bindings/Python/concrete/compiler/client_parameters.py#L115"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `function_list`

```python
function_list() → List[str]
```

Return the list of function names.



**Returns:**

- <b>`List[str]`</b>: list of the names of the functions.

---

<a href="../../../compilers/concrete-compiler/compiler/lib/Bindings/Python/concrete/compiler/client_parameters.py#L57"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `input_keyid_at`

```python
input_keyid_at(input_idx: int, circuit_name: str = '<lambda>') → int
```

Get the keyid of a selected encrypted input in a given circuit.



**Args:**

- <b>`input_idx`</b> (int): index of the input in the circuit.
- <b>`circuit_name`</b> (str): name of the circuit containing the desired input.



**Raises:**

- <b>`TypeError`</b>: if arguments aren't of expected types



**Returns:**

- <b>`int`</b>: keyid

---

<a href="../../../compilers/concrete-compiler/compiler/lib/Bindings/Python/concrete/compiler/client_parameters.py#L99"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `input_signs`

Expand All @@ -91,7 +140,68 @@ Return the sign information of inputs.

---

<a href="../../../compilers/concrete-compiler/compiler/lib/Bindings/Python/concrete/compiler/client_parameters.py#L48"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../../../compilers/concrete-compiler/compiler/lib/Bindings/Python/concrete/compiler/client_parameters.py#L78"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `input_variance_at`

```python
input_variance_at(input_idx: int, circuit_name: str) → float
```

Get the variance of a selected encrypted input in a given circuit.



**Args:**

- <b>`input_idx`</b> (int): index of the input in the circuit.
- <b>`circuit_name`</b> (str): name of the circuit containing the desired input.



**Raises:**

- <b>`TypeError`</b>: if arguments aren't of expected types



**Returns:**

- <b>`float`</b>: variance

---

<a href="../../../compilers/concrete-compiler/compiler/lib/Bindings/Python/concrete/compiler/client_parameters.py#L41"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `lwe_secret_key_param`

```python
lwe_secret_key_param(key_id: int) → LweSecretKeyParam
```

Get the parameters of a selected LWE secret key.



**Args:**

- <b>`key_id`</b> (int): keyid to get parameters from



**Raises:**

- <b>`TypeError`</b>: if arguments aren't of expected types



**Returns:**

- <b>`LweSecretKeyParam`</b>: LWE secret key parameters

---

<a href="../../../compilers/concrete-compiler/compiler/lib/Bindings/Python/concrete/compiler/client_parameters.py#L107"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `output_signs`

Expand All @@ -109,7 +219,7 @@ Return the sign information of outputs.

---

<a href="../../../compilers/concrete-compiler/compiler/lib/Bindings/Python/concrete/compiler/client_parameters.py#L56"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../../../compilers/concrete-compiler/compiler/lib/Bindings/Python/concrete/compiler/client_parameters.py#L123"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `serialize`

Expand Down
22 changes: 12 additions & 10 deletions docs/dev/api/concrete.compiler.client_support.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Client support.

---

<a href="../../../compilers/concrete-compiler/compiler/lib/Bindings/Python/concrete/compiler/client_support.py#L23"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../../../compilers/concrete-compiler/compiler/lib/Bindings/Python/concrete/compiler/client_support.py#L24"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>class</kbd> `ClientSupport`
Client interface for doing key generation and encryption.
Expand All @@ -24,7 +24,7 @@ It provides features that are needed on the client side:
- Encryption and preparation of public arguments, used later as input to the computation
- Decryption of public result returned after execution

<a href="../../../compilers/concrete-compiler/compiler/lib/Bindings/Python/concrete/compiler/client_support.py#L32"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../../../compilers/concrete-compiler/compiler/lib/Bindings/Python/concrete/compiler/client_support.py#L33"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `__init__`

Expand All @@ -51,7 +51,7 @@ Wrap the native Cpp object.

---

<a href="../../../compilers/concrete-compiler/compiler/lib/Bindings/Python/concrete/compiler/client_support.py#L170"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../../../compilers/concrete-compiler/compiler/lib/Bindings/Python/concrete/compiler/client_support.py#L181"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `decrypt_result`

Expand All @@ -60,7 +60,7 @@ decrypt_result(
client_parameters: ClientParameters,
keyset: KeySet,
public_result: PublicResult,
circuit_name: str = 'main'
circuit_name: str
) → Union[int, ndarray]
```

Expand Down Expand Up @@ -92,7 +92,7 @@ Decrypt a public result using the keyset.

---

<a href="../../../compilers/concrete-compiler/compiler/lib/Bindings/Python/concrete/compiler/client_support.py#L114"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../../../compilers/concrete-compiler/compiler/lib/Bindings/Python/concrete/compiler/client_support.py#L125"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `encrypt_arguments`

Expand All @@ -101,7 +101,7 @@ encrypt_arguments(
client_parameters: ClientParameters,
keyset: KeySet,
args: List[Union[int, ndarray]],
circuit_name: str = 'main'
circuit_name: str
) → PublicArguments
```

Expand Down Expand Up @@ -134,7 +134,7 @@ Pack public arguments by encrypting the ones that requires encryption, and leavi

---

<a href="../../../compilers/concrete-compiler/compiler/lib/Bindings/Python/concrete/compiler/client_support.py#L59"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../../../compilers/concrete-compiler/compiler/lib/Bindings/Python/concrete/compiler/client_support.py#L60"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `key_set`

Expand All @@ -143,13 +143,14 @@ key_set(
client_parameters: ClientParameters,
keyset_cache: Optional[KeySetCache] = None,
secret_seed: Optional[int] = None,
encryption_seed: Optional[int] = None
encryption_seed: Optional[int] = None,
initial_lwe_secret_keys: Optional[Dict[int, LweSecretKey]] = None
) → KeySet
```

Generate a key set according to the client parameters.

If the cache is set, and include equivalent keys as specified by the client parameters, the keyset is loaded, otherwise, a new keyset is generated and saved in the cache.
If the cache is set, and include equivalent keys as specified by the client parameters, the keyset is loaded, otherwise, a new keyset is generated and saved in the cache. If keygen is required, it will first initialize the secret keys provided, if any.



Expand All @@ -159,6 +160,7 @@ If the cache is set, and include equivalent keys as specified by the client para
- <b>`keyset_cache`</b> (Optional[KeySetCache], optional): keyset cache. Defaults to None.
- <b>`secret_seed`</b> (Optional[int]): secret seed, must be a positive 128 bits integer
- <b>`encryption_seed`</b> (Optional[int]): encryption seed, must be a positive 128 bits integer
- <b>`initial_lwe_secret_keys`</b> (Optional[Dict[int, LweSecretKey]]): keys to init the keyset with before keygen. It maps keyid to secret key



Expand All @@ -176,7 +178,7 @@ If the cache is set, and include equivalent keys as specified by the client para

---

<a href="../../../compilers/concrete-compiler/compiler/lib/Bindings/Python/concrete/compiler/client_support.py#L48"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../../../compilers/concrete-compiler/compiler/lib/Bindings/Python/concrete/compiler/client_support.py#L49"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `new`

Expand Down
3 changes: 3 additions & 0 deletions docs/dev/api/concrete.compiler.compilation_feedback.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
# <kbd>module</kbd> `concrete.compiler.compilation_feedback`
Compilation feedback.

**Global Variables**
---------------
- **REGEX_LOCATION**

---

Expand Down
40 changes: 35 additions & 5 deletions docs/dev/api/concrete.compiler.key_set.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ Store for the different keys required for an encrypted computation.

---

<a href="../../../compilers/concrete-compiler/compiler/lib/Bindings/Python/concrete/compiler/key_set.py#L20"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../../../compilers/concrete-compiler/compiler/lib/Bindings/Python/concrete/compiler/key_set.py#L21"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>class</kbd> `KeySet`
KeySet stores the different keys required for an encrypted computation.

Holds private keys (secret key) used for encryption/decryption, and public keys used for computation.

<a href="../../../compilers/concrete-compiler/compiler/lib/Bindings/Python/concrete/compiler/key_set.py#L26"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../../../compilers/concrete-compiler/compiler/lib/Bindings/Python/concrete/compiler/key_set.py#L27"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `__init__`

Expand All @@ -45,7 +45,7 @@ Wrap the native Cpp object.

---

<a href="../../../compilers/concrete-compiler/compiler/lib/Bindings/Python/concrete/compiler/key_set.py#L47"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../../../compilers/concrete-compiler/compiler/lib/Bindings/Python/concrete/compiler/key_set.py#L48"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `deserialize`

Expand Down Expand Up @@ -75,7 +75,7 @@ Deserialize KeySet from bytes.

---

<a href="../../../compilers/concrete-compiler/compiler/lib/Bindings/Python/concrete/compiler/key_set.py#L66"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../../../compilers/concrete-compiler/compiler/lib/Bindings/Python/concrete/compiler/key_set.py#L83"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `get_evaluation_keys`

Expand All @@ -92,7 +92,37 @@ Get evaluation keys for execution.

---

<a href="../../../compilers/concrete-compiler/compiler/lib/Bindings/Python/concrete/compiler/key_set.py#L39"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../../../compilers/concrete-compiler/compiler/lib/Bindings/Python/concrete/compiler/key_set.py#L67"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `get_lwe_secret_key`

```python
get_lwe_secret_key(keyid: int) → LweSecretKey
```

Get a specific LweSecretKey.



**Args:**

- <b>`keyid`</b> (int): id of the key to get



**Raises:**

- <b>`TypeError`</b>: if wrong types for input arguments



**Returns:**

- <b>`bytes`</b>: LweSecretKey

---

<a href="../../../compilers/concrete-compiler/compiler/lib/Bindings/Python/concrete/compiler/key_set.py#L40"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `serialize`

Expand Down
2 changes: 1 addition & 1 deletion docs/dev/api/concrete.compiler.library_support.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ Load the compilation feedback from the compilation result.
load_server_lambda(
library_compilation_result: LibraryCompilationResult,
simulation: bool,
circuit_name: str = 'main'
circuit_name: str
) → LibraryLambda
```

Expand Down
Loading

0 comments on commit c38f9d4

Please sign in to comment.