@maatara/core-pqc-wasm 0.2.0 → 0.4.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/README.md +46 -46
- package/core_pqc_wasm.d.ts +65 -57
- package/core_pqc_wasm.js +5 -693
- package/core_pqc_wasm_bg.js +708 -0
- package/core_pqc_wasm_bg.wasm +0 -0
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
# @maatara/core-pqc-wasm
|
|
2
|
-
|
|
3
|
-
WASM bindings for Ma'atara's Post-Quantum Cryptography toolkit. Exposes Kyber ML‑KEM‑768, Dilithium (ML‑DSA‑65), HKDF‑SHA256, AES‑256‑GCM, and base64url helpers.
|
|
4
|
-
|
|
5
|
-
- Targets: `web` (browsers) and `bundler` (modern bundlers)
|
|
6
|
-
- Typings: included via wasm-pack generated `.d.ts`
|
|
7
|
-
- Size: ~238 KB `.wasm` (0.1.0), under 500 KB budget
|
|
8
|
-
|
|
9
|
-
## Install
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
npm install @maatara/core-pqc-wasm
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## Usage (direct)
|
|
16
|
-
|
|
17
|
-
Most projects should depend on the higher-level wrapper `@maatara/core-pqc`. If you need the raw WASM exports:
|
|
18
|
-
|
|
19
|
-
```js
|
|
20
|
-
import init, {
|
|
21
|
-
kyber_keygen,
|
|
22
|
-
kyber_encaps,
|
|
23
|
-
kyber_decaps,
|
|
24
|
-
hkdf_sha256,
|
|
25
|
-
aes_gcm_wrap,
|
|
26
|
-
aes_gcm_unwrap,
|
|
27
|
-
dilithium_keygen,
|
|
28
|
-
dilithium_sign,
|
|
29
|
-
dilithium_verify,
|
|
30
|
-
} from '@maatara/core-pqc-wasm';
|
|
31
|
-
|
|
32
|
-
await init();
|
|
33
|
-
const { public_b64u, secret_b64u } = JSON.parse(kyber_keygen());
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
## Security notes
|
|
37
|
-
|
|
38
|
-
- Zero‑knowledge: intended for client‑side use; servers should only perform verification.
|
|
39
|
-
- Constant‑time: uses vetted crates (`subtle`, `aes-gcm`).
|
|
40
|
-
- RNG: `getrandom` with `js` feature uses Web Crypto / Node WebCrypto.
|
|
41
|
-
- Provenance: WASM uses pure‑Rust `ml-kem` and `ml-dsa` crates; native builds (not used here) rely on `pqcrypto` (PQClean).
|
|
42
|
-
|
|
43
|
-
## Build targets
|
|
44
|
-
|
|
45
|
-
- `wasm-pack build --target web`
|
|
46
|
-
- `wasm-pack build --target bundler`
|
|
1
|
+
# @maatara/core-pqc-wasm
|
|
2
|
+
|
|
3
|
+
WASM bindings for Ma'atara's Post-Quantum Cryptography toolkit. Exposes Kyber ML‑KEM‑768, Dilithium (ML‑DSA‑65), HKDF‑SHA256, AES‑256‑GCM, and base64url helpers.
|
|
4
|
+
|
|
5
|
+
- Targets: `web` (browsers) and `bundler` (modern bundlers)
|
|
6
|
+
- Typings: included via wasm-pack generated `.d.ts`
|
|
7
|
+
- Size: ~238 KB `.wasm` (0.1.0), under 500 KB budget
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @maatara/core-pqc-wasm
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage (direct)
|
|
16
|
+
|
|
17
|
+
Most projects should depend on the higher-level wrapper `@maatara/core-pqc`. If you need the raw WASM exports:
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
import init, {
|
|
21
|
+
kyber_keygen,
|
|
22
|
+
kyber_encaps,
|
|
23
|
+
kyber_decaps,
|
|
24
|
+
hkdf_sha256,
|
|
25
|
+
aes_gcm_wrap,
|
|
26
|
+
aes_gcm_unwrap,
|
|
27
|
+
dilithium_keygen,
|
|
28
|
+
dilithium_sign,
|
|
29
|
+
dilithium_verify,
|
|
30
|
+
} from '@maatara/core-pqc-wasm';
|
|
31
|
+
|
|
32
|
+
await init();
|
|
33
|
+
const { public_b64u, secret_b64u } = JSON.parse(kyber_keygen());
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Security notes
|
|
37
|
+
|
|
38
|
+
- Zero‑knowledge: intended for client‑side use; servers should only perform verification.
|
|
39
|
+
- Constant‑time: uses vetted crates (`subtle`, `aes-gcm`).
|
|
40
|
+
- RNG: `getrandom` with `js` feature uses Web Crypto / Node WebCrypto.
|
|
41
|
+
- Provenance: WASM uses pure‑Rust `ml-kem` and `ml-dsa` crates; native builds (not used here) rely on `pqcrypto` (PQClean).
|
|
42
|
+
|
|
43
|
+
## Build targets
|
|
44
|
+
|
|
45
|
+
- `wasm-pack build --target web`
|
|
46
|
+
- `wasm-pack build --target bundler`
|
package/core_pqc_wasm.d.ts
CHANGED
|
@@ -1,70 +1,78 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
-
|
|
4
|
-
export function kyber_encaps(public_b64u: string): string;
|
|
5
|
-
export function kyber_decaps(secret_b64u: string, kem_ct_b64u: string): string;
|
|
6
|
-
export function hkdf_sha256(secret_b64u: string, info_b64u: string, salt_b64u: string | null | undefined, len: number): string;
|
|
7
|
-
export function aes_gcm_wrap(key_b64u: string, dek_b64u: string, aad_b64u: string): string;
|
|
3
|
+
|
|
8
4
|
export function aes_gcm_unwrap(key_b64u: string, iv_b64u: string, ct_b64u: string, aad_b64u: string): string;
|
|
5
|
+
|
|
6
|
+
export function aes_gcm_wrap(key_b64u: string, dek_b64u: string, aad_b64u: string): string;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Create a nonce cache for replay attack prevention
|
|
10
|
+
* capacity: maximum number of nonces to track
|
|
11
|
+
* ttl_ms: time-to-live in milliseconds before nonces expire
|
|
12
|
+
*/
|
|
13
|
+
export function create_nonce_cache(capacity: number, ttl_ms: bigint): string;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* ML-DSA-65 key generation (FIPS 204 compliant)
|
|
17
|
+
* Security: Keys are generated using platform CSPRNG
|
|
18
|
+
*/
|
|
9
19
|
export function dilithium_keygen(): string;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* ML-DSA-65 signing (FIPS 204 compliant)
|
|
23
|
+
* Security: Input validation prevents DoS; constant-time operations
|
|
24
|
+
*/
|
|
10
25
|
export function dilithium_sign(message_b64u: string, secret_b64u: string): string;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* ML-DSA-65 verification (FIPS 204 compliant)
|
|
29
|
+
* Security: Input validation prevents DoS; constant-time comparison
|
|
30
|
+
*/
|
|
11
31
|
export function dilithium_verify(message_b64u: string, signature_b64u: string, public_b64u: string): string;
|
|
12
|
-
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Get elastic hash table configuration for key caching
|
|
35
|
+
*/
|
|
36
|
+
export function elastic_hash_config(capacity: number, load_factor: number): string;
|
|
37
|
+
|
|
38
|
+
export function hkdf_sha256(secret_b64u: string, info_b64u: string, salt_b64u: string | null | undefined, len: number): string;
|
|
39
|
+
|
|
13
40
|
export function jcs_canonicalize(json: string): string;
|
|
14
|
-
|
|
41
|
+
|
|
42
|
+
export function kyber_decaps(secret_b64u: string, kem_ct_b64u: string): string;
|
|
43
|
+
|
|
44
|
+
export function kyber_encaps(public_b64u: string): string;
|
|
45
|
+
|
|
46
|
+
export function kyber_keygen(): string;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Check if a nonce has been seen (for replay prevention)
|
|
50
|
+
* Returns info about the nonce cache algorithm
|
|
51
|
+
*/
|
|
52
|
+
export function nonce_cache_info(): string;
|
|
53
|
+
|
|
54
|
+
export function preimage_anchor(user_id: string, root_hex: string, epoch: string, chains_json: string): string;
|
|
55
|
+
|
|
15
56
|
export function preimage_asset_mint(header_json: string, asset_json: string): string;
|
|
57
|
+
|
|
16
58
|
export function preimage_asset_transfer(header_json: string): string;
|
|
17
|
-
export function preimage_anchor(user_id: string, root_hex: string, epoch: string, chains_json: string): string;
|
|
18
|
-
export function validate_royalty(receiver: string, bps: number): string;
|
|
19
|
-
export function verify_attestations(msg_b64u: string, attestations_json: string, allowed_public_keys_json?: string | null): string;
|
|
20
59
|
|
|
21
|
-
export
|
|
22
|
-
|
|
23
|
-
export interface InitOutput {
|
|
24
|
-
readonly memory: WebAssembly.Memory;
|
|
25
|
-
readonly kyber_keygen: () => [number, number];
|
|
26
|
-
readonly kyber_encaps: (a: number, b: number) => [number, number];
|
|
27
|
-
readonly kyber_decaps: (a: number, b: number, c: number, d: number) => [number, number];
|
|
28
|
-
readonly hkdf_sha256: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number];
|
|
29
|
-
readonly aes_gcm_wrap: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
|
|
30
|
-
readonly aes_gcm_unwrap: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number];
|
|
31
|
-
readonly dilithium_keygen: () => [number, number];
|
|
32
|
-
readonly dilithium_sign: (a: number, b: number, c: number, d: number) => [number, number];
|
|
33
|
-
readonly dilithium_verify: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
|
|
34
|
-
readonly start: () => void;
|
|
35
|
-
readonly jcs_canonicalize: (a: number, b: number) => [number, number];
|
|
36
|
-
readonly preimage_asset_mint: (a: number, b: number, c: number, d: number) => [number, number];
|
|
37
|
-
readonly preimage_asset_transfer: (a: number, b: number) => [number, number];
|
|
38
|
-
readonly preimage_anchor: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number];
|
|
39
|
-
readonly validate_royalty: (a: number, b: number, c: number) => [number, number];
|
|
40
|
-
readonly verify_attestations: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
|
|
41
|
-
readonly preimage_governance: (a: number, b: number) => [number, number];
|
|
42
|
-
readonly __wbindgen_exn_store: (a: number) => void;
|
|
43
|
-
readonly __externref_table_alloc: () => number;
|
|
44
|
-
readonly __wbindgen_export_2: WebAssembly.Table;
|
|
45
|
-
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
46
|
-
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
47
|
-
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
48
|
-
readonly __wbindgen_start: () => void;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
60
|
+
export function preimage_governance(policy_json: string): string;
|
|
61
|
+
|
|
52
62
|
/**
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
*
|
|
58
|
-
* @returns {InitOutput}
|
|
59
|
-
*/
|
|
60
|
-
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
63
|
+
* Compute shortest path verification info for provenance chains
|
|
64
|
+
* This returns the algorithm parameters for JS-side graph operations
|
|
65
|
+
*/
|
|
66
|
+
export function provenance_path_config(chain_length: number, branches: number): string;
|
|
61
67
|
|
|
62
68
|
/**
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
export
|
|
69
|
+
* Get SSSP algorithm configuration for graph verification
|
|
70
|
+
* nodes: expected number of nodes in the graph
|
|
71
|
+
*/
|
|
72
|
+
export function sssp_config(nodes: number): string;
|
|
73
|
+
|
|
74
|
+
export function start(): void;
|
|
75
|
+
|
|
76
|
+
export function validate_royalty(receiver: string, bps: number): string;
|
|
77
|
+
|
|
78
|
+
export function verify_attestations(msg_b64u: string, attestations_json: string, allowed_public_keys_json?: string | null): string;
|