mirror of
https://codeberg.org/rag27/kyber-mini.git
synced 2026-10-07 06:19:22 +00:00
No description
- TypeScript 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .gitignore | ||
| build.ts | ||
| index.ts | ||
| package.json | ||
| README.md | ||
| utils.ts | ||
kyber-mini
A minimalistic, high-performance TypeScript/JavaScript implementation of the Kyber KEM and PKE algorithms (standard specified by FIPS203).
Performance
Benchmarks indicate performance on par with noble/post-quantum in Node.js, and approximately 2x faster when running with Bun.
Usage
kyber KEM usage example using ML_KEM1024:
import { kyberKEM1024 } from "kyber-mini";
// generates a pair of private and public keys.
const keys = kyberKEM1024.keyGen();
// creates a shared key and creates a ciphertext from which the recipient can recreate the shared key
const encapsulatedKeys = kyberKEM1024.encapsulate(keys.publicKey);
// recreates the shared key from ciphercode
const sharedKey = kyberKEM1024.decapsulate(encapsulatedKeys.ciphertext, keys.privateKey);
kyber PKE usage example using ML_PKE1024:
import { kyberPKE1024 } from "kyber-mini";
// generates kyber_pke keys
const keys = kyberPKE1024.keyGen();
const message = new Uint8Array(32);
// set a message
// encrypts the message with a public key
const ciphertext = kyberPKE1024.encrypt(message, keys.publicKey);
// decrypts the message with a private key
const decryptedMessage = kyberPKE1024.decrypt(ciphertext, keys.privateKey);
Instalation
bun install kyber-mini
or
npm install kyber-mini
Audit
This library has not been audited by a third party.