ronhombre/KyberKotlin
GitHub: ronhombre/KyberKotlin
这是一个纯 Kotlin Multiplatform 实现的 ML-KEM(NIST FIPS 203)后量子密钥封装库,为 Java/Kotlin/Android 应用提供抗量子计算攻击的密钥交换能力。
Stars: 10 | Forks: 0
# KyberKotlin (2.0.1)
## _实现 ML-KEM (CRYSTALS-Kyber)_
_**面向所有人的数字安全,无处不在,无论他们是谁,或信仰什么。**_
[](https://github.com/ronhombre/KyberKotlin/actions/workflows/codeql.yml)
[](https://search.maven.org/#search%7Cga%7C1%7Cg%3A%22asia.hombre%22)
[](https://www.apache.org/licenses/LICENSE-2.0)







*这段话引用自 NIST FIPS 203 文档的
[第 3.2 节](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.203.pdf)。*
## 简介
这是一个 100% Kotlin Multiplatform 的 ML-KEM Final 实现,具有超快的优化。
它依赖于 [KeccakKotlin](https://github.com/ronhombre/KeccakKotlin) 和 [secure-random](https://github.com/KotlinCrypto/secure-random) Kotlin 库,以便在库中实现 SHA3、SHAKE 和 Secure Random。
该库针对每个参数集,对照 Bouncy Castle 的 Java ML-KEM 实现进行了 100 万次测试。为了快速测试,我们还进行了 1 万次测试(参见 JVMTest.kt 文件)。
## 功能
* 密钥生成 (512, 768, 1024)
* 封装 (512, 768, 1024)
* 解封装 (512, 768, 1024)
* 转换为字节或从字节转换。
## 已测试平台
* JVM (Java, Kotlin)
## 支持的目标
| 目标 | Arm32 | Arm64 | X64 |
|---------------------------|--------------------|--------------------|--------------------|
| JVM (Kotlin & Java) | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| Linux | :x: * | :x: ** | :white_check_mark: |
| Windows (Mingw) | :x: * | :x: * | :white_check_mark: |
| Android | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| iOS | :x: * | :x: ** | :x: ** |
| iOS Simulator | :x: * | :x: ** | :x: * |
*注意:某些平台在 Kotlin Multiplatform 中不可用/已弃用作为目标。请将您的投诉发送给 Jetbrains。
**这些目标目前可用,但我**尚**无法编译它们。一旦我有更多空闲时间,我将设置一个发布服务器来编译所有目标。
## 文档
* [kyber.hombre.asia](https://kyber.hombre.asia)
## 安装
### JVM (Kotlin, Java, Android)
**要求:JAVA 8+**
注意:如果 _implementation_ 不起作用,请替换为 _compile_。
### 通过 Maven 的 Gradle
`build.gradle`
```
dependencies {
implementation 'asia.hombre:kyber:2.0.1'
}
```
### 通过 Maven 的 Gradle Kotlin
`build.gradle.kts`
```
dependencies {
implementation("asia.hombre:kyber:2.0.1")
}
```
### Maven
`pom.xml`
```
asia.hombre
kyber
2.0.1
```
查看 [Wiki](https://github.com/ronhombre/KyberKotlin/wiki/Installation) 获取更多安装说明和示例。
## API 用法
查看 Wiki 或文档以获取更多信息。
### 参考资料
* [NIST FIPS 203](https://csrc.nist.gov/pubs/fips/203/final)
* [CRYSTALS-Kyber Algorithm Specs v3.02](https://pq-crystals.org/kyber/data/kyber-specification-round3-20210804.pdf)
* [kyberJCE](https://github.com/fisherstevenk/kyberJCE)
* [CCTestVectors](https://github.com/C2SP/CCTV/)
* [mlkem768](https://github.com/FiloSottile/mlkem768)
* [kyber (C)](https://github.com/pq-crystals/kyber)
* [kyber (Rust)](https://github.com/Argyle-Software/kyber)
* [Montgomery Algorithm](https://www.ams.org/journals/mcom/1985-44-170/S0025-5718-1985-0777282-X/S0025-5718-1985-0777282-X.pdf)
* [Kyber-K2SO (Go)](https://github.com/symbolicsoft/kyber-k2so)
* [Kyber on ARM64](https://eprint.iacr.org/2021/561.pdf) _解释了神秘的 Qinv 值 62209_
### 特别感谢
* IAmDerek 指导我学习 NTT。
* grhkm 帮助我实现 NTT。
* versusdkp 为我提供了用于测试的中间值链接。
* FiloSottile 的 mlkem768 为我提供了修复实现中错误的线索。
* Steven Fisher 的 kyberJCE 帮助我运行了第一批测试并使用了其中的一个算法。
* 以及 CryptoHack 社区的其他人!
### 许可证
```
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.
```
尽管 ML-KEM 被宣布为公共领域,但此实现是由其贡献者的努力创建的。因此,此库的所有用户需要对其工作给予某种形式的认可。
标签:Android安全, Bouncy Castle, CRYSTALS-Kyber, Gradle, iOS加密, Keccak, KEM, KMP, Kotlin, Kotlin Multiplatform, ML-KEM, NIST FIPS 203, PQC, SHA-3, SHAKE, YAML, 信息保密, 后台面板检测, 后量子密码学, 安全库, 密码学, 密钥封装机制, 手动系统调用, 无权限库, 本体建模, 漏洞测试