/KyberKotlin

ML-KEM's Kotlin Implementation

Primary LanguageKotlinApache License 2.0Apache-2.0

KyberKotlin (1.0.0)

Implements ML-KEM (CRYSTALS-Kyber)

Digital security for all, everywhere, no matter who they are, or what they believe in.

CodeQL master Maven Central GitHub license Gradle Kotlin Java JS

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.

Introduction

This is a 100% Kotlin Multiplatform implementation of ML-KEM. It depends on KeccakKotlin and secure-random Kotlin libraries in order to implement SHA3, SHAKE, and Secure Random within the library.

Note

With the release of the final version of NIST FIPS 203 for ML-KEM, I'm proud to present that my KyberKotlin library is ready for production use. In the past months, there have been no reports about any problems.

Capabilities

  • Key Generation (512, 768, 1024)
  • Encapsulation (512, 768, 1024)
  • Decapsulation (512, 768, 1024)
  • Convert to or from bytes.

Supported & Tested Platforms

  • JVM (Java, Kotlin)
  • Javascript (NPM)

Documentation

Warning

Upgrading to 1.x.x from the 0.x.x versions requires a quick read up with the documentation. This is because there have been massive improvements and changes in the way the API works.

Installation

//Gradle Kotlin DSL (build.gradle.kts)
dependencies {
    implementation("asia.hombre:kyber:1.0.0")
}

Checkout the Wiki for more installation options.

API Usage

Checkout the Wiki or the Documentation for more information.

References

Special Thanks

  • IAmDerek for guiding me in NTT.
  • grhkm for helping me with implementing NTT.
  • versusdkp for providing me a link for intermediates for testing.
  • FiloSottile's mlkem768 which gave me clues to fix bugs in my implementation.
  • Steven Fisher's kyberJCE which helped me run my first tests and use one of its algorithms.
  • and others from CryptoHack community!

License

Copyright 2024 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.