Modern-Apps.git
Publicgit clone https://git.maproj.org/Modern-Apps.gitModern-Apps.git / library / e2ee-p2p / src / main / java / com / vayunmathur / e2ee / PqcNative.kt
PqcNative.kt22 lines · 1007 BRaw
| 1 | package com.vayunmathur.e2ee |
| 2 | |
| 3 | /** |
| 4 | * JNI surface for the native Rust PQC library (libe2ee_pqc.so): ML-KEM-768 + |
| 5 | * ML-DSA-65. All keys are DER (X.509 SPKI / PKCS#8), byte-compatible with the |
| 6 | * previous Bouncy Castle encoding. Keygen/encaps return a two-element |
| 7 | * `byte[][]` = [publicOrCiphertext, privateOrSharedSecret]; null on failure. |
| 8 | */ |
| 9 | internal object PqcNative { |
| 10 | external fun nativeMlkemKeygen(): Array<ByteArray>? |
| 11 | external fun nativeMlkemLinkKeygen(): Array<ByteArray>? |
| 12 | external fun nativeMlkemLinkPubFromSeed(seed: ByteArray): ByteArray? |
| 13 | external fun nativeMldsaKeygen(): Array<ByteArray>? |
| 14 | external fun nativeMlkemEncaps(pubDer: ByteArray): Array<ByteArray>? |
| 15 | external fun nativeMlkemDecaps(privDer: ByteArray, ct: ByteArray): ByteArray? |
| 16 | external fun nativeMldsaSign(privDer: ByteArray, msg: ByteArray): ByteArray? |
| 17 | external fun nativeMldsaVerify(pubDer: ByteArray, msg: ByteArray, sig: ByteArray): Boolean |
| 18 | |
| 19 | init { |
| 20 | System.loadLibrary("e2ee_pqc") |
| 21 | } |
| 22 | } |