
Implements a key-encapsulation mechanism based on CRYSTALS-Kyber, offering key generation, encapsulation, and decapsulation with MLWE security. Supports byte conversions and various cryptographic operations.
Digital security for all, everywhere, no matter who they are, or what they believe in.
ML-KEM is a key-encapsulation mechanism based on CRYSTALS-KYBER. The security of ML-KEM is based on the presumed hardness of the so-called Module Learning with Errors (MLWE) problem, which is a generalization of the Learning With Errors (LWE) problem introduced by Regev in 2005. The hardness of the MLWE problem is itself based on the presumed hardness of certain computational problems in module lattices. This motivates the name of the scheme ML-KEM.
This is quoted from Section 3.2 of the NIST FIPS 203 document.
[!WARNING] If you are using any versions below 1.2.0, you must update to 1.2.0 and above to fix a critical vulnerability in this implementation. In summary, the previous versions were NOT ML-KEM but Kyber. There is a big difference between the two. In addition, the algorithm was sometimes producing rare bit flips that doesn't affect the encaps, decaps process, but it is still a different result than the implementation of others so it would cause confusion once mixed with other libraries seen in #14.
This is a 100% Kotlin Multiplatform implementation of ML-KEM Final with super fast optimizations. It depends on KeccakKotlin and secure-random Kotlin libraries in order to implement SHA3, SHAKE, and Secure Random within the library.
This library is tested against Bouncy Castle's Java ML-KEM implementation 1 million times for each parameter set. For quick testing we also do 10 thousand times (see JVMTest.kt file).
[!NOTE] Version 2.0.1 brings astounding performance improvements by updating the underlying KeccakKotlin library to 2.0.1. The memory allocations during JVMBenchmark was initially at 275.57GB(2.0.0) and it brought it down to 53.88GB(2.0.1); All thanks to my full control over KeccakKotlin which gave me the freedom to optimize it ridiculously to bring my implementation closer to native speeds. It also sped up the speed a little bit. Not too much but it's significant for millions of kyber operations. (Profiling done using IntelliJ Profiler on Windows 11)
| Target | Arm32 | Arm64 | X64 |
|---|---|---|---|
| JVM (Kotlin & Java) | ✅ | ✅ | ✅ |
| Linux | ❌ * | ❌ ** | ✅ |
| Windows (Mingw) | ❌ * | ❌ * | ✅ |
| Android | ✅ | ✅ | ✅ |
| iOS | ❌ * | ❌ ** | ❌ ** |
| iOS Simulator | ❌ * | ❌ ** | ❌ * |
*Note: Some platforms are unavailable/deprecated as targets in Kotlin Multiplatform. Please send your complaints to Jetbrains.
**These targets are currently available, but I have no ability to compile them yet. Once I have more free time, I will setup a publishing server to compile to all targets.
Requirements: JAVA 8+
NOTE: if implementation does not work, replace with compile.
build.gradle
dependencies {
implementation 'asia.hombre:kyber:2.0.1'
}build.gradle.kts
dependencies {
implementation("asia.hombre:kyber:2.0.1")
}pom.xml
<dependency>
<groupId>asia.hombre</groupId>
<artifactId>kyber</artifactId>
<version>2.0.1</version>
</dependency>Checkout the Wiki for more installation instructions and examples.
Checkout the Wiki or the Documentation for more information.
Copyright 2025 Ron Lauren Hombre
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
and included as LICENSE.txt in this Project.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Although ML-KEM is declared Public Domain, this implementation is created through the efforts of its contributors. As such, some form of recognition for their work are required for all users of this library.
Digital security for all, everywhere, no matter who they are, or what they believe in.
ML-KEM is a key-encapsulation mechanism based on CRYSTALS-KYBER. The security of ML-KEM is based on the presumed hardness of the so-called Module Learning with Errors (MLWE) problem, which is a generalization of the Learning With Errors (LWE) problem introduced by Regev in 2005. The hardness of the MLWE problem is itself based on the presumed hardness of certain computational problems in module lattices. This motivates the name of the scheme ML-KEM.
This is quoted from Section 3.2 of the NIST FIPS 203 document.
[!WARNING] If you are using any versions below 1.2.0, you must update to 1.2.0 and above to fix a critical vulnerability in this implementation. In summary, the previous versions were NOT ML-KEM but Kyber. There is a big difference between the two. In addition, the algorithm was sometimes producing rare bit flips that doesn't affect the encaps, decaps process, but it is still a different result than the implementation of others so it would cause confusion once mixed with other libraries seen in #14.
This is a 100% Kotlin Multiplatform implementation of ML-KEM Final with super fast optimizations. It depends on KeccakKotlin and secure-random Kotlin libraries in order to implement SHA3, SHAKE, and Secure Random within the library.
This library is tested against Bouncy Castle's Java ML-KEM implementation 1 million times for each parameter set. For quick testing we also do 10 thousand times (see JVMTest.kt file).
[!NOTE] Version 2.0.1 brings astounding performance improvements by updating the underlying KeccakKotlin library to 2.0.1. The memory allocations during JVMBenchmark was initially at 275.57GB(2.0.0) and it brought it down to 53.88GB(2.0.1); All thanks to my full control over KeccakKotlin which gave me the freedom to optimize it ridiculously to bring my implementation closer to native speeds. It also sped up the speed a little bit. Not too much but it's significant for millions of kyber operations. (Profiling done using IntelliJ Profiler on Windows 11)
| Target | Arm32 | Arm64 | X64 |
|---|---|---|---|
| JVM (Kotlin & Java) | ✅ | ✅ | ✅ |
| Linux | ❌ * | ❌ ** | ✅ |
| Windows (Mingw) | ❌ * | ❌ * | ✅ |
| Android | ✅ | ✅ | ✅ |
| iOS | ❌ * | ❌ ** | ❌ ** |
| iOS Simulator | ❌ * | ❌ ** | ❌ * |
*Note: Some platforms are unavailable/deprecated as targets in Kotlin Multiplatform. Please send your complaints to Jetbrains.
**These targets are currently available, but I have no ability to compile them yet. Once I have more free time, I will setup a publishing server to compile to all targets.
Requirements: JAVA 8+
NOTE: if implementation does not work, replace with compile.
build.gradle
dependencies {
implementation 'asia.hombre:kyber:2.0.1'
}build.gradle.kts
dependencies {
implementation("asia.hombre:kyber:2.0.1")
}pom.xml
<dependency>
<groupId>asia.hombre</groupId>
<artifactId>kyber</artifactId>
<version>2.0.1</version>
</dependency>Checkout the Wiki for more installation instructions and examples.
Checkout the Wiki or the Documentation for more information.
Copyright 2025 Ron Lauren Hombre
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
and included as LICENSE.txt in this Project.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Although ML-KEM is declared Public Domain, this implementation is created through the efforts of its contributors. As such, some form of recognition for their work are required for all users of this library.