Skip to content

Commit

Permalink
mark the ML-KEM API as stable
Browse files Browse the repository at this point in the history
  • Loading branch information
tomato42 committed Oct 8, 2024
1 parent b187189 commit 6504ce4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ use:
- `ML_KEM.encaps(ek)`: generate a key and ciphertext pair `(key, ct)`
- `ML_KEM.decaps(dk, ct)`: generate the shared key `key`

Those, together with the `ML_KEM_512`, `ML_KEM_768`, and `ML_KEM_1024`
objects comprise the kyber-py library stable API.

#### Example

```python
Expand Down
6 changes: 6 additions & 0 deletions src/kyber_py/ml_kem/default_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,24 @@
Key exchange object that uses ML-KEM-512 parameters internally.
Provides about 128 bit level of security.
Part of stable API.
"""

ML_KEM_768 = ML_KEM(DEFAULT_PARAMETERS["ML768"])
"""
Key exchange object that uses ML-KEM-768 parameters internally.
Provides about 192 bit level of security.
Part of stable API.
"""

ML_KEM_1024 = ML_KEM(DEFAULT_PARAMETERS["ML1024"])
"""
Key exchange object that uses ML-KEM-1024 parameters internally.
Provides about 256 bit level of security.
Part of stable API.
"""
10 changes: 8 additions & 2 deletions src/kyber_py/ml_kem/ml_kem.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@ def keygen(self):
``ek`` is encoded as bytes of length 384*k + 32
``dk`` is encoded as bytes of length 768*k + 96
Part of stable API.
:return: Tuple with encapsulation key and decapsulation key.
:rtype: tuple(bytes, bytes)
"""
Expand Down Expand Up @@ -324,8 +326,10 @@ def encaps(self, ek):
``K`` is the shared secret key of length 32 bytes
``c`` is the ciphertext of length 32(du*k + dv)
Part of stable API.
:param bytes ek: byte-encoded encapsulation key
:return: a random key and an encapsulation of it
:return: a random key (``K``) and an encapsulation of it (``c``)
:rtype: tuple(bytes, bytes)
"""
# Create random tokens
Expand Down Expand Up @@ -395,9 +399,11 @@ def decaps(self, dk, c):
``K`` is the shared secret key of length 32 bytes
Part of stable API.
:param bytes dk: decapsulation key
:param bytes c: ciphertext with an encapsulated key
:return: shared secret key
:return: shared secret key (``K``)
:rtype: bytes
"""
try:
Expand Down

0 comments on commit 6504ce4

Please sign in to comment.