@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
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview OV-Is signature algorithm implementation
|
|
3
|
+
* @module algorithms/sig/uov/ov-is
|
|
4
|
+
* @description
|
|
5
|
+
* OV-Is is an Unbalanced Oil and Vinegar (UOV) signature scheme.
|
|
6
|
+
* This variant uses uncompressed keys.
|
|
7
|
+
*
|
|
8
|
+
* Key features:
|
|
9
|
+
* - Multivariate quadratic cryptography
|
|
10
|
+
* - Security Level 1 (128-bit classical, quantum-resistant)
|
|
11
|
+
* - Standard key sizes
|
|
12
|
+
* - Compact signatures (96 bytes)
|
|
13
|
+
*
|
|
14
|
+
* @see {@link https://www.uovsig.org/} - UOV specification
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { LibOQSError, LibOQSInitError, LibOQSOperationError, LibOQSValidationError } from '../../../core/errors.js';
|
|
18
|
+
import { isUint8Array } from '../../../core/validation.js';
|
|
19
|
+
|
|
20
|
+
// Dynamic module loading for cross-runtime compatibility
|
|
21
|
+
async function loadModule() {
|
|
22
|
+
const isDeno = typeof Deno !== 'undefined';
|
|
23
|
+
const modulePath = isDeno
|
|
24
|
+
? `../../../../dist/ov-is.deno.js`
|
|
25
|
+
: `../../../../dist/ov-is.min.js`;
|
|
26
|
+
|
|
27
|
+
const module = await import(modulePath);
|
|
28
|
+
return module.default;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* OV-IS-INFO algorithm constants and metadata
|
|
33
|
+
* @type {{readonly name: 'OV-Is', readonly identifier: 'OV-Is', readonly type: 'sig', readonly securityLevel: 1, readonly standardized: false, readonly description: string, readonly keySize: {readonly publicKey: 412160, readonly secretKey: 348704, readonly signature: 96}}}
|
|
34
|
+
*/
|
|
35
|
+
export const OV_IS_INFO = {
|
|
36
|
+
name: 'OV-Is',
|
|
37
|
+
identifier: 'OV-Is',
|
|
38
|
+
type: 'sig',
|
|
39
|
+
securityLevel: 1,
|
|
40
|
+
standardized: false,
|
|
41
|
+
description: 'OV-Is UOV signature scheme (NIST Level 1, 128-bit quantum security, uncompressed keys)',
|
|
42
|
+
keySize: {
|
|
43
|
+
publicKey: 412160,
|
|
44
|
+
secretKey: 348704,
|
|
45
|
+
signature: 96
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Factory function to create a OV-Is signature instance
|
|
51
|
+
*
|
|
52
|
+
* @async
|
|
53
|
+
* @function createOVIs
|
|
54
|
+
* @returns {Promise<OVIs>} Initialized OV-Is instance
|
|
55
|
+
* @throws {LibOQSInitError} If module initialization fails
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* import { createOVIs } from '@oqs/liboqs-js';
|
|
59
|
+
*
|
|
60
|
+
* const sig = await createOVIs();
|
|
61
|
+
* const { publicKey, secretKey } = sig.generateKeyPair();
|
|
62
|
+
* sig.destroy();
|
|
63
|
+
*/
|
|
64
|
+
export async function createOVIs() {
|
|
65
|
+
const moduleFactory = await loadModule();
|
|
66
|
+
const wasmModule = await moduleFactory();
|
|
67
|
+
wasmModule._OQS_init();
|
|
68
|
+
|
|
69
|
+
const algoName = OV_IS_INFO.identifier;
|
|
70
|
+
const nameLen = wasmModule.lengthBytesUTF8(algoName);
|
|
71
|
+
const namePtr = wasmModule._malloc(nameLen + 1);
|
|
72
|
+
wasmModule.stringToUTF8(algoName, namePtr, nameLen + 1);
|
|
73
|
+
|
|
74
|
+
const sigPtr = wasmModule._OQS_SIG_new(namePtr);
|
|
75
|
+
wasmModule._free(namePtr);
|
|
76
|
+
|
|
77
|
+
if (!sigPtr) {
|
|
78
|
+
throw new LibOQSInitError('OV-Is', 'Failed to create SIG instance');
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return new OVIs(wasmModule, sigPtr);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* OV-Is digital signature wrapper class
|
|
86
|
+
*
|
|
87
|
+
* @class OVIs
|
|
88
|
+
* @description
|
|
89
|
+
* High-level wrapper for OV-Is signature operations. Provides secure key generation,
|
|
90
|
+
* signing, and verification with automatic memory management.
|
|
91
|
+
*
|
|
92
|
+
* Memory Management:
|
|
93
|
+
* - All WASM memory is managed internally
|
|
94
|
+
* - Call destroy() when finished to free resources
|
|
95
|
+
* - Do not use instance after calling destroy()
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* const sig = await createOVIs();
|
|
99
|
+
*
|
|
100
|
+
* // Generate keypair
|
|
101
|
+
* const { publicKey, secretKey } = sig.generateKeyPair();
|
|
102
|
+
*
|
|
103
|
+
* // Sign message
|
|
104
|
+
* const message = new TextEncoder().encode('Hello, quantum world!');
|
|
105
|
+
* const signature = sig.sign(message, secretKey);
|
|
106
|
+
*
|
|
107
|
+
* // Verify signature
|
|
108
|
+
* const isValid = sig.verify(message, signature, publicKey);
|
|
109
|
+
*
|
|
110
|
+
* // Cleanup
|
|
111
|
+
* sig.destroy();
|
|
112
|
+
*/
|
|
113
|
+
export class OVIs {
|
|
114
|
+
/** @type {Object} @private */ #wasmModule;
|
|
115
|
+
/** @type {number} @private */ #sigPtr;
|
|
116
|
+
/** @type {boolean} @private */ #destroyed = false;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* @private
|
|
120
|
+
* @constructor
|
|
121
|
+
* @param {Object} wasmModule - Emscripten WASM module
|
|
122
|
+
* @param {number} sigPtr - Pointer to OQS_SIG structure
|
|
123
|
+
*/
|
|
124
|
+
constructor(wasmModule, sigPtr) {
|
|
125
|
+
this.#wasmModule = wasmModule;
|
|
126
|
+
this.#sigPtr = sigPtr;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Generate a new OV-Is keypair
|
|
131
|
+
*
|
|
132
|
+
* @async
|
|
133
|
+
* @returns {{publicKey: Uint8Array, secretKey: Uint8Array}}
|
|
134
|
+
* @throws {LibOQSError} If instance is destroyed
|
|
135
|
+
* @throws {LibOQSOperationError} If key generation fails
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* const { publicKey, secretKey } = sig.generateKeyPair();
|
|
139
|
+
* console.log('Public key:', publicKey.length); // 412160 bytes
|
|
140
|
+
* console.log('Secret key:', secretKey.length); // 348704 bytes
|
|
141
|
+
*/
|
|
142
|
+
generateKeyPair() {
|
|
143
|
+
this.#checkDestroyed();
|
|
144
|
+
|
|
145
|
+
const publicKey = new Uint8Array(OV_IS_INFO.keySize.publicKey);
|
|
146
|
+
const secretKey = new Uint8Array(OV_IS_INFO.keySize.secretKey);
|
|
147
|
+
|
|
148
|
+
const publicKeyPtr = this.#wasmModule._malloc(publicKey.length);
|
|
149
|
+
const secretKeyPtr = this.#wasmModule._malloc(secretKey.length);
|
|
150
|
+
|
|
151
|
+
try {
|
|
152
|
+
const result = this.#wasmModule._OQS_SIG_keypair(this.#sigPtr, publicKeyPtr, secretKeyPtr);
|
|
153
|
+
|
|
154
|
+
if (result !== 0) {
|
|
155
|
+
throw new LibOQSOperationError('generateKeyPair', 'OV-Is', 'Key generation failed');
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
publicKey.set(this.#wasmModule.HEAPU8.subarray(publicKeyPtr, publicKeyPtr + publicKey.length));
|
|
159
|
+
secretKey.set(this.#wasmModule.HEAPU8.subarray(secretKeyPtr, secretKeyPtr + secretKey.length));
|
|
160
|
+
|
|
161
|
+
return { publicKey, secretKey };
|
|
162
|
+
} finally {
|
|
163
|
+
this.#wasmModule._free(publicKeyPtr);
|
|
164
|
+
this.#wasmModule._free(secretKeyPtr);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Sign a message using the secret key
|
|
170
|
+
*
|
|
171
|
+
* @async
|
|
172
|
+
* @param {Uint8Array} message - Message to sign (arbitrary length)
|
|
173
|
+
* @param {Uint8Array} secretKey - Secret key for signing (348704 bytes)
|
|
174
|
+
* @returns {Uint8Array} Digital signature (up to 96 bytes)
|
|
175
|
+
* @throws {LibOQSError} If instance is destroyed
|
|
176
|
+
* @throws {LibOQSValidationError} If inputs are invalid
|
|
177
|
+
* @throws {LibOQSOperationError} If signing fails
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* const message = new TextEncoder().encode('Hello!');
|
|
181
|
+
* const signature = sig.sign(message, secretKey);
|
|
182
|
+
* console.log('Signature:', signature.length); // 96 bytes
|
|
183
|
+
*/
|
|
184
|
+
sign(message, secretKey) {
|
|
185
|
+
this.#checkDestroyed();
|
|
186
|
+
this.#validateMessage(message);
|
|
187
|
+
this.#validateSecretKey(secretKey);
|
|
188
|
+
|
|
189
|
+
const signature = new Uint8Array(OV_IS_INFO.keySize.signature);
|
|
190
|
+
const sigPtr = this.#wasmModule._malloc(signature.length);
|
|
191
|
+
const sigLenPtr = this.#wasmModule._malloc(8); // size_t
|
|
192
|
+
const msgPtr = this.#wasmModule._malloc(message.length);
|
|
193
|
+
const skPtr = this.#wasmModule._malloc(secretKey.length);
|
|
194
|
+
|
|
195
|
+
try {
|
|
196
|
+
this.#wasmModule.HEAPU8.set(message, msgPtr);
|
|
197
|
+
this.#wasmModule.HEAPU8.set(secretKey, skPtr);
|
|
198
|
+
this.#wasmModule.setValue(sigLenPtr, signature.length, 'i64');
|
|
199
|
+
|
|
200
|
+
const result = this.#wasmModule._OQS_SIG_sign(
|
|
201
|
+
this.#sigPtr,
|
|
202
|
+
sigPtr,
|
|
203
|
+
sigLenPtr,
|
|
204
|
+
msgPtr,
|
|
205
|
+
message.length,
|
|
206
|
+
skPtr
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
if (result !== 0) {
|
|
210
|
+
throw new LibOQSOperationError('sign', 'OV-Is', 'Signing failed');
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const actualSigLen = this.#wasmModule.getValue(sigLenPtr, 'i32');
|
|
214
|
+
const actualSignature = new Uint8Array(actualSigLen);
|
|
215
|
+
actualSignature.set(this.#wasmModule.HEAPU8.subarray(sigPtr, sigPtr + actualSigLen));
|
|
216
|
+
|
|
217
|
+
return actualSignature;
|
|
218
|
+
} finally {
|
|
219
|
+
this.#wasmModule._free(sigPtr);
|
|
220
|
+
this.#wasmModule._free(sigLenPtr);
|
|
221
|
+
this.#wasmModule._free(msgPtr);
|
|
222
|
+
this.#wasmModule._free(skPtr);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Verify a signature against a message using the public key
|
|
228
|
+
*
|
|
229
|
+
* @async
|
|
230
|
+
* @param {Uint8Array} message - Original message that was signed
|
|
231
|
+
* @param {Uint8Array} signature - Signature to verify
|
|
232
|
+
* @param {Uint8Array} publicKey - Public key for verification (412160 bytes)
|
|
233
|
+
* @returns {boolean} True if signature is valid, false otherwise
|
|
234
|
+
* @throws {LibOQSError} If instance is destroyed
|
|
235
|
+
* @throws {LibOQSValidationError} If inputs are invalid
|
|
236
|
+
*
|
|
237
|
+
* @example
|
|
238
|
+
* const isValid = sig.verify(message, signature, publicKey);
|
|
239
|
+
* if (isValid) {
|
|
240
|
+
* console.log('Signature is valid!');
|
|
241
|
+
* }
|
|
242
|
+
*/
|
|
243
|
+
verify(message, signature, publicKey) {
|
|
244
|
+
this.#checkDestroyed();
|
|
245
|
+
this.#validateMessage(message);
|
|
246
|
+
this.#validateSignature(signature);
|
|
247
|
+
this.#validatePublicKey(publicKey);
|
|
248
|
+
|
|
249
|
+
const msgPtr = this.#wasmModule._malloc(message.length);
|
|
250
|
+
const sigPtr = this.#wasmModule._malloc(signature.length);
|
|
251
|
+
const pkPtr = this.#wasmModule._malloc(publicKey.length);
|
|
252
|
+
|
|
253
|
+
try {
|
|
254
|
+
this.#wasmModule.HEAPU8.set(message, msgPtr);
|
|
255
|
+
this.#wasmModule.HEAPU8.set(signature, sigPtr);
|
|
256
|
+
this.#wasmModule.HEAPU8.set(publicKey, pkPtr);
|
|
257
|
+
|
|
258
|
+
const result = this.#wasmModule._OQS_SIG_verify(
|
|
259
|
+
this.#sigPtr,
|
|
260
|
+
msgPtr,
|
|
261
|
+
message.length,
|
|
262
|
+
sigPtr,
|
|
263
|
+
signature.length,
|
|
264
|
+
pkPtr
|
|
265
|
+
);
|
|
266
|
+
|
|
267
|
+
return result === 0;
|
|
268
|
+
} finally {
|
|
269
|
+
this.#wasmModule._free(msgPtr);
|
|
270
|
+
this.#wasmModule._free(sigPtr);
|
|
271
|
+
this.#wasmModule._free(pkPtr);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Free WASM resources
|
|
277
|
+
*
|
|
278
|
+
* @description
|
|
279
|
+
* Releases all WASM memory associated with this instance.
|
|
280
|
+
* The instance cannot be used after calling destroy().
|
|
281
|
+
*
|
|
282
|
+
* @example
|
|
283
|
+
* sig.destroy();
|
|
284
|
+
* // sig is now unusable
|
|
285
|
+
*/
|
|
286
|
+
destroy() {
|
|
287
|
+
if (!this.#destroyed && this.#sigPtr) {
|
|
288
|
+
this.#wasmModule._OQS_SIG_free(this.#sigPtr);
|
|
289
|
+
this.#sigPtr = null;
|
|
290
|
+
this.#destroyed = true;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Enables automatic cleanup via `using` declarations
|
|
296
|
+
* @example
|
|
297
|
+
* using instance = await create...();
|
|
298
|
+
* // automatically cleaned up at end of scope
|
|
299
|
+
*/
|
|
300
|
+
[Symbol.dispose]() {
|
|
301
|
+
this.destroy();
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Get algorithm information
|
|
306
|
+
*
|
|
307
|
+
* @readonly
|
|
308
|
+
* @returns {typeof OV_IS_INFO} Algorithm metadata
|
|
309
|
+
*
|
|
310
|
+
* @example
|
|
311
|
+
* console.log(sig.info.name); // 'OV-Is'
|
|
312
|
+
* console.log(sig.info.securityLevel); // 1
|
|
313
|
+
* console.log(sig.info.keySize); // { publicKey: 412160, secretKey: 348704, signature: 96 }
|
|
314
|
+
*/
|
|
315
|
+
get info() {
|
|
316
|
+
return OV_IS_INFO;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* @private
|
|
321
|
+
* @throws {LibOQSError} If instance is destroyed
|
|
322
|
+
*/
|
|
323
|
+
#checkDestroyed() {
|
|
324
|
+
if (this.#destroyed) {
|
|
325
|
+
throw new LibOQSError('Instance has been destroyed', 'OV-Is');
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* @private
|
|
331
|
+
* @param {Uint8Array} message
|
|
332
|
+
* @throws {LibOQSValidationError} If message is invalid
|
|
333
|
+
*/
|
|
334
|
+
#validateMessage(message) {
|
|
335
|
+
if (!ArrayBuffer.isView(message) || message.constructor.name !== 'Uint8Array') {
|
|
336
|
+
throw new LibOQSValidationError(
|
|
337
|
+
'Message must be Uint8Array',
|
|
338
|
+
'OV-Is'
|
|
339
|
+
);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* @private
|
|
345
|
+
* @param {Uint8Array} publicKey
|
|
346
|
+
* @throws {LibOQSValidationError} If public key size is invalid
|
|
347
|
+
*/
|
|
348
|
+
#validatePublicKey(publicKey) {
|
|
349
|
+
if (!isUint8Array(publicKey) || publicKey.length !== OV_IS_INFO.keySize.publicKey) {
|
|
350
|
+
throw new LibOQSValidationError(
|
|
351
|
+
`Invalid public key: expected ${OV_IS_INFO.keySize.publicKey} bytes, got ${publicKey?.length ?? 'null'}`,
|
|
352
|
+
'OV-Is'
|
|
353
|
+
);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* @private
|
|
359
|
+
* @param {Uint8Array} secretKey
|
|
360
|
+
* @throws {LibOQSValidationError} If secret key size is invalid
|
|
361
|
+
*/
|
|
362
|
+
#validateSecretKey(secretKey) {
|
|
363
|
+
if (!isUint8Array(secretKey) || secretKey.length !== OV_IS_INFO.keySize.secretKey) {
|
|
364
|
+
throw new LibOQSValidationError(
|
|
365
|
+
`Invalid secret key: expected ${OV_IS_INFO.keySize.secretKey} bytes, got ${secretKey?.length ?? 'null'}`,
|
|
366
|
+
'OV-Is'
|
|
367
|
+
);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* @private
|
|
373
|
+
* @param {Uint8Array} signature
|
|
374
|
+
* @throws {LibOQSValidationError} If signature is invalid
|
|
375
|
+
*/
|
|
376
|
+
#validateSignature(signature) {
|
|
377
|
+
if (!isUint8Array(signature)) {
|
|
378
|
+
throw new LibOQSValidationError(
|
|
379
|
+
'Signature must be Uint8Array',
|
|
380
|
+
'OV-Is'
|
|
381
|
+
);
|
|
382
|
+
}
|
|
383
|
+
if (signature.length === 0 || signature.length > OV_IS_INFO.keySize.signature) {
|
|
384
|
+
throw new LibOQSValidationError(
|
|
385
|
+
`Invalid signature length: expected up to ${OV_IS_INFO.keySize.signature} bytes, got ${signature.length}`,
|
|
386
|
+
'OV-Is'
|
|
387
|
+
);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
}
|