Skip to content

Commit f1d5f4d

Browse files
authored
Merge pull request #51 from itzmeanjan/get-rid-of-kyber
Rename repository to `ml-kem`
2 parents b71107b + 223d4a0 commit f1d5f4d

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

README.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ KeyGen | - | Public Key and Secret Key
1818
Encapsulation | Public Key | Cipher Text and 32B Shared Secret
1919
Decapsulation | Secret Key and Cipher Text | 32B Shared Secret
2020

21-
Here I'm maintaining `kyber` - a C++20 header-only `constexpr` library, implementing ML-KEM, supporting ML-KEM-{512, 768, 1024} parameter sets, as defined in table 2 of ML-KEM draft standard. It's pretty easy to use, see [usage](#usage).
21+
Here I'm maintaining `ml-kem` - a C++20 header-only `constexpr` library, implementing ML-KEM, supporting ML-KEM-{512, 768, 1024} parameter sets, as defined in table 2 of ML-KEM draft standard. It's pretty easy to use, see [usage](#usage).
2222

2323
> [!NOTE]
2424
> Find ML-KEM draft standard @ https://doi.org/10.6028/NIST.FIPS.203.ipd - this is the document that I followed when implementing ML-KEM. I suggest you go through the specification to get an in-depth understanding of the scheme.
@@ -374,19 +374,19 @@ ml_kem_512/decap_max 16.4 us 16.4 us 10 61.3
374374

375375
## Usage
376376

377-
`kyber` is written as a header-only C++20 `constexpr` library, majorly targeting 64 -bit desktop/ server grade platforms and it's pretty easy to get started with. All you need to do is following.
377+
`ml-kem` is written as a header-only C++20 `constexpr` library, majorly targeting 64 -bit desktop/ server grade platforms and it's pretty easy to get started with. All you need to do is following.
378378

379-
- Clone `kyber` repository.
379+
- Clone `ml-kem` repository.
380380

381381
```bash
382382
cd
383383

384384
# Multi-step cloning and importing of submodules
385-
git clone https://github.com/itzmeanjan/kyber.git && pushd kyber && git submodule update --init && popd
385+
git clone https://github.com/itzmeanjan/ml-kem.git && pushd ml-kem && git submodule update --init && popd
386386
# Or do single step cloning and importing of submodules
387-
git clone https://github.com/itzmeanjan/kyber.git --recurse-submodules
387+
git clone https://github.com/itzmeanjan/ml-kem.git --recurse-submodules
388388
# Or clone and then run tests, which will automatically bring in dependencies
389-
git clone https://github.com/itzmeanjan/kyber.git && pushd kyber && make -j && popd
389+
git clone https://github.com/itzmeanjan/ml-kem.git && pushd ml-kem && make -j && popd
390390
```
391391

392392
- Write your program while including proper header files ( based on which variant of ML-KEM you want to use, see [include](./include/ml_kem/) directory ), which includes declarations ( and definitions ) of all required ML-KEM routines and constants ( such as byte length of public/ private key, cipher text etc. ).
@@ -432,16 +432,16 @@ main()
432432
}
433433
```
434434

435-
- When compiling your program, let your compiler know where it can find `kyber`, `sha3` and `subtle` headers, which includes their definitions ( all of them are header-only libraries ) too.
435+
- When compiling your program, let your compiler know where it can find `ml-kem`, `sha3` and `subtle` headers, which includes their definitions ( all of them are header-only libraries ) too.
436436

437437
```bash
438-
# Assuming `kyber` was cloned just under $HOME
438+
# Assuming `ml-kem` was cloned just under $HOME
439439

440-
KYBER_HEADERS=~/kyber/include
441-
SHA3_HEADERS=~/kyber/sha3/include
442-
SUBTLE_HEADERS=~/kyber/subtle/include
440+
ML_KEM_HEADERS=~/ml-kem/include
441+
SHA3_HEADERS=~/ml-kem/sha3/include
442+
SUBTLE_HEADERS=~/ml-kem/subtle/include
443443

444-
g++ -std=c++20 -Wall -Wextra -pedantic -O3 -march=native -I $KYBER_HEADERS -I $SHA3_HEADERS -I $SUBTLE_HEADERS main.cpp
444+
g++ -std=c++20 -Wall -Wextra -pedantic -O3 -march=native -I $ML_KEM_HEADERS -I $SHA3_HEADERS -I $SUBTLE_HEADERS main.cpp
445445
```
446446

447447
ML-KEM Variant | Namespace | Header
@@ -453,21 +453,21 @@ ML-KEM-1024 Routines | `ml_kem_1024::` | `include/ml_kem/ml_kem_1024.hpp`
453453
> [!NOTE]
454454
> ML-KEM parameter sets are taken from table 2 of ML-KEM draft standard @ https://doi.org/10.6028/NIST.FIPS.203.ipd.
455455
456-
All the functions, in this Kyber header-only library, are implemented as `constexpr` functions. Hence you should be able to evaluate ML-KEM key generation, encapsulation or decapsulation at compile-time itself, given that all inputs are known at compile-time. I present you with following demonstration program, which generates a ML-KEM-512 keypair and encapsulates a message, producing a ML-KEM-512 cipher text and a fixed size shared secret, given `seed_{d, z, m}` as input - all at program compile-time. Notice, the *static assertion*.
456+
All the functions, in this ML-KEM header-only library, are implemented as `constexpr` functions. Hence you should be able to evaluate ML-KEM key generation, encapsulation or decapsulation at compile-time itself, given that all inputs are known at compile-time. I present you with following demonstration program, which generates a ML-KEM-512 keypair and encapsulates a message, producing a ML-KEM-512 cipher text and a fixed size shared secret, given `seed_{d, z, m}` as input - all at program compile-time. Notice, the *static assertion*.
457457

458458
```cpp
459459
// compile-time-ml-kem-512.cpp
460460
//
461461
// Compile and run this program with
462-
// $ g++ -std=c++20 -Wall -Wextra -pedantic -I include -I sha3/include -I subtle/include main.cpp && ./a.out
462+
// $ g++ -std=c++20 -Wall -Wextra -pedantic -I include -I sha3/include -I subtle/include compile-time-ml-kem-512.cpp && ./a.out
463463
// or
464-
// $ clang++ -std=c++20 -Wall -Wextra -pedantic -fconstexpr-steps=4000000 -I include -I sha3/include -I subtle/include main.cpp && ./a.out
464+
// $ clang++ -std=c++20 -Wall -Wextra -pedantic -fconstexpr-steps=4000000 -I include -I sha3/include -I subtle/include compile-time-ml-kem-512.cpp && ./a.out
465465

466466
#include "ml_kem/ml_kem_512.hpp"
467467

468468
// Compile-time evaluation of ML-KEM-512 key generation and encapsulation, using NIST official KAT no. (1).
469469
constexpr auto
470-
eval_encaps() -> auto
470+
eval_ml_kem_768_encaps() -> auto
471471
{
472472
using seed_t = std::array<uint8_t, ml_kem_512::SEED_D_BYTE_LEN>;
473473

@@ -494,7 +494,7 @@ int
494494
main()
495495
{
496496
// This step is being evaluated at compile-time, thanks to the fact that my ML-KEM implementation is `constexpr`.
497-
static constexpr auto computed_shared_secret = eval_encaps();
497+
static constexpr auto computed_shared_secret = eval_ml_kem_768_encaps();
498498
// 500c4424107df96b01749b95f47a14eea871c3742606e15d2b6c91d207d85965
499499
constexpr std::array<uint8_t, ml_kem_512::SHARED_SECRET_BYTE_LEN> expected_shared_secret = { 80, 12, 68, 36, 16, 125, 249, 107, 1, 116, 155, 149, 244, 122, 20, 238, 168, 113, 195, 116, 38, 6, 225, 93, 43, 108, 145, 210, 7, 216, 89, 101 };
500500

0 commit comments

Comments
 (0)