A frontend web application demonstrating post-quantum cryptography using Classic McEliece combined with AES-GCM hybrid encryption.
This demo showcases quantum-resistant asymmetric encryption using:
- Classic McEliece (8192128) - A key encapsulation mechanism (KEM) providing ~256-bit post-quantum security
- AES-GCM - Symmetric encryption using the Web Crypto API for actual message encryption
McEliece is a KEM (Key Encapsulation Mechanism), not a direct encryption algorithm. This demo uses a hybrid encryption scheme combining post-quantum key exchange with symmetric encryption:
flowchart TB
subgraph keygen["π Key Generation"]
direction LR
KG[McEliece KeyPair] --> PK["π€ Public Key<br/><i>~1.3 MB</i>"]
KG --> SK["π₯ Private Key<br/><i>~14 KB</i>"]
end
subgraph encrypt["π Encryption"]
direction TB
PK2["Recipient's<br/>Public Key"] --> KEM["McEliece<br/>Encapsulate"]
KEM --> SECRET1["Shared Secret<br/><i>32 bytes</i>"]
KEM --> KEMCT["KEM Ciphertext<br/><i>~240 bytes</i>"]
SECRET1 --> AES["AES-GCM<br/>Encrypt"]
MSG["Plaintext<br/>Message"] --> AES
IV["Random IV<br/><i>12 bytes</i>"] --> AES
AES --> AESCT["Encrypted<br/>Data"]
KEMCT --> PKG["Package"]
IV --> PKG
AESCT --> PKG
PKG --> FINAL["π¦ Final Ciphertext<br/><i>Base64 encoded</i>"]
end
subgraph decrypt["π Decryption"]
direction TB
CT["π¦ Ciphertext"] --> UNPKG["Unpackage"]
UNPKG --> KEMCT2["KEM<br/>Ciphertext"]
UNPKG --> IV2["IV"]
UNPKG --> AESCT2["Encrypted<br/>Data"]
KEMCT2 --> KEMDEC["McEliece<br/>Decapsulate"]
SK2["Your<br/>Private Key"] --> KEMDEC
KEMDEC --> SECRET2["Shared Secret<br/><i>32 bytes</i>"]
SECRET2 --> AESDEC["AES-GCM<br/>Decrypt"]
IV2 --> AESDEC
AESCT2 --> AESDEC
AESDEC --> PLAIN["βοΈ Plaintext<br/>Message"]
end
PK -.->|"share publicly"| encrypt
SK -.->|"keep secret"| decrypt
encrypt -->|"send securely"| decrypt
style keygen stroke:#19FB9B,stroke-width:2px
style encrypt stroke:#19FB9B,stroke-width:2px
style decrypt stroke:#19FB9B,stroke-width:2px
style SECRET1 fill:#19FB9B,color:#000
style SECRET2 fill:#19FB9B,color:#000
-
Encryption:
- McEliece KEM generates a random
shared secret+KEM ciphertextfrom the recipient's public key - AES-GCM encrypts the plaintext using the shared secret as the key
- The KEM ciphertext, IV, and encrypted data are packaged together
- McEliece KEM generates a random
-
Decryption:
- Unpackage the ciphertext components
- McEliece KEM recovers the
shared secretfrom the KEM ciphertext using the private key - AES-GCM decrypts the data using the recovered shared secret
- Key Generation - Generate McEliece keypairs (public key ~1.3 MB, private key ~14 KB)
- Encrypt - Encrypt messages to a recipient's public key
- Decrypt - Decrypt messages using your private key
- File Import/Export - Download and load keys and ciphertexts
- Node.js (v18 or higher recommended)
- npm (comes with Node.js)
- Clone the repository:
git clone <repository-url>
cd pqdemo- Install dependencies:
npm installStart the Vite development server with hot reload:
npm run devThe app will be available at http://localhost:5173
Build the application for production:
npm run buildThis creates an optimized build in the dist/ directory.
Preview the production build locally:
npm run previewpqdemo/
βββ index.html # Main HTML file
βββ app.js # Application logic (key gen, encrypt, decrypt)
βββ style.css # idOS-branded styles
βββ package.json # Dependencies and scripts
βββ vite.config.js # Vite configuration (if present)
βββ README.md # This file
| Package | Version | Description |
|---|---|---|
| mceliece | ^5.0.0 | Classic McEliece post-quantum KEM |
| vite | ^6.0.0 | Frontend build tool (dev dependency) |
For production use:
- Implement proper key management and secure storage
- Use secure channels for key exchange
- Consider key rotation policies
- Audit cryptographic implementation
- Never expose private keys
- Key Sizes: McEliece public keys are large (~1.3 MB) due to the algorithm's design
- Performance: Key generation takes several seconds due to the computational complexity
- Browser Support: Requires browsers with Web Crypto API support (all modern browsers)
MIT
- pqcrypto.js - Post-quantum cryptography library
- idOS Network - Brand design inspiration