@oqs/liboqs-js 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +50 -0
- package/README.md +829 -0
- package/bin/cli.js +16 -0
- package/dist/classic-mceliece-348864.deno.js +0 -0
- package/dist/classic-mceliece-348864.min.js +0 -0
- package/dist/classic-mceliece-348864f.deno.js +0 -0
- package/dist/classic-mceliece-348864f.min.js +0 -0
- package/dist/classic-mceliece-460896.deno.js +0 -0
- package/dist/classic-mceliece-460896.min.js +0 -0
- package/dist/classic-mceliece-460896f.deno.js +0 -0
- package/dist/classic-mceliece-460896f.min.js +0 -0
- package/dist/classic-mceliece-6688128.deno.js +0 -0
- package/dist/classic-mceliece-6688128.min.js +0 -0
- package/dist/classic-mceliece-6688128f.deno.js +0 -0
- package/dist/classic-mceliece-6688128f.min.js +0 -0
- package/dist/classic-mceliece-6960119.deno.js +0 -0
- package/dist/classic-mceliece-6960119.min.js +0 -0
- package/dist/classic-mceliece-6960119f.deno.js +0 -0
- package/dist/classic-mceliece-6960119f.min.js +0 -0
- package/dist/classic-mceliece-8192128.deno.js +0 -0
- package/dist/classic-mceliece-8192128.min.js +0 -0
- package/dist/classic-mceliece-8192128f.deno.js +0 -0
- package/dist/classic-mceliece-8192128f.min.js +0 -0
- package/dist/cross-rsdp-128-balanced.deno.js +0 -0
- package/dist/cross-rsdp-128-balanced.min.js +0 -0
- package/dist/cross-rsdp-128-fast.deno.js +0 -0
- package/dist/cross-rsdp-128-fast.min.js +0 -0
- package/dist/cross-rsdp-128-small.deno.js +0 -0
- package/dist/cross-rsdp-128-small.min.js +0 -0
- package/dist/cross-rsdp-192-balanced.deno.js +0 -0
- package/dist/cross-rsdp-192-balanced.min.js +0 -0
- package/dist/cross-rsdp-192-fast.deno.js +0 -0
- package/dist/cross-rsdp-192-fast.min.js +0 -0
- package/dist/cross-rsdp-192-small.deno.js +0 -0
- package/dist/cross-rsdp-192-small.min.js +0 -0
- package/dist/cross-rsdp-256-balanced.deno.js +0 -0
- package/dist/cross-rsdp-256-balanced.min.js +0 -0
- package/dist/cross-rsdp-256-fast.deno.js +0 -0
- package/dist/cross-rsdp-256-fast.min.js +0 -0
- package/dist/cross-rsdp-256-small.deno.js +0 -0
- package/dist/cross-rsdp-256-small.min.js +0 -0
- package/dist/cross-rsdpg-128-balanced.deno.js +0 -0
- package/dist/cross-rsdpg-128-balanced.min.js +0 -0
- package/dist/cross-rsdpg-128-fast.deno.js +0 -0
- package/dist/cross-rsdpg-128-fast.min.js +0 -0
- package/dist/cross-rsdpg-128-small.deno.js +0 -0
- package/dist/cross-rsdpg-128-small.min.js +0 -0
- package/dist/cross-rsdpg-192-balanced.deno.js +0 -0
- package/dist/cross-rsdpg-192-balanced.min.js +0 -0
- package/dist/cross-rsdpg-192-fast.deno.js +0 -0
- package/dist/cross-rsdpg-192-fast.min.js +0 -0
- package/dist/cross-rsdpg-192-small.deno.js +0 -0
- package/dist/cross-rsdpg-192-small.min.js +0 -0
- package/dist/cross-rsdpg-256-balanced.deno.js +0 -0
- package/dist/cross-rsdpg-256-balanced.min.js +0 -0
- package/dist/cross-rsdpg-256-fast.deno.js +0 -0
- package/dist/cross-rsdpg-256-fast.min.js +0 -0
- package/dist/cross-rsdpg-256-small.deno.js +0 -0
- package/dist/cross-rsdpg-256-small.min.js +0 -0
- package/dist/falcon-1024.deno.js +0 -0
- package/dist/falcon-1024.min.js +0 -0
- package/dist/falcon-512.deno.js +0 -0
- package/dist/falcon-512.min.js +0 -0
- package/dist/falcon-padded-1024.deno.js +0 -0
- package/dist/falcon-padded-1024.min.js +0 -0
- package/dist/falcon-padded-512.deno.js +0 -0
- package/dist/falcon-padded-512.min.js +0 -0
- package/dist/frodokem-1344-aes.deno.js +0 -0
- package/dist/frodokem-1344-aes.min.js +0 -0
- package/dist/frodokem-1344-shake.deno.js +0 -0
- package/dist/frodokem-1344-shake.min.js +0 -0
- package/dist/frodokem-640-aes.deno.js +0 -0
- package/dist/frodokem-640-aes.min.js +0 -0
- package/dist/frodokem-640-shake.deno.js +0 -0
- package/dist/frodokem-640-shake.min.js +0 -0
- package/dist/frodokem-976-aes.deno.js +0 -0
- package/dist/frodokem-976-aes.min.js +0 -0
- package/dist/frodokem-976-shake.deno.js +0 -0
- package/dist/frodokem-976-shake.min.js +0 -0
- package/dist/hqc-128.deno.js +0 -0
- package/dist/hqc-128.min.js +0 -0
- package/dist/hqc-192.deno.js +0 -0
- package/dist/hqc-192.min.js +0 -0
- package/dist/hqc-256.deno.js +0 -0
- package/dist/hqc-256.min.js +0 -0
- package/dist/kyber-1024.deno.js +0 -0
- package/dist/kyber-1024.min.js +0 -0
- package/dist/kyber-512.deno.js +0 -0
- package/dist/kyber-512.min.js +0 -0
- package/dist/kyber-768.deno.js +0 -0
- package/dist/kyber-768.min.js +0 -0
- package/dist/mayo-1.deno.js +0 -0
- package/dist/mayo-1.min.js +0 -0
- package/dist/mayo-2.deno.js +0 -0
- package/dist/mayo-2.min.js +0 -0
- package/dist/mayo-3.deno.js +0 -0
- package/dist/mayo-3.min.js +0 -0
- package/dist/mayo-5.deno.js +0 -0
- package/dist/mayo-5.min.js +0 -0
- package/dist/ml-dsa-44.deno.js +0 -0
- package/dist/ml-dsa-44.min.js +0 -0
- package/dist/ml-dsa-65.deno.js +0 -0
- package/dist/ml-dsa-65.min.js +0 -0
- package/dist/ml-dsa-87.deno.js +0 -0
- package/dist/ml-dsa-87.min.js +0 -0
- package/dist/ml-kem-1024.deno.js +0 -0
- package/dist/ml-kem-1024.min.js +0 -0
- package/dist/ml-kem-512.deno.js +0 -0
- package/dist/ml-kem-512.min.js +0 -0
- package/dist/ml-kem-768.deno.js +0 -0
- package/dist/ml-kem-768.min.js +0 -0
- package/dist/ntru-hps-2048-509.deno.js +0 -0
- package/dist/ntru-hps-2048-509.min.js +0 -0
- package/dist/ntru-hps-2048-677.deno.js +0 -0
- package/dist/ntru-hps-2048-677.min.js +0 -0
- package/dist/ntru-hps-4096-1229.deno.js +0 -0
- package/dist/ntru-hps-4096-1229.min.js +0 -0
- package/dist/ntru-hps-4096-821.deno.js +0 -0
- package/dist/ntru-hps-4096-821.min.js +0 -0
- package/dist/ntru-hrss-1373.deno.js +0 -0
- package/dist/ntru-hrss-1373.min.js +0 -0
- package/dist/ntru-hrss-701.deno.js +0 -0
- package/dist/ntru-hrss-701.min.js +0 -0
- package/dist/ov-iii-pkc-skc.deno.js +0 -0
- package/dist/ov-iii-pkc-skc.min.js +0 -0
- package/dist/ov-iii-pkc.deno.js +0 -0
- package/dist/ov-iii-pkc.min.js +0 -0
- package/dist/ov-iii.deno.js +0 -0
- package/dist/ov-iii.min.js +0 -0
- package/dist/ov-ip-pkc-skc.deno.js +0 -0
- package/dist/ov-ip-pkc-skc.min.js +0 -0
- package/dist/ov-ip-pkc.deno.js +0 -0
- package/dist/ov-ip-pkc.min.js +0 -0
- package/dist/ov-ip.deno.js +0 -0
- package/dist/ov-ip.min.js +0 -0
- package/dist/ov-is-pkc-skc.deno.js +0 -0
- package/dist/ov-is-pkc-skc.min.js +0 -0
- package/dist/ov-is-pkc.deno.js +0 -0
- package/dist/ov-is-pkc.min.js +0 -0
- package/dist/ov-is.deno.js +0 -0
- package/dist/ov-is.min.js +0 -0
- package/dist/ov-v-pkc-skc.deno.js +0 -0
- package/dist/ov-v-pkc-skc.min.js +0 -0
- package/dist/ov-v-pkc.deno.js +0 -0
- package/dist/ov-v-pkc.min.js +0 -0
- package/dist/ov-v.deno.js +0 -0
- package/dist/ov-v.min.js +0 -0
- package/dist/slh-dsa-sha2-128f.deno.js +0 -0
- package/dist/slh-dsa-sha2-128f.min.js +0 -0
- package/dist/slh-dsa-sha2-128s.deno.js +0 -0
- package/dist/slh-dsa-sha2-128s.min.js +0 -0
- package/dist/slh-dsa-sha2-192f.deno.js +0 -0
- package/dist/slh-dsa-sha2-192f.min.js +0 -0
- package/dist/slh-dsa-sha2-192s.deno.js +0 -0
- package/dist/slh-dsa-sha2-192s.min.js +0 -0
- package/dist/slh-dsa-sha2-256f.deno.js +0 -0
- package/dist/slh-dsa-sha2-256f.min.js +0 -0
- package/dist/slh-dsa-sha2-256s.deno.js +0 -0
- package/dist/slh-dsa-sha2-256s.min.js +0 -0
- package/dist/slh-dsa-shake-128f.deno.js +0 -0
- package/dist/slh-dsa-shake-128f.min.js +0 -0
- package/dist/slh-dsa-shake-128s.deno.js +0 -0
- package/dist/slh-dsa-shake-128s.min.js +0 -0
- package/dist/slh-dsa-shake-192f.deno.js +0 -0
- package/dist/slh-dsa-shake-192f.min.js +0 -0
- package/dist/slh-dsa-shake-192s.deno.js +0 -0
- package/dist/slh-dsa-shake-192s.min.js +0 -0
- package/dist/slh-dsa-shake-256f.deno.js +0 -0
- package/dist/slh-dsa-shake-256f.min.js +0 -0
- package/dist/slh-dsa-shake-256s.deno.js +0 -0
- package/dist/slh-dsa-shake-256s.min.js +0 -0
- package/dist/snova-24-5-4-esk.deno.js +0 -0
- package/dist/snova-24-5-4-esk.min.js +0 -0
- package/dist/snova-24-5-4-shake-esk.deno.js +0 -0
- package/dist/snova-24-5-4-shake-esk.min.js +0 -0
- package/dist/snova-24-5-4-shake.deno.js +0 -0
- package/dist/snova-24-5-4-shake.min.js +0 -0
- package/dist/snova-24-5-4.deno.js +0 -0
- package/dist/snova-24-5-4.min.js +0 -0
- package/dist/snova-24-5-5.deno.js +0 -0
- package/dist/snova-24-5-5.min.js +0 -0
- package/dist/snova-25-8-3.deno.js +0 -0
- package/dist/snova-25-8-3.min.js +0 -0
- package/dist/snova-29-6-5.deno.js +0 -0
- package/dist/snova-29-6-5.min.js +0 -0
- package/dist/snova-37-17-2.deno.js +0 -0
- package/dist/snova-37-17-2.min.js +0 -0
- package/dist/snova-37-8-4.deno.js +0 -0
- package/dist/snova-37-8-4.min.js +0 -0
- package/dist/snova-49-11-3.deno.js +0 -0
- package/dist/snova-49-11-3.min.js +0 -0
- package/dist/snova-56-25-2.deno.js +0 -0
- package/dist/snova-56-25-2.min.js +0 -0
- package/dist/snova-60-10-4.deno.js +0 -0
- package/dist/snova-60-10-4.min.js +0 -0
- package/dist/sntrup761.deno.js +0 -0
- package/dist/sntrup761.min.js +0 -0
- package/package.json +108 -0
- package/src/algorithms/kem/classic-mceliece/classic-mceliece-348864.js +336 -0
- package/src/algorithms/kem/classic-mceliece/classic-mceliece-348864f.js +336 -0
- package/src/algorithms/kem/classic-mceliece/classic-mceliece-460896.js +336 -0
- package/src/algorithms/kem/classic-mceliece/classic-mceliece-460896f.js +336 -0
- package/src/algorithms/kem/classic-mceliece/classic-mceliece-6688128.js +336 -0
- package/src/algorithms/kem/classic-mceliece/classic-mceliece-6688128f.js +336 -0
- package/src/algorithms/kem/classic-mceliece/classic-mceliece-6960119.js +336 -0
- package/src/algorithms/kem/classic-mceliece/classic-mceliece-6960119f.js +336 -0
- package/src/algorithms/kem/classic-mceliece/classic-mceliece-8192128.js +336 -0
- package/src/algorithms/kem/classic-mceliece/classic-mceliece-8192128f.js +336 -0
- package/src/algorithms/kem/frodokem/efrodokem-1344-aes.js +366 -0
- package/src/algorithms/kem/frodokem/efrodokem-1344-shake.js +366 -0
- package/src/algorithms/kem/frodokem/efrodokem-640-aes.js +366 -0
- package/src/algorithms/kem/frodokem/efrodokem-640-shake.js +366 -0
- package/src/algorithms/kem/frodokem/efrodokem-976-aes.js +366 -0
- package/src/algorithms/kem/frodokem/efrodokem-976-shake.js +366 -0
- package/src/algorithms/kem/frodokem/frodokem-1344-aes.js +366 -0
- package/src/algorithms/kem/frodokem/frodokem-1344-shake.js +366 -0
- package/src/algorithms/kem/frodokem/frodokem-640-aes.js +366 -0
- package/src/algorithms/kem/frodokem/frodokem-640-shake.js +366 -0
- package/src/algorithms/kem/frodokem/frodokem-976-aes.js +366 -0
- package/src/algorithms/kem/frodokem/frodokem-976-shake.js +366 -0
- package/src/algorithms/kem/hqc/hqc-128.js +366 -0
- package/src/algorithms/kem/hqc/hqc-192.js +366 -0
- package/src/algorithms/kem/hqc/hqc-256.js +366 -0
- package/src/algorithms/kem/kyber/kyber-1024.js +349 -0
- package/src/algorithms/kem/kyber/kyber-512.js +347 -0
- package/src/algorithms/kem/kyber/kyber-768.js +348 -0
- package/src/algorithms/kem/ml-kem/ml-kem-1024.js +345 -0
- package/src/algorithms/kem/ml-kem/ml-kem-512.js +345 -0
- package/src/algorithms/kem/ml-kem/ml-kem-768.js +344 -0
- package/src/algorithms/kem/ntru/ntru-hps-2048-509.js +366 -0
- package/src/algorithms/kem/ntru/ntru-hps-2048-677.js +366 -0
- package/src/algorithms/kem/ntru/ntru-hps-4096-1229.js +366 -0
- package/src/algorithms/kem/ntru/ntru-hps-4096-821.js +366 -0
- package/src/algorithms/kem/ntru/ntru-hrss-1373.js +366 -0
- package/src/algorithms/kem/ntru/ntru-hrss-701.js +366 -0
- package/src/algorithms/kem/ntru/sntrup761.js +367 -0
- package/src/algorithms/sig/cross/cross-rsdp-128-balanced.js +391 -0
- package/src/algorithms/sig/cross/cross-rsdp-128-fast.js +391 -0
- package/src/algorithms/sig/cross/cross-rsdp-128-small.js +391 -0
- package/src/algorithms/sig/cross/cross-rsdp-192-balanced.js +391 -0
- package/src/algorithms/sig/cross/cross-rsdp-192-fast.js +391 -0
- package/src/algorithms/sig/cross/cross-rsdp-192-small.js +391 -0
- package/src/algorithms/sig/cross/cross-rsdp-256-balanced.js +391 -0
- package/src/algorithms/sig/cross/cross-rsdp-256-fast.js +391 -0
- package/src/algorithms/sig/cross/cross-rsdp-256-small.js +391 -0
- package/src/algorithms/sig/cross/cross-rsdpg-128-balanced.js +391 -0
- package/src/algorithms/sig/cross/cross-rsdpg-128-fast.js +391 -0
- package/src/algorithms/sig/cross/cross-rsdpg-128-small.js +391 -0
- package/src/algorithms/sig/cross/cross-rsdpg-192-balanced.js +391 -0
- package/src/algorithms/sig/cross/cross-rsdpg-192-fast.js +391 -0
- package/src/algorithms/sig/cross/cross-rsdpg-192-small.js +391 -0
- package/src/algorithms/sig/cross/cross-rsdpg-256-balanced.js +391 -0
- package/src/algorithms/sig/cross/cross-rsdpg-256-fast.js +391 -0
- package/src/algorithms/sig/cross/cross-rsdpg-256-small.js +391 -0
- package/src/algorithms/sig/falcon/falcon-1024.js +378 -0
- package/src/algorithms/sig/falcon/falcon-512.js +379 -0
- package/src/algorithms/sig/falcon/falcon-padded-1024.js +380 -0
- package/src/algorithms/sig/falcon/falcon-padded-512.js +380 -0
- package/src/algorithms/sig/mayo/mayo-1.js +390 -0
- package/src/algorithms/sig/mayo/mayo-2.js +390 -0
- package/src/algorithms/sig/mayo/mayo-3.js +390 -0
- package/src/algorithms/sig/mayo/mayo-5.js +390 -0
- package/src/algorithms/sig/ml-dsa/ml-dsa-44.js +338 -0
- package/src/algorithms/sig/ml-dsa/ml-dsa-65.js +338 -0
- package/src/algorithms/sig/ml-dsa/ml-dsa-87.js +338 -0
- package/src/algorithms/sig/slh-dsa/slh-dsa-sha2-128f.js +367 -0
- package/src/algorithms/sig/slh-dsa/slh-dsa-sha2-128s.js +367 -0
- package/src/algorithms/sig/slh-dsa/slh-dsa-sha2-192f.js +367 -0
- package/src/algorithms/sig/slh-dsa/slh-dsa-sha2-192s.js +367 -0
- package/src/algorithms/sig/slh-dsa/slh-dsa-sha2-256f.js +367 -0
- package/src/algorithms/sig/slh-dsa/slh-dsa-sha2-256s.js +367 -0
- package/src/algorithms/sig/slh-dsa/slh-dsa-shake-128f.js +367 -0
- package/src/algorithms/sig/slh-dsa/slh-dsa-shake-128s.js +367 -0
- package/src/algorithms/sig/slh-dsa/slh-dsa-shake-192f.js +367 -0
- package/src/algorithms/sig/slh-dsa/slh-dsa-shake-192s.js +367 -0
- package/src/algorithms/sig/slh-dsa/slh-dsa-shake-256f.js +367 -0
- package/src/algorithms/sig/slh-dsa/slh-dsa-shake-256s.js +367 -0
- package/src/algorithms/sig/snova/snova-24-5-4-esk.js +391 -0
- package/src/algorithms/sig/snova/snova-24-5-4-shake-esk.js +391 -0
- package/src/algorithms/sig/snova/snova-24-5-4-shake.js +391 -0
- package/src/algorithms/sig/snova/snova-24-5-4.js +391 -0
- package/src/algorithms/sig/snova/snova-24-5-5.js +391 -0
- package/src/algorithms/sig/snova/snova-25-8-3.js +391 -0
- package/src/algorithms/sig/snova/snova-29-6-5.js +391 -0
- package/src/algorithms/sig/snova/snova-37-17-2.js +391 -0
- package/src/algorithms/sig/snova/snova-37-8-4.js +391 -0
- package/src/algorithms/sig/snova/snova-49-11-3.js +391 -0
- package/src/algorithms/sig/snova/snova-56-25-2.js +391 -0
- package/src/algorithms/sig/snova/snova-60-10-4.js +391 -0
- package/src/algorithms/sig/uov/ov-iii-pkc-skc.js +390 -0
- package/src/algorithms/sig/uov/ov-iii-pkc.js +390 -0
- package/src/algorithms/sig/uov/ov-iii.js +390 -0
- package/src/algorithms/sig/uov/ov-ip-pkc-skc.js +390 -0
- package/src/algorithms/sig/uov/ov-ip-pkc.js +390 -0
- package/src/algorithms/sig/uov/ov-ip.js +390 -0
- package/src/algorithms/sig/uov/ov-is-pkc-skc.js +390 -0
- package/src/algorithms/sig/uov/ov-is-pkc.js +390 -0
- package/src/algorithms/sig/uov/ov-is.js +390 -0
- package/src/algorithms/sig/uov/ov-v-pkc-skc.js +390 -0
- package/src/algorithms/sig/uov/ov-v-pkc.js +390 -0
- package/src/algorithms/sig/uov/ov-v.js +390 -0
- package/src/cli/algorithms.js +254 -0
- package/src/cli/commands/info.js +35 -0
- package/src/cli/commands/kem.js +91 -0
- package/src/cli/commands/list.js +30 -0
- package/src/cli/commands/sig.js +98 -0
- package/src/cli/index.js +86 -0
- package/src/cli/io.js +147 -0
- package/src/cli/parser.js +64 -0
- package/src/core/errors.js +75 -0
- package/src/core/validation.js +28 -0
- package/src/index.js +164 -0
- package/src/kem.js +60 -0
- package/src/sig.js +87 -0
- package/src/types/algorithms.d.ts +1543 -0
- package/src/types/errors.d.ts +60 -0
- package/src/types/index.d.ts +9 -0
package/README.md
ADDED
|
@@ -0,0 +1,829 @@
|
|
|
1
|
+
# @oqs/liboqs-js
|
|
2
|
+
|
|
3
|
+
[](https://opensource.org/licenses/MIT)
|
|
4
|
+
[](https://nodejs.org/)
|
|
5
|
+
|
|
6
|
+
A JavaScript/TypeScript wrapper for [LibOQS](https://github.com/open-quantum-safe/liboqs), providing access to post-quantum cryptographic algorithms for key encapsulation mechanisms (KEM) and digital signatures.
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
This library provides WebAssembly bindings to LibOQS, part of the [Open Quantum Safe](https://openquantumsafe.org/) project. It includes:
|
|
11
|
+
|
|
12
|
+
- Individual WASM modules per algorithm for optimal bundle sizes
|
|
13
|
+
- TypeScript definitions for complete type safety
|
|
14
|
+
- Support for Node.js and browser environments
|
|
15
|
+
- SIMD-optimized builds for maximum performance
|
|
16
|
+
- Tree-shakable ES module exports to minimize bundle size
|
|
17
|
+
- Automatic memory management and secure cleanup
|
|
18
|
+
|
|
19
|
+
## Status
|
|
20
|
+
|
|
21
|
+
### ⚠️ Important Notice
|
|
22
|
+
|
|
23
|
+
**This library is meant for research, prototyping, and experimentation.** While the underlying LibOQS library is well-maintained by the Open Quantum Safe project, both projects carry important caveats:
|
|
24
|
+
|
|
25
|
+
- Most post-quantum algorithms have not received the same level of scrutiny as traditional cryptography
|
|
26
|
+
- Algorithm support may change rapidly as research advances
|
|
27
|
+
- Some algorithms may prove insecure against classical or quantum computers
|
|
28
|
+
- This library has not received a formal security audit
|
|
29
|
+
|
|
30
|
+
**If you must use post-quantum cryptography in production environments**, use **hybrid approaches** that combine post-quantum algorithms with traditional algorithms (e.g., ML-KEM with X25519, ML-DSA with Ed25519). This provides defense-in-depth during the transition period.
|
|
31
|
+
|
|
32
|
+
For production deployments, follow guidance from NIST's [Post-Quantum Cryptography Standardization](https://csrc.nist.gov/Projects/post-quantum-cryptography) project.
|
|
33
|
+
|
|
34
|
+
### NIST Standardized Algorithms
|
|
35
|
+
|
|
36
|
+
The algorithms implementing NIST FIPS standards are:
|
|
37
|
+
- **ML-KEM** (FIPS 203, formerly Kyber): ML-KEM-512, ML-KEM-768, ML-KEM-1024
|
|
38
|
+
- **ML-DSA** (FIPS 204, formerly Dilithium): ML-DSA-44, ML-DSA-65, ML-DSA-87
|
|
39
|
+
- **SLH-DSA** (FIPS 205, formerly SPHINCS+): 12 variants (SHA2 and SHAKE, 128/192/256-bit security, f/s modes)
|
|
40
|
+
|
|
41
|
+
These algorithm names are stable and will be maintained. If NIST updates implementation details, this library will track those changes as closely as possible.
|
|
42
|
+
|
|
43
|
+
### Available Algorithms
|
|
44
|
+
|
|
45
|
+
The library provides JavaScript wrappers for **103 algorithms** including experimental and alternative post-quantum schemes:
|
|
46
|
+
|
|
47
|
+
<details>
|
|
48
|
+
<summary>Key Encapsulation Mechanisms (38 algorithms)</summary>
|
|
49
|
+
|
|
50
|
+
- **Kyber** (legacy, use ML-KEM): `Kyber512`, `Kyber768`, `Kyber1024`
|
|
51
|
+
- **Classic McEliece**: 10 variants (`Classic-McEliece-348864` through `Classic-McEliece-8192128f`)
|
|
52
|
+
- **FrodoKEM**: 6 salted variants (AES and SHAKE, 640/976/1344-bit)
|
|
53
|
+
- **eFrodoKEM**: 6 ephemeral variants (AES and SHAKE, 640/976/1344-bit)
|
|
54
|
+
- **HQC**: `HQC-128`, `HQC-192`, `HQC-256`
|
|
55
|
+
- **NTRU**: 6 variants (HPS and HRSS families)
|
|
56
|
+
- **NTRU Prime**: `sntrup761`
|
|
57
|
+
|
|
58
|
+
**Note**: BIKE family is not supported due to WASM incompatibility (requires platform-specific optimizations).
|
|
59
|
+
|
|
60
|
+
</details>
|
|
61
|
+
|
|
62
|
+
<details>
|
|
63
|
+
<summary>Digital Signatures (65 algorithms)</summary>
|
|
64
|
+
|
|
65
|
+
- **Falcon**: `Falcon-512`, `Falcon-1024`, `Falcon-padded-512`, `Falcon-padded-1024`
|
|
66
|
+
- **SLH-DSA** (FIPS 205): 12 variants (SHA2 and SHAKE, 128/192/256-bit security, f/s modes)
|
|
67
|
+
- **CROSS**: 18 variants (RSDP and RSDPG parameter sets with balanced/fast/small tradeoffs)
|
|
68
|
+
- **MAYO**: `MAYO-1`, `MAYO-2`, `MAYO-3`, `MAYO-5`
|
|
69
|
+
- **SNOVA**: 12 variants (various parameter sets)
|
|
70
|
+
- **UOV**: 12 variants (Ip, Is, III, V with different optimization levels)
|
|
71
|
+
|
|
72
|
+
</details>
|
|
73
|
+
|
|
74
|
+
See `algorithms.json` for the complete algorithm registry, or [the algorithms section](#available-algorithms-1). All 103 algorithms have WASM modules, JavaScript wrappers, TypeScript definitions, and test coverage.
|
|
75
|
+
|
|
76
|
+
## Installation
|
|
77
|
+
|
|
78
|
+
This package works with all major JavaScript package managers:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
# bun (recommended - fastest)
|
|
82
|
+
bun add @oqs/liboqs-js
|
|
83
|
+
|
|
84
|
+
# npm
|
|
85
|
+
npm install @oqs/liboqs-js
|
|
86
|
+
|
|
87
|
+
# pnpm
|
|
88
|
+
pnpm add @oqs/liboqs-js
|
|
89
|
+
|
|
90
|
+
# yarn
|
|
91
|
+
yarn add @oqs/liboqs-js
|
|
92
|
+
|
|
93
|
+
# deno (via npm: specifier - no install needed)
|
|
94
|
+
# See "Deno Usage" section below
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
This project uses **bun** by default for development, but all package managers are fully supported.
|
|
98
|
+
|
|
99
|
+
### Deno Usage
|
|
100
|
+
|
|
101
|
+
✅ **Fully Supported** - Available through **npm** only due to package size limitations on JSR:
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
// Alternative: Import from npm
|
|
105
|
+
import { createMLKEM768 } from "npm:@oqs/liboqs-js";
|
|
106
|
+
|
|
107
|
+
const kem = await createMLKEM768();
|
|
108
|
+
const { publicKey, secretKey } = kem.generateKeyPair();
|
|
109
|
+
kem.destroy();
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**How it works:** The library automatically detects the Deno runtime and loads optimized WASM modules built for deno compatibility (`ENVIRONMENT='web'` Emscripten build).
|
|
113
|
+
|
|
114
|
+
**Recommended Setup** - Create a `deno.json` for cleaner imports:
|
|
115
|
+
```json
|
|
116
|
+
{
|
|
117
|
+
"imports": {
|
|
118
|
+
"liboqs": "npm:@oqs/liboqs-js@^0.15.0"
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Then import like:
|
|
124
|
+
```typescript
|
|
125
|
+
import { createMLKEM768 } from "liboqs";
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
**Using the CLI with Deno:**
|
|
129
|
+
```bash
|
|
130
|
+
# Run CLI directly (JSR)
|
|
131
|
+
deno run --allow-read npm:@oqs/liboqs-js/cli kem keygen ml-kem-768
|
|
132
|
+
|
|
133
|
+
# Or from npm
|
|
134
|
+
deno run --allow-read npm:@oqs/liboqs-js/cli kem keygen ml-kem-768
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
```json
|
|
138
|
+
# Or add to deno.json tasks:
|
|
139
|
+
{
|
|
140
|
+
"tasks": {
|
|
141
|
+
"liboqs": "deno run --allow-read npm:@oqs/liboqs-js/cli"
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
```bash
|
|
146
|
+
# Then run:
|
|
147
|
+
deno task liboqs list --kem
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
**Permissions:**
|
|
151
|
+
```bash
|
|
152
|
+
# Library usage (cryptographic operations only)
|
|
153
|
+
deno run --allow-read your-script.ts
|
|
154
|
+
|
|
155
|
+
# CLI usage (may need write for output files)
|
|
156
|
+
deno run --allow-read --allow-write npm:@oqs/liboqs-js/cli kem keygen ml-kem-768 --output-dir ./keys
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Deno automatically caches packages on first run - no separate install step needed.
|
|
160
|
+
|
|
161
|
+
## Requirements
|
|
162
|
+
|
|
163
|
+
- **Node.js 22.0 or higher** (for WASM SIMD support)
|
|
164
|
+
- **Package Managers**: Bun 1.0+, npm 10+, pnpm 8+, yarn 4+ (for Node.js)
|
|
165
|
+
- **Deno 2.0+** (available only through npm)
|
|
166
|
+
- **Modern browsers** with WebAssembly support (Chrome 91+, Firefox 89+, Edge 91+, Safari 16.4+ - Safari is untested)
|
|
167
|
+
|
|
168
|
+
## Quick Start
|
|
169
|
+
|
|
170
|
+
### Command Line Interface
|
|
171
|
+
|
|
172
|
+
The package includes a CLI for cryptographic operations without writing code:
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
# Generate ML-KEM-768 keypair
|
|
176
|
+
npx @oqs/liboqs-js kem keygen ml-kem-768 --output-dir ./keys
|
|
177
|
+
|
|
178
|
+
# Encapsulate to create shared secret
|
|
179
|
+
npx @oqs/liboqs-js kem encapsulate ml-kem-768 ./keys/public.key --format base64
|
|
180
|
+
|
|
181
|
+
# Sign a message
|
|
182
|
+
npx @oqs/liboqs-js sig sign ml-dsa-65 message.txt ./keys/secret.key -o signature.sig
|
|
183
|
+
|
|
184
|
+
# Verify signature
|
|
185
|
+
npx @oqs/liboqs-js sig verify ml-dsa-65 message.txt signature.sig ./keys/public.key
|
|
186
|
+
|
|
187
|
+
# List available algorithms
|
|
188
|
+
npx @oqs/liboqs-js list --kem
|
|
189
|
+
|
|
190
|
+
# Get algorithm info
|
|
191
|
+
npx @oqs/liboqs-js info ml-kem-768
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
**Works with all package managers:**
|
|
195
|
+
- `npx @oqs/liboqs-js` (npm)
|
|
196
|
+
- `bunx @oqs/liboqs-js` (bun)
|
|
197
|
+
- `pnpm dlx @oqs/liboqs-js` (pnpm)
|
|
198
|
+
- `yarn dlx @oqs/liboqs-js` (yarn)
|
|
199
|
+
|
|
200
|
+
**For full CLI documentation, run:**
|
|
201
|
+
```bash
|
|
202
|
+
npx @oqs/liboqs-js --help
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### Key Encapsulation (ML-KEM)
|
|
206
|
+
|
|
207
|
+
```javascript
|
|
208
|
+
import { createMLKEM768 } from '@oqs/liboqs-js';
|
|
209
|
+
|
|
210
|
+
// Alice generates keypair
|
|
211
|
+
const alice = await createMLKEM768();
|
|
212
|
+
const { publicKey, secretKey } = alice.generateKeyPair();
|
|
213
|
+
|
|
214
|
+
// Bob encapsulates shared secret
|
|
215
|
+
const bob = await createMLKEM768();
|
|
216
|
+
const { ciphertext, sharedSecret } = bob.encapsulate(publicKey);
|
|
217
|
+
|
|
218
|
+
// Alice decapsulates
|
|
219
|
+
const aliceSecret = alice.decapsulate(ciphertext, secretKey);
|
|
220
|
+
|
|
221
|
+
// Verify shared secrets match
|
|
222
|
+
console.log('Secrets match:', Buffer.compare(sharedSecret, aliceSecret) === 0);
|
|
223
|
+
|
|
224
|
+
// Cleanup
|
|
225
|
+
alice.destroy();
|
|
226
|
+
bob.destroy();
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### Digital Signatures (ML-DSA)
|
|
230
|
+
|
|
231
|
+
```javascript
|
|
232
|
+
import { createMLDSA65 } from '@oqs/liboqs-js';
|
|
233
|
+
|
|
234
|
+
const signer = await createMLDSA65();
|
|
235
|
+
const { publicKey, secretKey } = signer.generateKeyPair();
|
|
236
|
+
|
|
237
|
+
const message = new TextEncoder().encode('Hello, quantum world!');
|
|
238
|
+
const signature = signer.sign(message, secretKey);
|
|
239
|
+
|
|
240
|
+
const isValid = signer.verify(message, signature, publicKey);
|
|
241
|
+
console.log('Valid:', isValid); // true
|
|
242
|
+
|
|
243
|
+
signer.destroy();
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
## Available Algorithms
|
|
247
|
+
|
|
248
|
+
### NIST Standardized (Recommended)
|
|
249
|
+
|
|
250
|
+
These are the officially standardized post-quantum cryptographic algorithms approved by NIST for production use.
|
|
251
|
+
|
|
252
|
+
#### Key Encapsulation - ML-KEM (Module-Lattice-Based KEM)
|
|
253
|
+
|
|
254
|
+
| Algorithm | Security Level | Public Key | Secret Key | Ciphertext | Factory Function |
|
|
255
|
+
|-----------|----------------|------------|------------|------------|------------------|
|
|
256
|
+
| ML-KEM-512 | Level 1 (128-bit) | 800 B | 1,632 B | 768 B | `createMLKEM512()` |
|
|
257
|
+
| ML-KEM-768 | Level 3 (192-bit) | 1,184 B | 2,400 B | 1,088 B | `createMLKEM768()` |
|
|
258
|
+
| ML-KEM-1024 | Level 5 (256-bit) | 1,568 B | 3,168 B | 1,568 B | `createMLKEM1024()` |
|
|
259
|
+
|
|
260
|
+
**Formerly known as**: CRYSTALS-Kyber
|
|
261
|
+
|
|
262
|
+
#### Digital Signatures - ML-DSA (Module-Lattice-Based DSA)
|
|
263
|
+
|
|
264
|
+
| Algorithm | Security Level | Public Key | Secret Key | Signature | Factory Function |
|
|
265
|
+
|-----------|----------------|------------|------------|-----------|------------------|
|
|
266
|
+
| ML-DSA-44 | Level 2 (128-bit) | 1,312 B | 2,560 B | ~2,420 B | `createMLDSA44()` |
|
|
267
|
+
| ML-DSA-65 | Level 3 (192-bit) | 1,952 B | 4,032 B | ~3,309 B | `createMLDSA65()` |
|
|
268
|
+
| ML-DSA-87 | Level 5 (256-bit) | 2,592 B | 4,896 B | ~4,627 B | `createMLDSA87()` |
|
|
269
|
+
|
|
270
|
+
**Formerly known as**: CRYSTALS-Dilithium
|
|
271
|
+
|
|
272
|
+
#### Digital Signatures - SLH-DSA (Stateless Hash-Based DSA)
|
|
273
|
+
|
|
274
|
+
| Algorithm | Security Level | Public Key | Secret Key | Signature | Factory Function |
|
|
275
|
+
|-----------|----------------|------------|------------|-----------|------------------|
|
|
276
|
+
| SLH-DSA-SHA2-128f | Level 1 (128-bit) | 32 B | 64 B | 17,088 B | `createSLHDSASHA2128f()` |
|
|
277
|
+
| SLH-DSA-SHA2-128s | Level 1 (128-bit) | 32 B | 64 B | 7,856 B | `createSLHDSASHA2128s()` |
|
|
278
|
+
| SLH-DSA-SHA2-192f | Level 3 (192-bit) | 48 B | 96 B | 35,664 B | `createSLHDSASHA2192f()` |
|
|
279
|
+
| SLH-DSA-SHA2-192s | Level 3 (192-bit) | 48 B | 96 B | 16,224 B | `createSLHDSASHA2192s()` |
|
|
280
|
+
| SLH-DSA-SHA2-256f | Level 5 (256-bit) | 64 B | 128 B | 49,856 B | `createSLHDSASHA2256f()` |
|
|
281
|
+
| SLH-DSA-SHA2-256s | Level 5 (256-bit) | 64 B | 128 B | 29,792 B | `createSLHDSASHA2256s()` |
|
|
282
|
+
| SLH-DSA-SHAKE-128f | Level 1 (128-bit) | 32 B | 64 B | 17,088 B | `createSLHDSASHAKE128f()` |
|
|
283
|
+
| SLH-DSA-SHAKE-128s | Level 1 (128-bit) | 32 B | 64 B | 7,856 B | `createSLHDSASHAKE128s()` |
|
|
284
|
+
| SLH-DSA-SHAKE-192f | Level 3 (192-bit) | 48 B | 96 B | 35,664 B | `createSLHDSASHAKE192f()` |
|
|
285
|
+
| SLH-DSA-SHAKE-192s | Level 3 (192-bit) | 48 B | 96 B | 16,224 B | `createSLHDSASHAKE192s()` |
|
|
286
|
+
| SLH-DSA-SHAKE-256f | Level 5 (256-bit) | 64 B | 128 B | 49,856 B | `createSLHDSASHAKE256f()` |
|
|
287
|
+
| SLH-DSA-SHAKE-256s | Level 5 (256-bit) | 64 B | 128 B | 29,792 B | `createSLHDSASHAKE256s()` |
|
|
288
|
+
|
|
289
|
+
**Formerly known as**: SPHINCS+
|
|
290
|
+
**Variants**: `f` = fast signing/slower verification, `s` = small signatures/slower signing
|
|
291
|
+
|
|
292
|
+
### Additional Algorithms
|
|
293
|
+
|
|
294
|
+
Beyond the NIST-standardized algorithms, this library includes experimental and alternative post-quantum schemes for research purposes.
|
|
295
|
+
|
|
296
|
+
#### Legacy Kyber (Deprecated)
|
|
297
|
+
|
|
298
|
+
| Algorithm | Security Level | Public Key | Secret Key | Ciphertext | Factory Function |
|
|
299
|
+
|-----------|----------------|------------|------------|------------|------------------|
|
|
300
|
+
| Kyber512 | Level 1 (128-bit) | 800 B | 1,632 B | 768 B | `createKyber512()` |
|
|
301
|
+
| Kyber768 | Level 3 (192-bit) | 1,184 B | 2,400 B | 1,088 B | `createKyber768()` |
|
|
302
|
+
| Kyber1024 | Level 5 (256-bit) | 1,568 B | 3,168 B | 1,568 B | `createKyber1024()` |
|
|
303
|
+
|
|
304
|
+
**Note**: Use ML-KEM instead. Kyber is the pre-standardization version.
|
|
305
|
+
|
|
306
|
+
#### Key Encapsulation - Classic McEliece (10 variants)
|
|
307
|
+
|
|
308
|
+
| Algorithm | Security Level | Public Key | Secret Key | Ciphertext | Factory Function |
|
|
309
|
+
|-----------|----------------|------------|------------|------------|------------------|
|
|
310
|
+
| Classic-McEliece-348864 | Level 1 (128-bit) | 261,120 B | 6,492 B | 96 B | `createClassicMcEliece348864()` |
|
|
311
|
+
| Classic-McEliece-348864f | Level 1 (128-bit) | 261,120 B | 6,492 B | 96 B | `createClassicMcEliece348864f()` |
|
|
312
|
+
| Classic-McEliece-460896 | Level 3 (192-bit) | 524,160 B | 13,608 B | 156 B | `createClassicMcEliece460896()` |
|
|
313
|
+
| Classic-McEliece-460896f | Level 3 (192-bit) | 524,160 B | 13,608 B | 156 B | `createClassicMcEliece460896f()` |
|
|
314
|
+
| Classic-McEliece-6688128 | Level 5 (256-bit) | 1,044,992 B | 13,932 B | 208 B | `createClassicMcEliece6688128()` |
|
|
315
|
+
| Classic-McEliece-6688128f | Level 5 (256-bit) | 1,044,992 B | 13,932 B | 208 B | `createClassicMcEliece6688128f()` |
|
|
316
|
+
| Classic-McEliece-6960119 | Level 5 (256-bit) | 1,047,319 B | 13,948 B | 194 B | `createClassicMcEliece6960119()` |
|
|
317
|
+
| Classic-McEliece-6960119f | Level 5 (256-bit) | 1,047,319 B | 13,948 B | 194 B | `createClassicMcEliece6960119f()` |
|
|
318
|
+
| Classic-McEliece-8192128 | Level 5 (256-bit) | 1,357,824 B | 14,120 B | 208 B | `createClassicMcEliece8192128()` |
|
|
319
|
+
| Classic-McEliece-8192128f | Level 5 (256-bit) | 1,357,824 B | 14,120 B | 208 B | `createClassicMcEliece8192128f()` |
|
|
320
|
+
|
|
321
|
+
#### Key Encapsulation - FrodoKEM (6 salted variants)
|
|
322
|
+
|
|
323
|
+
| Algorithm | Security Level | Public Key | Secret Key | Ciphertext | Factory Function |
|
|
324
|
+
|-----------|----------------|------------|------------|------------|------------------|
|
|
325
|
+
| FrodoKEM-640-AES | Level 1 (128-bit) | 9,616 B | 19,888 B | 9,752 B | `createFrodoKEM640AES()` |
|
|
326
|
+
| FrodoKEM-640-SHAKE | Level 1 (128-bit) | 9,616 B | 19,888 B | 9,752 B | `createFrodoKEM640SHAKE()` |
|
|
327
|
+
| FrodoKEM-976-AES | Level 3 (192-bit) | 15,632 B | 31,296 B | 15,792 B | `createFrodoKEM976AES()` |
|
|
328
|
+
| FrodoKEM-976-SHAKE | Level 3 (192-bit) | 15,632 B | 31,296 B | 15,792 B | `createFrodoKEM976SHAKE()` |
|
|
329
|
+
| FrodoKEM-1344-AES | Level 5 (256-bit) | 21,520 B | 43,088 B | 21,696 B | `createFrodoKEM1344AES()` |
|
|
330
|
+
| FrodoKEM-1344-SHAKE | Level 5 (256-bit) | 21,520 B | 43,088 B | 21,696 B | `createFrodoKEM1344SHAKE()` |
|
|
331
|
+
|
|
332
|
+
#### Key Encapsulation - eFrodoKEM (6 ephemeral variants)
|
|
333
|
+
|
|
334
|
+
| Algorithm | Security Level | Public Key | Secret Key | Ciphertext | Factory Function |
|
|
335
|
+
|-----------|----------------|------------|------------|------------|------------------|
|
|
336
|
+
| eFrodoKEM-640-AES | Level 1 (128-bit) | 9,616 B | 19,888 B | 9,720 B | `createEFrodoKEM640AES()` |
|
|
337
|
+
| eFrodoKEM-640-SHAKE | Level 1 (128-bit) | 9,616 B | 19,888 B | 9,720 B | `createEFrodoKEM640SHAKE()` |
|
|
338
|
+
| eFrodoKEM-976-AES | Level 3 (192-bit) | 15,632 B | 31,296 B | 15,744 B | `createEFrodoKEM976AES()` |
|
|
339
|
+
| eFrodoKEM-976-SHAKE | Level 3 (192-bit) | 15,632 B | 31,296 B | 15,744 B | `createEFrodoKEM976SHAKE()` |
|
|
340
|
+
| eFrodoKEM-1344-AES | Level 5 (256-bit) | 21,520 B | 43,088 B | 21,632 B | `createEFrodoKEM1344AES()` |
|
|
341
|
+
| eFrodoKEM-1344-SHAKE | Level 5 (256-bit) | 21,520 B | 43,088 B | 21,632 B | `createEFrodoKEM1344SHAKE()` |
|
|
342
|
+
|
|
343
|
+
#### Key Encapsulation - HQC (3 variants)
|
|
344
|
+
|
|
345
|
+
| Algorithm | Security Level | Public Key | Secret Key | Ciphertext | Factory Function |
|
|
346
|
+
|-----------|----------------|------------|------------|------------|------------------|
|
|
347
|
+
| HQC-128 | Level 1 (128-bit) | 2,249 B | 2,305 B | 4,433 B | `createHQC128()` |
|
|
348
|
+
| HQC-192 | Level 3 (192-bit) | 4,522 B | 4,586 B | 8,978 B | `createHQC192()` |
|
|
349
|
+
| HQC-256 | Level 5 (256-bit) | 7,245 B | 7,317 B | 14,421 B | `createHQC256()` |
|
|
350
|
+
|
|
351
|
+
#### Key Encapsulation - NTRU (6 variants)
|
|
352
|
+
|
|
353
|
+
| Algorithm | Security Level | Public Key | Secret Key | Ciphertext | Factory Function |
|
|
354
|
+
|-----------|----------------|------------|------------|------------|------------------|
|
|
355
|
+
| NTRU-HPS-2048-509 | Level 1 (128-bit) | 699 B | 935 B | 699 B | `createNTRUHPS2048509()` |
|
|
356
|
+
| NTRU-HPS-2048-677 | Level 3 (192-bit) | 930 B | 1,234 B | 930 B | `createNTRUHPS2048677()` |
|
|
357
|
+
| NTRU-HPS-4096-821 | Level 5 (256-bit) | 1,230 B | 1,590 B | 1,230 B | `createNTRUHPS4096821()` |
|
|
358
|
+
| NTRU-HPS-4096-1229 | Level 5 (256-bit) | 1,842 B | 2,366 B | 1,842 B | `createNTRUHPS40961229()` |
|
|
359
|
+
| NTRU-HRSS-701 | Level 3 (192-bit) | 1,138 B | 1,450 B | 1,138 B | `createNTRUHRSS701()` |
|
|
360
|
+
| NTRU-HRSS-1373 | Level 5 (256-bit) | 2,401 B | 2,983 B | 2,401 B | `createNTRUHRSS1373()` |
|
|
361
|
+
|
|
362
|
+
#### Key Encapsulation - NTRU Prime
|
|
363
|
+
|
|
364
|
+
| Algorithm | Security Level | Public Key | Secret Key | Ciphertext | Factory Function |
|
|
365
|
+
|-----------|----------------|------------|------------|------------|------------------|
|
|
366
|
+
| sntrup761 | Level 3 (192-bit) | 1,158 B | 1,763 B | 1,039 B | `createSntrup761()` |
|
|
367
|
+
|
|
368
|
+
**Note**: `sntrup761` is included primarily for interoperability testing.
|
|
369
|
+
|
|
370
|
+
#### Digital Signatures - Falcon (4 variants)
|
|
371
|
+
|
|
372
|
+
| Algorithm | Security Level | Public Key | Secret Key | Signature | Factory Function |
|
|
373
|
+
|-----------|----------------|------------|------------|-----------|------------------|
|
|
374
|
+
| Falcon-512 | Level 1 (128-bit) | 897 B | 1,281 B | ~752 B | `createFalcon512()` |
|
|
375
|
+
| Falcon-1024 | Level 5 (256-bit) | 1,793 B | 2,305 B | ~1,462 B | `createFalcon1024()` |
|
|
376
|
+
| Falcon-padded-512 | Level 1 (128-bit) | 897 B | 1,281 B | 666 B | `createFalconPadded512()` |
|
|
377
|
+
| Falcon-padded-1024 | Level 5 (256-bit) | 1,793 B | 2,305 B | 1,280 B | `createFalconPadded1024()` |
|
|
378
|
+
|
|
379
|
+
#### Digital Signatures - CROSS (18 variants)
|
|
380
|
+
|
|
381
|
+
| Algorithm | Security Level | Public Key | Secret Key | Signature | Factory Function |
|
|
382
|
+
|-----------|----------------|------------|------------|-----------|------------------|
|
|
383
|
+
| CROSS-rsdp-128-balanced | Level 1 (128-bit) | 77 B | 32 B | 13,152 B | `createCROSSRSDP128Balanced()` |
|
|
384
|
+
| CROSS-rsdp-128-fast | Level 1 (128-bit) | 77 B | 32 B | 18,432 B | `createCROSSRSDP128Fast()` |
|
|
385
|
+
| CROSS-rsdp-128-small | Level 1 (128-bit) | 77 B | 32 B | 12,432 B | `createCROSSRSDP128Small()` |
|
|
386
|
+
| CROSS-rsdp-192-balanced | Level 3 (192-bit) | 115 B | 48 B | 29,853 B | `createCROSSRSDP192Balanced()` |
|
|
387
|
+
| CROSS-rsdp-192-fast | Level 3 (192-bit) | 115 B | 48 B | 41,406 B | `createCROSSRSDP192Fast()` |
|
|
388
|
+
| CROSS-rsdp-192-small | Level 3 (192-bit) | 115 B | 48 B | 28,391 B | `createCROSSRSDP192Small()` |
|
|
389
|
+
| CROSS-rsdp-256-balanced | Level 5 (256-bit) | 153 B | 64 B | 53,527 B | `createCROSSRSDP256Balanced()` |
|
|
390
|
+
| CROSS-rsdp-256-fast | Level 5 (256-bit) | 153 B | 64 B | 74,590 B | `createCROSSRSDP256Fast()` |
|
|
391
|
+
| CROSS-rsdp-256-small | Level 5 (256-bit) | 153 B | 64 B | 50,818 B | `createCROSSRSDP256Small()` |
|
|
392
|
+
| CROSS-rsdpg-128-balanced | Level 1 (128-bit) | 54 B | 32 B | 9,120 B | `createCROSSRSDPG128Balanced()` |
|
|
393
|
+
| CROSS-rsdpg-128-fast | Level 1 (128-bit) | 54 B | 32 B | 11,980 B | `createCROSSRSDPG128Fast()` |
|
|
394
|
+
| CROSS-rsdpg-128-small | Level 1 (128-bit) | 54 B | 32 B | 8,960 B | `createCROSSRSDPG128Small()` |
|
|
395
|
+
| CROSS-rsdpg-192-balanced | Level 3 (192-bit) | 83 B | 48 B | 22,464 B | `createCROSSRSDPG192Balanced()` |
|
|
396
|
+
| CROSS-rsdpg-192-fast | Level 3 (192-bit) | 83 B | 48 B | 26,772 B | `createCROSSRSDPG192Fast()` |
|
|
397
|
+
| CROSS-rsdpg-192-small | Level 3 (192-bit) | 83 B | 48 B | 20,452 B | `createCROSSRSDPG192Small()` |
|
|
398
|
+
| CROSS-rsdpg-256-balanced | Level 5 (256-bit) | 106 B | 64 B | 40,100 B | `createCROSSRSDPG256Balanced()` |
|
|
399
|
+
| CROSS-rsdpg-256-fast | Level 5 (256-bit) | 106 B | 64 B | 48,102 B | `createCROSSRSDPG256Fast()` |
|
|
400
|
+
| CROSS-rsdpg-256-small | Level 5 (256-bit) | 106 B | 64 B | 36,454 B | `createCROSSRSDPG256Small()` |
|
|
401
|
+
|
|
402
|
+
#### Digital Signatures - MAYO (4 variants)
|
|
403
|
+
|
|
404
|
+
| Algorithm | Security Level | Public Key | Secret Key | Signature | Factory Function |
|
|
405
|
+
|-----------|----------------|------------|------------|-----------|------------------|
|
|
406
|
+
| MAYO-1 | Level 1 (128-bit) | 1,420 B | 24 B | 454 B | `createMAYO1()` |
|
|
407
|
+
| MAYO-2 | Level 1 (128-bit) | 4,912 B | 24 B | 186 B | `createMAYO2()` |
|
|
408
|
+
| MAYO-3 | Level 3 (192-bit) | 2,986 B | 32 B | 681 B | `createMAYO3()` |
|
|
409
|
+
| MAYO-5 | Level 5 (256-bit) | 5,554 B | 40 B | 964 B | `createMAYO5()` |
|
|
410
|
+
|
|
411
|
+
#### Digital Signatures - SNOVA (12 variants)
|
|
412
|
+
|
|
413
|
+
| Algorithm | Security Level | Public Key | Secret Key | Signature | Factory Function |
|
|
414
|
+
|-----------|----------------|------------|------------|-----------|------------------|
|
|
415
|
+
| SNOVA-24-5-4 | Level 1 (128-bit) | 1,016 B | 48 B | 248 B | `createSNOVA2454()` |
|
|
416
|
+
| SNOVA-24-5-4-esk | Level 1 (128-bit) | 1,016 B | 36,848 B | 248 B | `createSNOVA2454ESK()` |
|
|
417
|
+
| SNOVA-24-5-4-SHAKE | Level 1 (128-bit) | 1,016 B | 48 B | 248 B | `createSNOVA2454SHAKE()` |
|
|
418
|
+
| SNOVA-24-5-4-SHAKE-esk | Level 1 (128-bit) | 1,016 B | 36,848 B | 248 B | `createSNOVA2454SHAKEESK()` |
|
|
419
|
+
| SNOVA-24-5-5 | Level 1 (128-bit) | 1,579 B | 48 B | 379 B | `createSNOVA2455()` |
|
|
420
|
+
| SNOVA-25-8-3 | Level 1 (128-bit) | 2,320 B | 48 B | 165 B | `createSNOVA2583()` |
|
|
421
|
+
| SNOVA-29-6-5 | Level 3 (192-bit) | 2,716 B | 48 B | 454 B | `createSNOVA2965()` |
|
|
422
|
+
| SNOVA-37-17-2 | Level 3 (192-bit) | 9,842 B | 48 B | 124 B | `createSNOVA37172()` |
|
|
423
|
+
| SNOVA-37-8-4 | Level 3 (192-bit) | 4,112 B | 48 B | 376 B | `createSNOVA3784()` |
|
|
424
|
+
| SNOVA-49-11-3 | Level 5 (256-bit) | 6,006 B | 48 B | 286 B | `createSNOVA49113()` |
|
|
425
|
+
| SNOVA-56-25-2 | Level 5 (256-bit) | 31,266 B | 48 B | 178 B | `createSNOVA56252()` |
|
|
426
|
+
| SNOVA-60-10-4 | Level 5 (256-bit) | 8,016 B | 48 B | 576 B | `createSNOVA60104()` |
|
|
427
|
+
|
|
428
|
+
#### Digital Signatures - UOV (12 variants)
|
|
429
|
+
|
|
430
|
+
| Algorithm | Security Level | Public Key | Secret Key | Signature | Factory Function |
|
|
431
|
+
|-----------|----------------|------------|------------|-----------|------------------|
|
|
432
|
+
| OV-Ip | Level 1 (128-bit) | 278,432 B | 237,896 B | 128 B | `createOVIp()` |
|
|
433
|
+
| OV-Ip-pkc | Level 1 (128-bit) | 43,576 B | 237,896 B | 128 B | `createOVIpPKC()` |
|
|
434
|
+
| OV-Ip-pkc-skc | Level 1 (128-bit) | 43,576 B | 32 B | 128 B | `createOVIpPKCSKC()` |
|
|
435
|
+
| OV-Is | Level 1 (128-bit) | 412,160 B | 348,704 B | 96 B | `createOVIs()` |
|
|
436
|
+
| OV-Is-pkc | Level 1 (128-bit) | 66,576 B | 348,704 B | 96 B | `createOVIsPKC()` |
|
|
437
|
+
| OV-Is-pkc-skc | Level 1 (128-bit) | 66,576 B | 32 B | 96 B | `createOVIsPKCSKC()` |
|
|
438
|
+
| OV-III | Level 3 (192-bit) | 1,225,440 B | 1,044,320 B | 200 B | `createOVIII()` |
|
|
439
|
+
| OV-III-pkc | Level 3 (192-bit) | 189,232 B | 1,044,320 B | 200 B | `createOVIIIPKC()` |
|
|
440
|
+
| OV-III-pkc-skc | Level 3 (192-bit) | 189,232 B | 32 B | 200 B | `createOVIIIPKCSKC()` |
|
|
441
|
+
| OV-V | Level 5 (256-bit) | 2,869,440 B | 2,436,704 B | 260 B | `createOVV()` |
|
|
442
|
+
| OV-V-pkc | Level 5 (256-bit) | 446,992 B | 2,436,704 B | 260 B | `createOVVPKC()` |
|
|
443
|
+
| OV-V-pkc-skc | Level 5 (256-bit) | 446,992 B | 32 B | 260 B | `createOVVPKCSKC()` |
|
|
444
|
+
|
|
445
|
+
**Notes:**
|
|
446
|
+
- UOV variants with `-pkc` (public key compression) have smaller public keys
|
|
447
|
+
- UOV variants with `-skc` (secret key compression) have smaller secret keys
|
|
448
|
+
- `-esk` SNOVA variants use expanded secret keys for faster signing
|
|
449
|
+
|
|
450
|
+
## Bundle Size Optimization
|
|
451
|
+
|
|
452
|
+
Each algorithm is compiled separately into individual WASM modules, so you only bundle what you use:
|
|
453
|
+
|
|
454
|
+
```javascript
|
|
455
|
+
// Single algorithm (~80-160KB depending on algorithm complexity)
|
|
456
|
+
import { createMLKEM768 } from '@oqs/liboqs-js';
|
|
457
|
+
const kem = await createMLKEM768();
|
|
458
|
+
|
|
459
|
+
// Multiple algorithms - each adds its own WASM module
|
|
460
|
+
import { createMLKEM768, createMLDSA65 } from '@oqs/liboqs-js';
|
|
461
|
+
const kem = await createMLKEM768();
|
|
462
|
+
const sig = await createMLDSA65();
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
Tree-shaking ensures unused algorithms are never included in your bundle. Each algorithm's WASM is embedded in its module and loaded when you import the factory function.
|
|
466
|
+
|
|
467
|
+
## Package Structure
|
|
468
|
+
|
|
469
|
+
### Exports
|
|
470
|
+
|
|
471
|
+
```javascript
|
|
472
|
+
// Main entry - all 103 algorithm factory functions, classes, and metadata
|
|
473
|
+
import { createMLKEM768, MLKEM768, ML_KEM_768_INFO } from '@oqs/liboqs-js';
|
|
474
|
+
|
|
475
|
+
// KEM-only exports (32 algorithms)
|
|
476
|
+
import {
|
|
477
|
+
createMLKEM512,
|
|
478
|
+
createClassicMcEliece348864,
|
|
479
|
+
createFrodoKEM640AES
|
|
480
|
+
} from '@oqs/liboqs-js/kem';
|
|
481
|
+
|
|
482
|
+
// Signature-only exports (65 algorithms)
|
|
483
|
+
import {
|
|
484
|
+
createMLDSA44,
|
|
485
|
+
createFalcon512,
|
|
486
|
+
createSphincsSha2128fSimple
|
|
487
|
+
} from '@oqs/liboqs-js/sig';
|
|
488
|
+
|
|
489
|
+
// Error classes only
|
|
490
|
+
import { LibOQSError, LibOQSInitError } from '@oqs/liboqs-js/errors';
|
|
491
|
+
```
|
|
492
|
+
|
|
493
|
+
### File Structure
|
|
494
|
+
|
|
495
|
+
```
|
|
496
|
+
@oqs/liboqs-js/
|
|
497
|
+
├── src/
|
|
498
|
+
│ ├── algorithms/
|
|
499
|
+
│ │ ├── kem/
|
|
500
|
+
│ │ │ ├── ml-kem/ # ML-KEM (3 variants)
|
|
501
|
+
│ │ │ ├── kyber/ # Legacy Kyber (3 variants)
|
|
502
|
+
│ │ │ ├── classic-mceliece/ # Classic McEliece (10 variants)
|
|
503
|
+
│ │ │ ├── frodokem/ # FrodoKEM (6 variants)
|
|
504
|
+
│ │ │ ├── hqc/ # HQC (3 variants)
|
|
505
|
+
│ │ │ └── ntru/ # NTRU + sntrup761 (7 variants)
|
|
506
|
+
│ │ └── sig/
|
|
507
|
+
│ │ ├── ml-dsa/ # ML-DSA (3 variants)
|
|
508
|
+
│ │ ├── falcon/ # Falcon (4 variants)
|
|
509
|
+
│ │ ├── slh-dsa/ # SLH-DSA (12 variants)
|
|
510
|
+
│ │ ├── cross/ # CROSS (18 variants)
|
|
511
|
+
│ │ ├── mayo/ # MAYO (4 variants)
|
|
512
|
+
│ │ ├── snova/ # SNOVA (12 variants)
|
|
513
|
+
│ │ └── uov/ # UOV (12 variants)
|
|
514
|
+
│ ├── cli/
|
|
515
|
+
│ │ ├── commands/ # CLI command implementations
|
|
516
|
+
│ │ │ ├── info.js # Algorithm information
|
|
517
|
+
│ │ │ ├── kem.js # KEM operations (keygen, encaps, decaps)
|
|
518
|
+
│ │ │ ├── sig.js # Signature operations (keygen, sign, verify)
|
|
519
|
+
│ │ │ └── list.js # List available algorithms
|
|
520
|
+
│ │ ├── algorithms.js # Algorithm registry
|
|
521
|
+
│ │ ├── index.js # CLI entry point
|
|
522
|
+
│ │ ├── io.js # File I/O utilities
|
|
523
|
+
│ │ └── parser.js # Command parser
|
|
524
|
+
│ ├── core/
|
|
525
|
+
│ │ ├── errors.js # Error classes
|
|
526
|
+
│ │ └── validation.js # Input validation utilities
|
|
527
|
+
│ ├── types/ # TypeScript definitions
|
|
528
|
+
│ │ ├── algorithms.d.ts
|
|
529
|
+
│ │ ├── errors.d.ts
|
|
530
|
+
│ │ └── index.d.ts
|
|
531
|
+
│ ├── index.js # Main entry (all 103 algorithms)
|
|
532
|
+
│ ├── kem.js # KEM exports (38 algorithms)
|
|
533
|
+
│ └── sig.js # Signature exports (65 algorithms)
|
|
534
|
+
├── bin/
|
|
535
|
+
│ └── cli.js # CLI executable entry point
|
|
536
|
+
├── tests/
|
|
537
|
+
│ ├── kem.test.ts
|
|
538
|
+
│ ├── sig.test.ts
|
|
539
|
+
│ ├── cli.test.ts
|
|
540
|
+
│ └── deno/ # Deno-specific tests
|
|
541
|
+
│ ├── kem.test.ts
|
|
542
|
+
│ ├── sig.test.ts
|
|
543
|
+
│ └── cli.test.ts
|
|
544
|
+
├── dist/ # WASM modules (97 × 2 = 194 files, ~100-500KB each)
|
|
545
|
+
│ ├── ml-kem-512.min.js # Node.js/Browser module
|
|
546
|
+
│ ├── ml-kem-512.deno.js # Deno module
|
|
547
|
+
│ ├── falcon-512.min.js
|
|
548
|
+
│ ├── falcon-512.deno.js
|
|
549
|
+
│ └── ... (and 190 others)
|
|
550
|
+
├── algorithms.json # Algorithm registry and metadata
|
|
551
|
+
└── build.sh # WASM build script
|
|
552
|
+
```
|
|
553
|
+
|
|
554
|
+
## Architecture
|
|
555
|
+
|
|
556
|
+
The library is organized in layers:
|
|
557
|
+
|
|
558
|
+
1. **WASM Modules**: Emscripten-compiled LibOQS binaries (one per algorithm)
|
|
559
|
+
2. **Low-level Bindings**: Direct WASM function calls (`_OQS_KEM_*`, `_OQS_SIG_*`)
|
|
560
|
+
3. **High-level Wrappers**: User-friendly classes (`MLKEM768`, `MLDSA65`)
|
|
561
|
+
4. **Public API**: Factory functions and exports
|
|
562
|
+
|
|
563
|
+
### Memory Management
|
|
564
|
+
|
|
565
|
+
**IMPORTANT**: Always call `destroy()` when finished with an algorithm instance. WASM memory is not garbage-collected by JavaScript.
|
|
566
|
+
|
|
567
|
+
#### Why This Matters
|
|
568
|
+
|
|
569
|
+
WebAssembly modules allocate native memory outside the JavaScript heap. When you create an algorithm instance, LibOQS allocates C structures that JavaScript's garbage collector cannot reclaim. Without calling `destroy()`, this memory leaks permanently.
|
|
570
|
+
|
|
571
|
+
**Long-running applications** (servers, single-page apps, daemons) that don't call `destroy()` will experience:
|
|
572
|
+
- Increasing memory usage over time
|
|
573
|
+
- Eventually: allocation failures or crashes when the 256MB WASM heap limit is reached
|
|
574
|
+
|
|
575
|
+
**Short-lived scripts** are less affected since the OS reclaims all memory when the process exits.
|
|
576
|
+
|
|
577
|
+
#### Best Practices
|
|
578
|
+
|
|
579
|
+
```javascript
|
|
580
|
+
// Pattern 1: Simple cleanup
|
|
581
|
+
const kem = await createMLKEM768();
|
|
582
|
+
const { publicKey, secretKey } = kem.generateKeyPair();
|
|
583
|
+
kem.destroy();
|
|
584
|
+
|
|
585
|
+
// Pattern 2: Error-safe cleanup (recommended)
|
|
586
|
+
const kem = await createMLKEM768();
|
|
587
|
+
try {
|
|
588
|
+
const { publicKey, secretKey } = kem.generateKeyPair();
|
|
589
|
+
const { ciphertext, sharedSecret } = kem.encapsulate(publicKey);
|
|
590
|
+
// ... use results ...
|
|
591
|
+
} finally {
|
|
592
|
+
kem.destroy(); // Always runs, even if errors occur
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
// Pattern 3: Multiple operations
|
|
596
|
+
const sig = await createMLDSA65();
|
|
597
|
+
try {
|
|
598
|
+
const { publicKey, secretKey } = sig.generateKeyPair();
|
|
599
|
+
const message = new TextEncoder().encode('Hello!');
|
|
600
|
+
const signature = sig.sign(message, secretKey);
|
|
601
|
+
const isValid = sig.verify(message, signature, publicKey);
|
|
602
|
+
return isValid;
|
|
603
|
+
} finally {
|
|
604
|
+
sig.destroy();
|
|
605
|
+
}
|
|
606
|
+
```
|
|
607
|
+
|
|
608
|
+
#### Additional Notes
|
|
609
|
+
|
|
610
|
+
- Secret keys, shared secrets, and signatures are handled via WASM memory
|
|
611
|
+
- Keys and secrets are not automatically zeroed (limitation of JavaScript/WASM)
|
|
612
|
+
- Each algorithm instance must be destroyed individually
|
|
613
|
+
- After calling `destroy()`, the instance cannot be reused
|
|
614
|
+
|
|
615
|
+
### Thread Safety
|
|
616
|
+
|
|
617
|
+
- Individual algorithm instances are **not** thread-safe
|
|
618
|
+
- For concurrent operations, create separate instances per worker/thread
|
|
619
|
+
- WASM modules can be instantiated multiple times safely
|
|
620
|
+
|
|
621
|
+
## Security Considerations
|
|
622
|
+
|
|
623
|
+
1. **Use NIST Standardized Algorithms**: ML-KEM, ML-DSA, and SLH-DSA are recommended for production
|
|
624
|
+
2. **Hybrid Cryptography**: We, as well as OQS, strongly recommend combining with traditional algorithms (X25519/Ed25519) during transition
|
|
625
|
+
3. **Key Storage**: Store secret keys securely, never in plain text or localStorage
|
|
626
|
+
4. **Stay Updated**: Monitor NIST guidance and update regularly
|
|
627
|
+
5. **Audit Your Deployment**: Consult cryptographic experts for production use
|
|
628
|
+
6. **Random Number Generation**: This library uses system entropy (Node.js `crypto.randomBytes()`, browser `crypto.getRandomValues()`)
|
|
629
|
+
|
|
630
|
+
### Reporting Security Issues
|
|
631
|
+
|
|
632
|
+
See [SECURITY.md](SECURITY.md) for our vulnerability disclosure policy. Issues specific to the LibOQS C library should be reported to the [LibOQS project](https://github.com/open-quantum-safe/liboqs/security).
|
|
633
|
+
|
|
634
|
+
## Building from Source
|
|
635
|
+
|
|
636
|
+
### Prerequisites
|
|
637
|
+
|
|
638
|
+
- **Node.js 22+**
|
|
639
|
+
- **Emscripten** (latest stable release)
|
|
640
|
+
- **Git**
|
|
641
|
+
- **CMake 3.20+**
|
|
642
|
+
- **Python 3** (for Emscripten)
|
|
643
|
+
- **jq** (for JSON parsing in build.sh)
|
|
644
|
+
|
|
645
|
+
### Build Steps
|
|
646
|
+
|
|
647
|
+
```bash
|
|
648
|
+
# Clone repository
|
|
649
|
+
git clone https://github.com/open-quantum-safe/liboqs-js.git
|
|
650
|
+
cd liboqs-js
|
|
651
|
+
|
|
652
|
+
# Build all algorithms
|
|
653
|
+
./build.sh
|
|
654
|
+
|
|
655
|
+
# Build specific algorithm
|
|
656
|
+
./build.sh ml-kem-768
|
|
657
|
+
|
|
658
|
+
# Setup only (clone liboqs without building)
|
|
659
|
+
./build.sh --setup-only
|
|
660
|
+
|
|
661
|
+
# Clean build artifacts
|
|
662
|
+
./build.sh --clean
|
|
663
|
+
```
|
|
664
|
+
|
|
665
|
+
### Build System
|
|
666
|
+
|
|
667
|
+
The build system is **data-driven** using `algorithms.json`:
|
|
668
|
+
|
|
669
|
+
```json
|
|
670
|
+
{
|
|
671
|
+
"kem": {
|
|
672
|
+
"ml-kem": {
|
|
673
|
+
"ML-KEM-768": {
|
|
674
|
+
"slug": "ml-kem-768",
|
|
675
|
+
"cmake_var": "ML_KEM_768",
|
|
676
|
+
"security": 3,
|
|
677
|
+
"standardized": true
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
```
|
|
683
|
+
|
|
684
|
+
The `build.sh` script:
|
|
685
|
+
1. Parses `algorithms.json` with jq
|
|
686
|
+
2. Dynamically generates CMake flags to build single-algorithm WASM modules
|
|
687
|
+
3. Compiles with Emscripten optimizations (Closure compiler, WASM SIMD)
|
|
688
|
+
4. Outputs standalone `.min.js` files with embedded WASM
|
|
689
|
+
|
|
690
|
+
**No build script changes needed to add new algorithms** - just update the JSON registry.
|
|
691
|
+
|
|
692
|
+
### Adding New Algorithms
|
|
693
|
+
|
|
694
|
+
#### Quick Start
|
|
695
|
+
|
|
696
|
+
```bash
|
|
697
|
+
# 1. Add algorithm metadata to algorithms.json
|
|
698
|
+
# 2. Create the algorithm wrapper file (see existing files for patterns)
|
|
699
|
+
# 3. Build WASM module
|
|
700
|
+
./build.sh <algorithm-slug>
|
|
701
|
+
|
|
702
|
+
# 4. Export from src/index.js, src/kem.js, or src/sig.js
|
|
703
|
+
```
|
|
704
|
+
|
|
705
|
+
#### Key Size Management
|
|
706
|
+
|
|
707
|
+
The `fetch-key-sizes.js` script extracts key sizes from existing algorithm files and updates `algorithms.json`:
|
|
708
|
+
|
|
709
|
+
```bash
|
|
710
|
+
node scripts/fetch-key-sizes.js
|
|
711
|
+
# Scans src/algorithms/**/*.js for keySize data
|
|
712
|
+
# Updates algorithms.json with found key sizes
|
|
713
|
+
```
|
|
714
|
+
|
|
715
|
+
This is useful when:
|
|
716
|
+
- Updating key sizes after LibOQS version changes
|
|
717
|
+
- Ensuring consistency across the codebase
|
|
718
|
+
- Adding new algorithms
|
|
719
|
+
|
|
720
|
+
#### Steps
|
|
721
|
+
|
|
722
|
+
1. **Add to `algorithms.json`**: Include the algorithm metadata (slug, cmake_var, security level, key sizes)
|
|
723
|
+
2. **Create wrapper file**: Follow patterns in existing files under `src/algorithms/kem/` or `src/algorithms/sig/`
|
|
724
|
+
3. **Export in index files**: Add to `src/index.js`, `src/kem.js`, or `src/sig.js`
|
|
725
|
+
4. **Add tests**: Follow patterns in `tests/kem.test.ts` or `tests/sig.test.ts`
|
|
726
|
+
5. **Update TypeScript definitions**: If needed, update `src/types/algorithms.d.ts`
|
|
727
|
+
|
|
728
|
+
All 103 algorithms maintain consistent APIs, documentation, and error handling patterns.
|
|
729
|
+
|
|
730
|
+
## Testing
|
|
731
|
+
|
|
732
|
+
The library includes comprehensive test coverage using Vitest:
|
|
733
|
+
|
|
734
|
+
```bash
|
|
735
|
+
# Run all tests (1400+ tests across 103 algorithms for both node and browser environments)
|
|
736
|
+
bun test
|
|
737
|
+
|
|
738
|
+
# Or use your preferred package manager
|
|
739
|
+
npm test
|
|
740
|
+
pnpm test
|
|
741
|
+
yarn test
|
|
742
|
+
|
|
743
|
+
# Or with Deno:
|
|
744
|
+
deno test --allow-read --allow-write --allow-run --allow-env --no-check tests/deno/
|
|
745
|
+
```
|
|
746
|
+
|
|
747
|
+
Test coverage includes:
|
|
748
|
+
- **Algorithm correctness**: All algorithms tested for basic functionality
|
|
749
|
+
- **Round-trip verification**: KEM encapsulation/decapsulation, signature sign/verify
|
|
750
|
+
- **Key generation**: Validates key sizes match specifications
|
|
751
|
+
- **Cross-environment**: Node.js and browser (jsdom) compatibility
|
|
752
|
+
- **Error handling**: Validates proper error messages and types
|
|
753
|
+
- **Memory safety**: Ensures cleanup via destroy() methods
|
|
754
|
+
- **Edge cases**: Empty messages, invalid signatures, destroyed instances
|
|
755
|
+
|
|
756
|
+
## Contributing
|
|
757
|
+
|
|
758
|
+
Contributions are welcome! Please:
|
|
759
|
+
|
|
760
|
+
- **Tests must pass**: Run `bun run test` (or `npm run test`) and `deno test --allow-read --allow-write --allow-run --allow-env --no-check tests/deno/` before submitting
|
|
761
|
+
- **Follow existing code style**: Use ESM, async/await, JSDoc comments
|
|
762
|
+
- **Document public APIs**: Add comprehensive JSDoc for all exported functions and classes
|
|
763
|
+
- **Security first**: Consider security implications, especially for cryptographic operations
|
|
764
|
+
- **Consistency matters**: Follow established patterns in existing wrappers
|
|
765
|
+
|
|
766
|
+
For larger changes, open an issue first to discuss the approach.
|
|
767
|
+
|
|
768
|
+
### Development Workflow
|
|
769
|
+
|
|
770
|
+
1. Fork the repository
|
|
771
|
+
2. Create a feature branch
|
|
772
|
+
3. Install dependencies: `bun install` (or `npm install`, `pnpm install`, etc.)
|
|
773
|
+
4. Make your changes (add tests if applicable)
|
|
774
|
+
5. Run tests: `bun run test` (or `npm run test`)
|
|
775
|
+
6. Build and test locally
|
|
776
|
+
7. Submit a pull request
|
|
777
|
+
|
|
778
|
+
### Package Manager Notes
|
|
779
|
+
|
|
780
|
+
```bash
|
|
781
|
+
# Using bun (recommended/default for contributors)
|
|
782
|
+
bun install
|
|
783
|
+
bun run test
|
|
784
|
+
bun run build
|
|
785
|
+
|
|
786
|
+
# Using npm
|
|
787
|
+
npm install
|
|
788
|
+
npm run test
|
|
789
|
+
npm run build
|
|
790
|
+
|
|
791
|
+
# Using pnpm
|
|
792
|
+
pnpm install
|
|
793
|
+
pnpm runtest
|
|
794
|
+
pnpm run build
|
|
795
|
+
|
|
796
|
+
# Using yarn
|
|
797
|
+
yarn install
|
|
798
|
+
yarn run test
|
|
799
|
+
yarn run build
|
|
800
|
+
```
|
|
801
|
+
|
|
802
|
+
Contributions that add new algorithm wrappers, improve documentation, add tests, or enhance the build system are especially appreciated.
|
|
803
|
+
|
|
804
|
+
## Documentation
|
|
805
|
+
|
|
806
|
+
- **[Security Policy](SECURITY.md)** - Vulnerability reporting and security guidance
|
|
807
|
+
- **[LibOQS Documentation](https://github.com/open-quantum-safe/liboqs)** - Underlying C library
|
|
808
|
+
|
|
809
|
+
## License
|
|
810
|
+
|
|
811
|
+
MIT License - see [LICENSE.md](LICENSE.md) for details.
|
|
812
|
+
|
|
813
|
+
## Acknowledgments
|
|
814
|
+
|
|
815
|
+
- [Open Quantum Safe](https://openquantumsafe.org/) project for LibOQS
|
|
816
|
+
- [NIST Post-Quantum Cryptography Standardization](https://csrc.nist.gov/Projects/post-quantum-cryptography)
|
|
817
|
+
- The cryptographic research community
|
|
818
|
+
- Emscripten team for excellent WASM tooling
|
|
819
|
+
|
|
820
|
+
## Versioning
|
|
821
|
+
|
|
822
|
+
This library's version tracks the bundled LibOQS version:
|
|
823
|
+
- `@oqs/liboqs-js 0.15.x` includes `LibOQS 0.15.0`
|
|
824
|
+
|
|
825
|
+
## Disclaimer
|
|
826
|
+
|
|
827
|
+
This library provides access to cryptographic algorithms believed to be quantum-resistant based on current research. The field of post-quantum cryptography is evolving. Algorithm support may change as research advances. Always consult with cryptographic experts for production deployments and follow NIST recommendations.
|
|
828
|
+
|
|
829
|
+
The LibOQS project states: **"WE DO NOT CURRENTLY RECOMMEND RELYING ON THIS LIBRARY IN A PRODUCTION ENVIRONMENT OR TO PROTECT ANY SENSITIVE DATA."** This guidance applies to this JavaScript/WebAssembly wrapper as well.
|