@enclave-technologies/pqc-primitives 0.1.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 +202 -0
- package/README.md +173 -0
- package/dist/bundler/constants.js +63 -0
- package/dist/bundler/enclave_pqc_primitives_wasm.d.ts +218 -0
- package/dist/bundler/enclave_pqc_primitives_wasm.js +9 -0
- package/dist/bundler/enclave_pqc_primitives_wasm_bg.js +838 -0
- package/dist/bundler/enclave_pqc_primitives_wasm_bg.wasm +0 -0
- package/dist/bundler/enclave_pqc_primitives_wasm_bg.wasm.d.ts +41 -0
- package/dist/bundler/index.d.ts +157 -0
- package/dist/bundler/index.js +80 -0
- package/dist/nodejs/constants.js +63 -0
- package/dist/nodejs/enclave_pqc_primitives_wasm.cjs +873 -0
- package/dist/nodejs/enclave_pqc_primitives_wasm.d.ts +218 -0
- package/dist/nodejs/enclave_pqc_primitives_wasm_bg.wasm +0 -0
- package/dist/nodejs/enclave_pqc_primitives_wasm_bg.wasm.d.ts +41 -0
- package/dist/nodejs/index.d.ts +157 -0
- package/dist/nodejs/index.js +54 -0
- package/dist/web/constants.js +63 -0
- package/dist/web/enclave_pqc_primitives_wasm.d.ts +284 -0
- package/dist/web/enclave_pqc_primitives_wasm.js +938 -0
- package/dist/web/enclave_pqc_primitives_wasm_bg.wasm +0 -0
- package/dist/web/enclave_pqc_primitives_wasm_bg.wasm.d.ts +41 -0
- package/dist/web/index.d.ts +157 -0
- package/dist/web/index.js +101 -0
- package/package.json +65 -0
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Canonical suite identifier matching the Rust crate (Category 5 algorithms).
|
|
6
|
+
*/
|
|
7
|
+
export function ENCLAVE_PQ_SUITE_ID(): string;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Domain-separation prefix for the Enclave labeled KDF.
|
|
11
|
+
*/
|
|
12
|
+
export function KDF_LABEL_PREFIX(): string;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Algorithm identifier (`"Argon2id"`).
|
|
16
|
+
*/
|
|
17
|
+
export function PWHASH_ALGORITHM(): string;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Derived key length in bytes (matches AES-256-GCM key size).
|
|
21
|
+
*/
|
|
22
|
+
export function PWHASH_OUTPUT_BYTES(): number;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Salt length in bytes produced by [`generate_salt`].
|
|
26
|
+
*/
|
|
27
|
+
export function PWHASH_SALT_BYTES(): number;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* OWASP baseline Argon2id params: `{ memoryCostKib, iterations, parallelism }`.
|
|
31
|
+
*
|
|
32
|
+
* Sourced from the OWASP Password Storage Cheat Sheet (19 MiB / t=2 / p=1).
|
|
33
|
+
* Slow and memory-hard by design — lowering these for login latency is a
|
|
34
|
+
* security tradeoff, not a free optimization.
|
|
35
|
+
*/
|
|
36
|
+
export function RECOMMENDED_PARAMS(): any;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Decrypt AES-256-GCM ciphertext (including trailing tag).
|
|
40
|
+
*
|
|
41
|
+
* Throws on authentication failure (`AeadFailure: ...`).
|
|
42
|
+
*/
|
|
43
|
+
export function aeadDecrypt(key: Uint8Array, nonce: Uint8Array, ciphertext: Uint8Array, aad: Uint8Array): Uint8Array;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Encrypt with AES-256-GCM under an explicit key and nonce.
|
|
47
|
+
*
|
|
48
|
+
* Returns `ciphertext || tag` (16-byte tag suffix). Callers must ensure
|
|
49
|
+
* `(key, nonce)` uniqueness.
|
|
50
|
+
*/
|
|
51
|
+
export function aeadEncrypt(key: Uint8Array, nonce: Uint8Array, plaintext: Uint8Array, aad: Uint8Array): Uint8Array;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Cryptographically random 16-byte salt for Argon2id.
|
|
55
|
+
*/
|
|
56
|
+
export function generateSalt(): Uint8Array;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Return the [`CryptoUsageRecord`] from the last WASM primitive call.
|
|
60
|
+
*
|
|
61
|
+
* Shape: `{ algorithm, suiteId, operation, crateVersion }`.
|
|
62
|
+
* Returns `undefined` if no operation has run yet in this WASM instance.
|
|
63
|
+
*
|
|
64
|
+
* This is the CBOM attach point for product layers (Encrypt, etc.). This
|
|
65
|
+
* binding does not persist or transmit the record.
|
|
66
|
+
*/
|
|
67
|
+
export function getLastUsageRecord(): any;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* SHAKE256 over UTF-8 string bytes.
|
|
71
|
+
*/
|
|
72
|
+
export function hashUtf8(value: string, output_len: number): Uint8Array;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Decapsulate an ML-KEM-1024 ciphertext.
|
|
76
|
+
*
|
|
77
|
+
* `secret_key` may be a 64-byte seed or a 3168-byte expanded key.
|
|
78
|
+
*/
|
|
79
|
+
export function kemDecapsulate(ciphertext: Uint8Array, secret_key: Uint8Array): Uint8Array;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Encapsulate a shared secret to an ML-KEM-1024 public key.
|
|
83
|
+
*
|
|
84
|
+
* Returns `{ ciphertext, sharedSecret }` (1568 / 32 bytes).
|
|
85
|
+
*/
|
|
86
|
+
export function kemEncapsulate(public_key: Uint8Array): any;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Deterministic encapsulation for known-answer / KAT compliance.
|
|
90
|
+
*
|
|
91
|
+
* # Hazmat
|
|
92
|
+
*
|
|
93
|
+
* **KATs only.** Production code must call [`kem_encapsulate`].
|
|
94
|
+
*/
|
|
95
|
+
export function kemEncapsulateDeterministic(public_key: Uint8Array, m: Uint8Array): any;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Expand a 64-byte seed-form secret key to the FIPS expanded encoding
|
|
99
|
+
* ([`kem::SECRET_KEY_BYTES`] bytes).
|
|
100
|
+
*/
|
|
101
|
+
export function kemExpandedSecretKey(secret_key: Uint8Array): Uint8Array;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Generate a fresh ML-KEM-1024 keypair (includes PCT).
|
|
105
|
+
*
|
|
106
|
+
* Returns `{ publicKey, secretKey }` where `secretKey` is the preferred
|
|
107
|
+
* seed form ([`kem::SECRET_KEY_SEED_BYTES`] = 64). Expanded size is
|
|
108
|
+
* [`kem::SECRET_KEY_BYTES`] = 3168 — use [`kem_expanded_secret_key`].
|
|
109
|
+
*
|
|
110
|
+
* Throws `PairwiseConsistencyFailureError` if the PCT fails.
|
|
111
|
+
*/
|
|
112
|
+
export function kemGenerateKeypair(): any;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Derive an ML-KEM-1024 keypair from a 64-byte seed (`d || z`). Includes PCT.
|
|
116
|
+
*/
|
|
117
|
+
export function kemKeypairFromSeed(seed: Uint8Array): any;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Derive key material with `enclave-kdf-v1` labeled SHAKE256.
|
|
121
|
+
*
|
|
122
|
+
* Throws `InvalidParameter` on empty `label` or `length == 0`.
|
|
123
|
+
*/
|
|
124
|
+
export function labeledKdf(label: string, ikm: Uint8Array, length: number): Uint8Array;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* [`labeled_kdf`] with a 32-byte output.
|
|
128
|
+
*/
|
|
129
|
+
export function labeledKdf32(label: string, ikm: Uint8Array): Uint8Array;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Derive a 32-byte key from a password + salt with Argon2id.
|
|
133
|
+
*
|
|
134
|
+
* `params` must be `{ memoryCostKib, iterations, parallelism }` (see
|
|
135
|
+
* [`recommended_params`]). Throws on empty password / wrong salt length /
|
|
136
|
+
* invalid costs.
|
|
137
|
+
*
|
|
138
|
+
* This call is intentionally slow (~tens–hundreds of ms depending on host).
|
|
139
|
+
* That cost is the offline brute-force defense — do not lower params casually.
|
|
140
|
+
*/
|
|
141
|
+
export function pwhashDeriveKey(password: Uint8Array, salt: Uint8Array, params: any): Uint8Array;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Run known-answer CASTs for ML-KEM-1024, ML-DSA-87, and Argon2id.
|
|
145
|
+
*
|
|
146
|
+
* Throws `SelfTestFailureError` if any CAST fails. Pair-wise consistency is
|
|
147
|
+
* already enforced inside key generation — this is the power-on / module-entry
|
|
148
|
+
* known-answer path. The Argon2id CAST is slower (memory-hard by design).
|
|
149
|
+
*/
|
|
150
|
+
export function runSelfTests(): void;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* One-shot SHAKE256 hash of `input` into `output_len` bytes.
|
|
154
|
+
*/
|
|
155
|
+
export function shake256(input: Uint8Array, output_len: number): Uint8Array;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Expand a 32-byte seed-form secret key to the FIPS expanded encoding
|
|
159
|
+
* ([`sig::SECRET_KEY_BYTES`] bytes).
|
|
160
|
+
*/
|
|
161
|
+
export function sigExpandedSecretKey(secret_key: Uint8Array): Uint8Array;
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Generate a fresh ML-DSA-87 keypair (includes PCT).
|
|
165
|
+
*
|
|
166
|
+
* Returns `{ publicKey, secretKey }` where `secretKey` is the preferred
|
|
167
|
+
* seed form ([`sig::SECRET_KEY_SEED_BYTES`] = 32). Expanded size is
|
|
168
|
+
* [`sig::SECRET_KEY_BYTES`] = 4896.
|
|
169
|
+
*
|
|
170
|
+
* Throws `PairwiseConsistencyFailureError` if the PCT fails.
|
|
171
|
+
*/
|
|
172
|
+
export function sigGenerateKeypair(): any;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Derive an ML-DSA-87 keypair from a 32-byte seed. Includes PCT.
|
|
176
|
+
*/
|
|
177
|
+
export function sigKeypairFromSeed(seed: Uint8Array): any;
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Sign a message with empty context (deterministic ML-DSA-87).
|
|
181
|
+
*
|
|
182
|
+
* Empty `message` throws `InvalidLength` (matches Rust).
|
|
183
|
+
*/
|
|
184
|
+
export function sigSign(secret_key: Uint8Array, message: Uint8Array): Uint8Array;
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Deterministic ML-DSA.Sign with an explicit context (`context.len() <= 255`).
|
|
188
|
+
*
|
|
189
|
+
* Empty `message` or `context.len() > 255` throws (matches Rust).
|
|
190
|
+
*/
|
|
191
|
+
export function sigSignWithContext(secret_key: Uint8Array, message: Uint8Array, context: Uint8Array): Uint8Array;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Verify an ML-DSA-87 signature (empty context).
|
|
195
|
+
*
|
|
196
|
+
* Returns `false` on a cryptographically invalid signature. Throws only for
|
|
197
|
+
* malformed input lengths / encodings.
|
|
198
|
+
*/
|
|
199
|
+
export function sigVerify(public_key: Uint8Array, message: Uint8Array, signature: Uint8Array): boolean;
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Verify an ML-DSA-87 signature with an explicit context.
|
|
203
|
+
*
|
|
204
|
+
* Returns `false` on cryptographic failure; throws on malformed lengths.
|
|
205
|
+
*/
|
|
206
|
+
export function sigVerifyWithContext(public_key: Uint8Array, message: Uint8Array, signature: Uint8Array, context: Uint8Array): boolean;
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Overwrite a JS `Uint8Array` in place with zeros.
|
|
210
|
+
*
|
|
211
|
+
* # Security note
|
|
212
|
+
*
|
|
213
|
+
* Rust-side secret keys are zeroized on `Drop`, but that guarantee **does not**
|
|
214
|
+
* cross the WASM boundary. Once secret material lives in a JS `Uint8Array`, the
|
|
215
|
+
* JS garbage collector will not zero it. Call this when you are finished with
|
|
216
|
+
* long-lived secret buffers.
|
|
217
|
+
*/
|
|
218
|
+
export function zeroize(buf: Uint8Array): void;
|
|
219
|
+
|
|
220
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
221
|
+
|
|
222
|
+
export interface InitOutput {
|
|
223
|
+
readonly memory: WebAssembly.Memory;
|
|
224
|
+
readonly aeadDecrypt: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number, number];
|
|
225
|
+
readonly aeadEncrypt: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number, number];
|
|
226
|
+
readonly hashUtf8: (a: number, b: number, c: number) => [number, number, number, number];
|
|
227
|
+
readonly shake256: (a: number, b: number, c: number) => [number, number, number, number];
|
|
228
|
+
readonly sigExpandedSecretKey: (a: number, b: number) => [number, number, number, number];
|
|
229
|
+
readonly sigGenerateKeypair: () => [number, number, number];
|
|
230
|
+
readonly sigKeypairFromSeed: (a: number, b: number) => [number, number, number];
|
|
231
|
+
readonly sigSign: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
232
|
+
readonly sigSignWithContext: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
|
|
233
|
+
readonly sigVerify: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
234
|
+
readonly sigVerifyWithContext: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number];
|
|
235
|
+
readonly PWHASH_ALGORITHM: () => [number, number];
|
|
236
|
+
readonly PWHASH_OUTPUT_BYTES: () => number;
|
|
237
|
+
readonly PWHASH_SALT_BYTES: () => number;
|
|
238
|
+
readonly RECOMMENDED_PARAMS: () => [number, number, number];
|
|
239
|
+
readonly generateSalt: () => [number, number, number, number];
|
|
240
|
+
readonly kemDecapsulate: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
241
|
+
readonly kemEncapsulate: (a: number, b: number) => [number, number, number];
|
|
242
|
+
readonly kemEncapsulateDeterministic: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
243
|
+
readonly kemExpandedSecretKey: (a: number, b: number) => [number, number, number, number];
|
|
244
|
+
readonly kemGenerateKeypair: () => [number, number, number];
|
|
245
|
+
readonly kemKeypairFromSeed: (a: number, b: number) => [number, number, number];
|
|
246
|
+
readonly pwhashDeriveKey: (a: number, b: number, c: number, d: number, e: any) => [number, number, number, number];
|
|
247
|
+
readonly ENCLAVE_PQ_SUITE_ID: () => [number, number];
|
|
248
|
+
readonly KDF_LABEL_PREFIX: () => [number, number];
|
|
249
|
+
readonly getLastUsageRecord: () => [number, number, number];
|
|
250
|
+
readonly labeledKdf: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
|
251
|
+
readonly labeledKdf32: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
252
|
+
readonly runSelfTests: () => [number, number];
|
|
253
|
+
readonly zeroize: (a: any) => void;
|
|
254
|
+
readonly __wbindgen_exn_store: (a: number) => void;
|
|
255
|
+
readonly __externref_table_alloc: () => number;
|
|
256
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
257
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
258
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
259
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
260
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
261
|
+
readonly __wbindgen_start: () => void;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
268
|
+
* a precompiled `WebAssembly.Module`.
|
|
269
|
+
*
|
|
270
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
271
|
+
*
|
|
272
|
+
* @returns {InitOutput}
|
|
273
|
+
*/
|
|
274
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
278
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
279
|
+
*
|
|
280
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
281
|
+
*
|
|
282
|
+
* @returns {Promise<InitOutput>}
|
|
283
|
+
*/
|
|
284
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|