calix-pqc là thư viện mã hoá hậu lượng tử kết hợp CRYSTALS-Kyber-768 (KEM) và ChaCha20-Poly1305 (AEAD). Một mã nguồn Rust, một wire format — chạy đồng nhất trên iOS, Android, Flutter, Go và Windows. calix-pqc is a post-quantum cryptography library combining CRYSTALS-Kyber-768 (KEM) and ChaCha20-Poly1305 (AEAD). One Rust core, one wire format — identical on iOS, Android, Flutter, Go and Windows.
Máy tính lượng tử trong tương lai có thể phá vỡ RSA và ECC bằng thuật toán Shor. Dữ liệu mã hoá hôm nay có thể bị "thu thập bây giờ, giải mã sau". PQC dùng bài toán lattice mà cả máy tính cổ điển lẫn lượng tử đều không giải được. Future quantum computers can break RSA and ECC via Shor's algorithm. Data encrypted today can be "harvested now, decrypted later". PQC relies on lattice problems that neither classical nor quantum computers can solve.
Kyber-768 dựa trên Module-LWE, an toàn trước cả Shor và Grover. Đạt chuẩn NIST FIPS 203 (ML-KEM).Kyber-768 is based on Module-LWE, secure against both Shor and Grover. Standardized as NIST FIPS 203 (ML-KEM).
ChaCha20-Poly1305 phát hiện mọi giả mạo bằng tag 16 byte. Mỗi tin nhắn dùng nonce ngẫu nhiên — forward secrecy.ChaCha20-Poly1305 detects any tampering with a 16-byte tag. Each message uses a random nonce — forward secrecy.
Wire format byte-identical: ciphertext tạo bởi Swift giải mã được bằng Kotlin, Flutter hay Go — và ngược lại.Byte-identical wire format: ciphertext from Swift decrypts in Kotlin, Flutter or Go — and vice versa.
Keygen ~0.5ms, encrypt ~0.8ms, decrypt ~0.6ms trên ARM64. Lõi Rust tối ưu, không phụ thuộc runtime.Keygen ~0.5ms, encrypt ~0.8ms, decrypt ~0.6ms on ARM64. Optimized Rust core, no runtime dependencies.
Chỉ ~388KB (.so arm64 Android). Không kéo theo OpenSSL hay thư viện nặng nào khác.Just ~388KB (.so arm64 Android). No OpenSSL or heavy dependencies pulled in.
3 hàm cốt lõi: generateKeyPair, encrypt, decrypt. Có sẵn wrapper Swift, Kotlin, Dart, Go.3 core functions: generateKeyPair, encrypt, decrypt. Ready-made Swift, Kotlin, Dart, Go wrappers.
KEM tạo shared secret từ public key, AEAD mã hoá nội dung. Tất cả gói gọn trong một blob wire-format chuẩn.KEM derives a shared secret from the public key, AEAD encrypts the payload. All packed into one standard wire-format blob.
Bob tạo cặp khoá: publicKey 1184B + secretKey 2400B.Bob creates a key pair: publicKey 1184B + secretKey 2400B.
Bob gửi publicKey cho Alice qua server hoặc QR code.Bob sends publicKey to Alice via server or QR code.
Alice mã hoá tin nhắn bằng publicKey của Bob → ciphertext base64.Alice encrypts with Bob's publicKey → base64 ciphertext.
Bob dùng secretKey giải mã, Poly1305 xác thực toàn vẹn.Bob decrypts with secretKey, Poly1305 verifies integrity.
| Thành phầnComponent | Giá trịValue |
|---|---|
| Public key | 1184 bytes |
| Secret key | 2400 bytes |
| KEM ciphertext | 1088 bytes |
| Shared secret | 32 bytes |
| Overhead / tin nhắnOverhead / message | 1121 bytes |
| Phép đoMetric | Giá trịValue |
|---|---|
| Sinh khoá (ARM64)Keygen (ARM64) | ~0.5 ms |
| Mã hoáEncrypt | ~0.8 ms |
| Giải mãDecrypt | ~0.6 ms |
| .so (Android arm64) | ~388 KB |
| .a (iOS device) | ~5.5 MB |
# Wire format — byte-identical trên mọi nền tảng / on all platforms
[0x04 : 1 byte] magic byte
[kem_ct_len : 4 bytes] little-endian = 1088
[kem_ct : 1088 bytes] Kyber-768 KEM ciphertext
[nonce : 12 bytes] ChaCha20-Poly1305 nonce
[ciphertext : N bytes] encrypted plaintext
[tag : 16 bytes] Poly1305 auth tag
Chọn nền tảng của bạn. Mỗi tab gồm bước cài đặt và đoạn code thật từ thư viện.Pick your platform. Each tab has setup steps and real code from the library.
// 1. Kéo CalixPQC.xcframework vào Xcode → Do Not Embed
// 2. Bridging header: #include <calix_pqc.h>
// 3. Copy CalixPQC.swift vào project
import Foundation
// Sinh khoá (Bob) / Generate keys
let bob = try CalixPQC.generateKeyPair()
// bob.publicKey -> 1184B · bob.secretKey -> 2400B
// Mã hoá (Alice -> Bob) / Encrypt
let ciphertext = try CalixPQC.encrypt("Hello PQC!", publicKey: bob.publicKey)
// Giải mã (Bob) / Decrypt
let plaintext = try CalixPQC.decrypt(ciphertext, secretKey: bob.secretKey)
print(plaintext) // "Hello PQC!"
// Lưu secretKey vào Keychain (production)
saveSecretKeyToKeychain(bob.secretKey,
label: "com.app.pqc.sk") // kSecAttrAccessibleWhenUnlockedThisDeviceOnly
// 1. Copy dist/android/jniLibs/ -> app/src/main/jniLibs/
// 2. Copy CalixPQC.kt vào package com.calixone.pqc
import com.calixone.pqc.CalixPQC
// Sinh khoá / Generate keys
val kp = CalixPQC.generateKeyPair()
// kp.publicKey 1184B · kp.secretKey 2400B · kp.publicKeyBase64
// Mã hoá / Encrypt
val ciphertext = CalixPQC.encrypt("Xin chào PQC!", kp.publicKey)
// Giải mã / Decrypt
val plaintext = CalixPQC.decrypt(ciphertext, kp.secretKey)
Log.d("PQC", plaintext)
// Lưu secretKey an toàn / Store securely
SecureKeyStorage.saveSecretKey(context, kp.secretKey) // Android Keystore + AES-GCM wrap
// 1. iOS: copy CalixPQC.xcframework -> ios/Frameworks/
// 2. Android: copy jniLibs/ -> android/app/src/main/jniLibs/
// 3. pubspec.yaml: ffi: ^2.1.0 · copy calix_pqc.dart vào lib/
import 'calix_pqc.dart';
// Sinh khoá / Generate keys
final kp = CalixPQC.generateKeyPair();
print('PK length: ' + kp.publicKey.length.toString());
// Mã hoá / Encrypt
final ciphertext = CalixPQC.encrypt('Xin chào từ Flutter!', kp.publicKey);
// Giải mã / Decrypt
final plaintext = CalixPQC.decrypt(ciphertext, kp.secretKey);
// 1. ./build.sh macos -> dist/macos/libcalix_pqc.a + calix_pqc.h
// 2. copy vào calix-pqc-go/calix/ (cùng pqc.go CGo wrapper)
package main
import (
"fmt"
"log"
"calix-pqc-go/calix"
)
func main() {
// Sinh khoá / Generate keys
kp, err := calix.GenerateKeyPair()
if err != nil { log.Fatal(err) }
// Mã hoá / Encrypt
ct, _ := calix.EncryptString(kp.PublicKey, "Hello từ Go!")
// Giải mã / Decrypt
msg, _ := calix.DecryptString(kp.SecretKey, ct)
fmt.Println(msg) // "Hello từ Go!"
}
// calix_pqc.h — C ABI. Link libcalix_pqc.a / .so / .dll
#include "calix_pqc.h"
uint8_t pk[CALIX_PK_LEN], sk[CALIX_SK_LEN];
calix_keygen(pk, sk); // 0 = OK
// Encrypt
const char *msg = "Hello PQC!";
size_t cap = calix_encrypt_output_len(strlen(msg));
uint8_t *out = malloc(cap); size_t out_len = cap;
calix_encrypt(pk, (uint8_t*)msg, strlen(msg), out, &out_len);
// Decrypt
uint8_t plain[256]; size_t plen = sizeof(plain);
int rc = calix_decrypt(sk, out, out_len, plain, &plen);
// rc == 0 -> thành công; -1 -> sai key hoặc bị giả mạo
Tất cả gói gồm thư viện đã build sẵn + header C. Không cần cài Rust.Every package ships prebuilt binaries + the C header. No Rust toolchain required.
jniLibs (.so) cho 4 ABI + header CjniLibs (.so) for 4 ABIs + C header
⬇ Tải về⬇ DownloadCalixPQC.xcframework (device + simulator)CalixPQC.xcframework (device + simulator)
⬇ Tải về⬇ DownloadUniversal .a + .dylib (arm64 + x86_64)Universal .a + .dylib (arm64 + x86_64)
⬇ Tải về⬇ DownloadTrọn bộ binary mọi nền tảng trong 1 fileEvery platform binary in one bundle
⬇ Tải về⬇ DownloadSwift / Kotlin / Flutter / Go + GUIDE.mdSwift / Kotlin / Flutter / Go + GUIDE.md
⬇ Tải về⬇ DownloadPublic key (1184B) chia sẻ tự do. Secret key (2400B) tuyệt đối bí mật — chỉ lưu trong Secure Storage.Public key (1184B) shares freely. Secret key (2400B) is absolutely secret — only in Secure Storage.