@maatara/core-pqc-wasm 0.1.0 → 0.1.2
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 -0
- package/core_pqc_wasm_bg.js +468 -0
- package/core_pqc_wasm_bg.wasm +0 -0
- package/node.js +29 -0
- package/package.json +14 -3
- package/LICENSE +0 -201
package/README.md
ADDED
|
@@ -0,0 +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`
|
|
@@ -0,0 +1,468 @@
|
|
|
1
|
+
let wasm;
|
|
2
|
+
export function __wbg_set_wasm(val) {
|
|
3
|
+
wasm = val;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
function addToExternrefTable0(obj) {
|
|
8
|
+
const idx = wasm.__externref_table_alloc();
|
|
9
|
+
wasm.__wbindgen_export_2.set(idx, obj);
|
|
10
|
+
return idx;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function handleError(f, args) {
|
|
14
|
+
try {
|
|
15
|
+
return f.apply(this, args);
|
|
16
|
+
} catch (e) {
|
|
17
|
+
const idx = addToExternrefTable0(e);
|
|
18
|
+
wasm.__wbindgen_exn_store(idx);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
let cachedUint8ArrayMemory0 = null;
|
|
23
|
+
|
|
24
|
+
function getUint8ArrayMemory0() {
|
|
25
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
26
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
27
|
+
}
|
|
28
|
+
return cachedUint8ArrayMemory0;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;
|
|
32
|
+
|
|
33
|
+
let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
34
|
+
|
|
35
|
+
cachedTextDecoder.decode();
|
|
36
|
+
|
|
37
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
38
|
+
let numBytesDecoded = 0;
|
|
39
|
+
function decodeText(ptr, len) {
|
|
40
|
+
numBytesDecoded += len;
|
|
41
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
42
|
+
cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
43
|
+
cachedTextDecoder.decode();
|
|
44
|
+
numBytesDecoded = len;
|
|
45
|
+
}
|
|
46
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function getStringFromWasm0(ptr, len) {
|
|
50
|
+
ptr = ptr >>> 0;
|
|
51
|
+
return decodeText(ptr, len);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function isLikeNone(x) {
|
|
55
|
+
return x === undefined || x === null;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* @returns {string}
|
|
59
|
+
*/
|
|
60
|
+
export function kyber_keygen() {
|
|
61
|
+
let deferred1_0;
|
|
62
|
+
let deferred1_1;
|
|
63
|
+
try {
|
|
64
|
+
const ret = wasm.kyber_keygen();
|
|
65
|
+
deferred1_0 = ret[0];
|
|
66
|
+
deferred1_1 = ret[1];
|
|
67
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
68
|
+
} finally {
|
|
69
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
let WASM_VECTOR_LEN = 0;
|
|
74
|
+
|
|
75
|
+
const lTextEncoder = typeof TextEncoder === 'undefined' ? (0, module.require)('util').TextEncoder : TextEncoder;
|
|
76
|
+
|
|
77
|
+
const cachedTextEncoder = new lTextEncoder('utf-8');
|
|
78
|
+
|
|
79
|
+
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
|
80
|
+
? function (arg, view) {
|
|
81
|
+
return cachedTextEncoder.encodeInto(arg, view);
|
|
82
|
+
}
|
|
83
|
+
: function (arg, view) {
|
|
84
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
85
|
+
view.set(buf);
|
|
86
|
+
return {
|
|
87
|
+
read: arg.length,
|
|
88
|
+
written: buf.length
|
|
89
|
+
};
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
93
|
+
|
|
94
|
+
if (realloc === undefined) {
|
|
95
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
96
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
97
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
98
|
+
WASM_VECTOR_LEN = buf.length;
|
|
99
|
+
return ptr;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
let len = arg.length;
|
|
103
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
104
|
+
|
|
105
|
+
const mem = getUint8ArrayMemory0();
|
|
106
|
+
|
|
107
|
+
let offset = 0;
|
|
108
|
+
|
|
109
|
+
for (; offset < len; offset++) {
|
|
110
|
+
const code = arg.charCodeAt(offset);
|
|
111
|
+
if (code > 0x7F) break;
|
|
112
|
+
mem[ptr + offset] = code;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (offset !== len) {
|
|
116
|
+
if (offset !== 0) {
|
|
117
|
+
arg = arg.slice(offset);
|
|
118
|
+
}
|
|
119
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
120
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
121
|
+
const ret = encodeString(arg, view);
|
|
122
|
+
|
|
123
|
+
offset += ret.written;
|
|
124
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
WASM_VECTOR_LEN = offset;
|
|
128
|
+
return ptr;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* @param {string} public_b64u
|
|
132
|
+
* @returns {string}
|
|
133
|
+
*/
|
|
134
|
+
export function kyber_encaps(public_b64u) {
|
|
135
|
+
let deferred2_0;
|
|
136
|
+
let deferred2_1;
|
|
137
|
+
try {
|
|
138
|
+
const ptr0 = passStringToWasm0(public_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
139
|
+
const len0 = WASM_VECTOR_LEN;
|
|
140
|
+
const ret = wasm.kyber_encaps(ptr0, len0);
|
|
141
|
+
deferred2_0 = ret[0];
|
|
142
|
+
deferred2_1 = ret[1];
|
|
143
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
144
|
+
} finally {
|
|
145
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* @param {string} secret_b64u
|
|
151
|
+
* @param {string} kem_ct_b64u
|
|
152
|
+
* @returns {string}
|
|
153
|
+
*/
|
|
154
|
+
export function kyber_decaps(secret_b64u, kem_ct_b64u) {
|
|
155
|
+
let deferred3_0;
|
|
156
|
+
let deferred3_1;
|
|
157
|
+
try {
|
|
158
|
+
const ptr0 = passStringToWasm0(secret_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
159
|
+
const len0 = WASM_VECTOR_LEN;
|
|
160
|
+
const ptr1 = passStringToWasm0(kem_ct_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
161
|
+
const len1 = WASM_VECTOR_LEN;
|
|
162
|
+
const ret = wasm.kyber_decaps(ptr0, len0, ptr1, len1);
|
|
163
|
+
deferred3_0 = ret[0];
|
|
164
|
+
deferred3_1 = ret[1];
|
|
165
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
166
|
+
} finally {
|
|
167
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* @param {string} secret_b64u
|
|
173
|
+
* @param {string} info_b64u
|
|
174
|
+
* @param {string | null | undefined} salt_b64u
|
|
175
|
+
* @param {number} len
|
|
176
|
+
* @returns {string}
|
|
177
|
+
*/
|
|
178
|
+
export function hkdf_sha256(secret_b64u, info_b64u, salt_b64u, len) {
|
|
179
|
+
let deferred4_0;
|
|
180
|
+
let deferred4_1;
|
|
181
|
+
try {
|
|
182
|
+
const ptr0 = passStringToWasm0(secret_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
183
|
+
const len0 = WASM_VECTOR_LEN;
|
|
184
|
+
const ptr1 = passStringToWasm0(info_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
185
|
+
const len1 = WASM_VECTOR_LEN;
|
|
186
|
+
var ptr2 = isLikeNone(salt_b64u) ? 0 : passStringToWasm0(salt_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
187
|
+
var len2 = WASM_VECTOR_LEN;
|
|
188
|
+
const ret = wasm.hkdf_sha256(ptr0, len0, ptr1, len1, ptr2, len2, len);
|
|
189
|
+
deferred4_0 = ret[0];
|
|
190
|
+
deferred4_1 = ret[1];
|
|
191
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
192
|
+
} finally {
|
|
193
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* @param {string} key_b64u
|
|
199
|
+
* @param {string} dek_b64u
|
|
200
|
+
* @param {string} aad_b64u
|
|
201
|
+
* @returns {string}
|
|
202
|
+
*/
|
|
203
|
+
export function aes_gcm_wrap(key_b64u, dek_b64u, aad_b64u) {
|
|
204
|
+
let deferred4_0;
|
|
205
|
+
let deferred4_1;
|
|
206
|
+
try {
|
|
207
|
+
const ptr0 = passStringToWasm0(key_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
208
|
+
const len0 = WASM_VECTOR_LEN;
|
|
209
|
+
const ptr1 = passStringToWasm0(dek_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
210
|
+
const len1 = WASM_VECTOR_LEN;
|
|
211
|
+
const ptr2 = passStringToWasm0(aad_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
212
|
+
const len2 = WASM_VECTOR_LEN;
|
|
213
|
+
const ret = wasm.aes_gcm_wrap(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
214
|
+
deferred4_0 = ret[0];
|
|
215
|
+
deferred4_1 = ret[1];
|
|
216
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
217
|
+
} finally {
|
|
218
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* @param {string} key_b64u
|
|
224
|
+
* @param {string} iv_b64u
|
|
225
|
+
* @param {string} ct_b64u
|
|
226
|
+
* @param {string} aad_b64u
|
|
227
|
+
* @returns {string}
|
|
228
|
+
*/
|
|
229
|
+
export function aes_gcm_unwrap(key_b64u, iv_b64u, ct_b64u, aad_b64u) {
|
|
230
|
+
let deferred5_0;
|
|
231
|
+
let deferred5_1;
|
|
232
|
+
try {
|
|
233
|
+
const ptr0 = passStringToWasm0(key_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
234
|
+
const len0 = WASM_VECTOR_LEN;
|
|
235
|
+
const ptr1 = passStringToWasm0(iv_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
236
|
+
const len1 = WASM_VECTOR_LEN;
|
|
237
|
+
const ptr2 = passStringToWasm0(ct_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
238
|
+
const len2 = WASM_VECTOR_LEN;
|
|
239
|
+
const ptr3 = passStringToWasm0(aad_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
240
|
+
const len3 = WASM_VECTOR_LEN;
|
|
241
|
+
const ret = wasm.aes_gcm_unwrap(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
242
|
+
deferred5_0 = ret[0];
|
|
243
|
+
deferred5_1 = ret[1];
|
|
244
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
245
|
+
} finally {
|
|
246
|
+
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* @returns {string}
|
|
252
|
+
*/
|
|
253
|
+
export function dilithium_keygen() {
|
|
254
|
+
let deferred1_0;
|
|
255
|
+
let deferred1_1;
|
|
256
|
+
try {
|
|
257
|
+
const ret = wasm.dilithium_keygen();
|
|
258
|
+
deferred1_0 = ret[0];
|
|
259
|
+
deferred1_1 = ret[1];
|
|
260
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
261
|
+
} finally {
|
|
262
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* @param {string} message_b64u
|
|
268
|
+
* @param {string} secret_b64u
|
|
269
|
+
* @returns {string}
|
|
270
|
+
*/
|
|
271
|
+
export function dilithium_sign(message_b64u, secret_b64u) {
|
|
272
|
+
let deferred3_0;
|
|
273
|
+
let deferred3_1;
|
|
274
|
+
try {
|
|
275
|
+
const ptr0 = passStringToWasm0(message_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
276
|
+
const len0 = WASM_VECTOR_LEN;
|
|
277
|
+
const ptr1 = passStringToWasm0(secret_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
278
|
+
const len1 = WASM_VECTOR_LEN;
|
|
279
|
+
const ret = wasm.dilithium_sign(ptr0, len0, ptr1, len1);
|
|
280
|
+
deferred3_0 = ret[0];
|
|
281
|
+
deferred3_1 = ret[1];
|
|
282
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
283
|
+
} finally {
|
|
284
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* @param {string} message_b64u
|
|
290
|
+
* @param {string} signature_b64u
|
|
291
|
+
* @param {string} public_b64u
|
|
292
|
+
* @returns {string}
|
|
293
|
+
*/
|
|
294
|
+
export function dilithium_verify(message_b64u, signature_b64u, public_b64u) {
|
|
295
|
+
let deferred4_0;
|
|
296
|
+
let deferred4_1;
|
|
297
|
+
try {
|
|
298
|
+
const ptr0 = passStringToWasm0(message_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
299
|
+
const len0 = WASM_VECTOR_LEN;
|
|
300
|
+
const ptr1 = passStringToWasm0(signature_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
301
|
+
const len1 = WASM_VECTOR_LEN;
|
|
302
|
+
const ptr2 = passStringToWasm0(public_b64u, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
303
|
+
const len2 = WASM_VECTOR_LEN;
|
|
304
|
+
const ret = wasm.dilithium_verify(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
305
|
+
deferred4_0 = ret[0];
|
|
306
|
+
deferred4_1 = ret[1];
|
|
307
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
308
|
+
} finally {
|
|
309
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
export function start() {
|
|
314
|
+
wasm.start();
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
export function __wbg_buffer_a1a27a0dfa70165d(arg0) {
|
|
318
|
+
const ret = arg0.buffer;
|
|
319
|
+
return ret;
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
export function __wbg_call_f2db6205e5c51dc8() { return handleError(function (arg0, arg1, arg2) {
|
|
323
|
+
const ret = arg0.call(arg1, arg2);
|
|
324
|
+
return ret;
|
|
325
|
+
}, arguments) };
|
|
326
|
+
|
|
327
|
+
export function __wbg_call_fbe8be8bf6436ce5() { return handleError(function (arg0, arg1) {
|
|
328
|
+
const ret = arg0.call(arg1);
|
|
329
|
+
return ret;
|
|
330
|
+
}, arguments) };
|
|
331
|
+
|
|
332
|
+
export function __wbg_crypto_574e78ad8b13b65f(arg0) {
|
|
333
|
+
const ret = arg0.crypto;
|
|
334
|
+
return ret;
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
export function __wbg_getRandomValues_b8f5dbd5f3995a9e() { return handleError(function (arg0, arg1) {
|
|
338
|
+
arg0.getRandomValues(arg1);
|
|
339
|
+
}, arguments) };
|
|
340
|
+
|
|
341
|
+
export function __wbg_log_8bc1206392c556f3(arg0, arg1) {
|
|
342
|
+
console.log(getStringFromWasm0(arg0, arg1));
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
export function __wbg_msCrypto_a61aeb35a24c1329(arg0) {
|
|
346
|
+
const ret = arg0.msCrypto;
|
|
347
|
+
return ret;
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
export function __wbg_new_e52b3efaaa774f96(arg0) {
|
|
351
|
+
const ret = new Uint8Array(arg0);
|
|
352
|
+
return ret;
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
export function __wbg_newnoargs_ff528e72d35de39a(arg0, arg1) {
|
|
356
|
+
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
|
357
|
+
return ret;
|
|
358
|
+
};
|
|
359
|
+
|
|
360
|
+
export function __wbg_newwithbyteoffsetandlength_3b01ecda099177e8(arg0, arg1, arg2) {
|
|
361
|
+
const ret = new Uint8Array(arg0, arg1 >>> 0, arg2 >>> 0);
|
|
362
|
+
return ret;
|
|
363
|
+
};
|
|
364
|
+
|
|
365
|
+
export function __wbg_newwithlength_08f872dc1e3ada2e(arg0) {
|
|
366
|
+
const ret = new Uint8Array(arg0 >>> 0);
|
|
367
|
+
return ret;
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
export function __wbg_node_905d3e251edff8a2(arg0) {
|
|
371
|
+
const ret = arg0.node;
|
|
372
|
+
return ret;
|
|
373
|
+
};
|
|
374
|
+
|
|
375
|
+
export function __wbg_process_dc0fbacc7c1c06f7(arg0) {
|
|
376
|
+
const ret = arg0.process;
|
|
377
|
+
return ret;
|
|
378
|
+
};
|
|
379
|
+
|
|
380
|
+
export function __wbg_randomFillSync_ac0988aba3254290() { return handleError(function (arg0, arg1) {
|
|
381
|
+
arg0.randomFillSync(arg1);
|
|
382
|
+
}, arguments) };
|
|
383
|
+
|
|
384
|
+
export function __wbg_require_60cc747a6bc5215a() { return handleError(function () {
|
|
385
|
+
const ret = module.require;
|
|
386
|
+
return ret;
|
|
387
|
+
}, arguments) };
|
|
388
|
+
|
|
389
|
+
export function __wbg_set_fe4e79d1ed3b0e9b(arg0, arg1, arg2) {
|
|
390
|
+
arg0.set(arg1, arg2 >>> 0);
|
|
391
|
+
};
|
|
392
|
+
|
|
393
|
+
export function __wbg_static_accessor_GLOBAL_487c52c58d65314d() {
|
|
394
|
+
const ret = typeof global === 'undefined' ? null : global;
|
|
395
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
396
|
+
};
|
|
397
|
+
|
|
398
|
+
export function __wbg_static_accessor_GLOBAL_THIS_ee9704f328b6b291() {
|
|
399
|
+
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
400
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
401
|
+
};
|
|
402
|
+
|
|
403
|
+
export function __wbg_static_accessor_SELF_78c9e3071b912620() {
|
|
404
|
+
const ret = typeof self === 'undefined' ? null : self;
|
|
405
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
406
|
+
};
|
|
407
|
+
|
|
408
|
+
export function __wbg_static_accessor_WINDOW_a093d21393777366() {
|
|
409
|
+
const ret = typeof window === 'undefined' ? null : window;
|
|
410
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
411
|
+
};
|
|
412
|
+
|
|
413
|
+
export function __wbg_subarray_dd4ade7d53bd8e26(arg0, arg1, arg2) {
|
|
414
|
+
const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
|
|
415
|
+
return ret;
|
|
416
|
+
};
|
|
417
|
+
|
|
418
|
+
export function __wbg_versions_c01dfd4722a88165(arg0) {
|
|
419
|
+
const ret = arg0.versions;
|
|
420
|
+
return ret;
|
|
421
|
+
};
|
|
422
|
+
|
|
423
|
+
export function __wbindgen_init_externref_table() {
|
|
424
|
+
const table = wasm.__wbindgen_export_2;
|
|
425
|
+
const offset = table.grow(4);
|
|
426
|
+
table.set(0, undefined);
|
|
427
|
+
table.set(offset + 0, undefined);
|
|
428
|
+
table.set(offset + 1, null);
|
|
429
|
+
table.set(offset + 2, true);
|
|
430
|
+
table.set(offset + 3, false);
|
|
431
|
+
;
|
|
432
|
+
};
|
|
433
|
+
|
|
434
|
+
export function __wbindgen_is_function(arg0) {
|
|
435
|
+
const ret = typeof(arg0) === 'function';
|
|
436
|
+
return ret;
|
|
437
|
+
};
|
|
438
|
+
|
|
439
|
+
export function __wbindgen_is_object(arg0) {
|
|
440
|
+
const val = arg0;
|
|
441
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
442
|
+
return ret;
|
|
443
|
+
};
|
|
444
|
+
|
|
445
|
+
export function __wbindgen_is_string(arg0) {
|
|
446
|
+
const ret = typeof(arg0) === 'string';
|
|
447
|
+
return ret;
|
|
448
|
+
};
|
|
449
|
+
|
|
450
|
+
export function __wbindgen_is_undefined(arg0) {
|
|
451
|
+
const ret = arg0 === undefined;
|
|
452
|
+
return ret;
|
|
453
|
+
};
|
|
454
|
+
|
|
455
|
+
export function __wbindgen_memory() {
|
|
456
|
+
const ret = wasm.memory;
|
|
457
|
+
return ret;
|
|
458
|
+
};
|
|
459
|
+
|
|
460
|
+
export function __wbindgen_string_new(arg0, arg1) {
|
|
461
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
462
|
+
return ret;
|
|
463
|
+
};
|
|
464
|
+
|
|
465
|
+
export function __wbindgen_throw(arg0, arg1) {
|
|
466
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
467
|
+
};
|
|
468
|
+
|
package/core_pqc_wasm_bg.wasm
CHANGED
|
Binary file
|
package/node.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import url from 'node:url';
|
|
4
|
+
|
|
5
|
+
// Node-friendly loader: read the .wasm file bytes and initialize the wasm module explicitly.
|
|
6
|
+
import initWasm, * as wasmExports from './core_pqc_wasm.js';
|
|
7
|
+
|
|
8
|
+
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
|
|
9
|
+
const wasmPath = path.join(__dirname, 'core_pqc_wasm_bg.wasm');
|
|
10
|
+
|
|
11
|
+
let ready;
|
|
12
|
+
async function ensureInit() {
|
|
13
|
+
if (!ready) {
|
|
14
|
+
const bytes = await fs.readFile(wasmPath);
|
|
15
|
+
// initWasm accepts BufferSource in Node 18 via WebAssembly.Module path
|
|
16
|
+
ready = initWasm(bytes);
|
|
17
|
+
}
|
|
18
|
+
return ready;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Re-export all bindings, but ensure initialization is performed first when needed.
|
|
22
|
+
// Consumers can call default() to ensure ready, or functions will work after a top-level init in their lib.
|
|
23
|
+
export default async function() {
|
|
24
|
+
await ensureInit();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Named exports: wrap the start/init-sensitive functions to ensure init has happened when called.
|
|
28
|
+
// For simplicity, re-export everything and rely on consumers to call default() or our higher-level wrapper does it.
|
|
29
|
+
export * from './core_pqc_wasm.js';
|
package/package.json
CHANGED
|
@@ -2,19 +2,30 @@
|
|
|
2
2
|
"name": "@maatara/core-pqc-wasm",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"description": "Ma'atara PQC WASM bindings",
|
|
5
|
-
"version": "0.1.
|
|
5
|
+
"version": "0.1.2",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "https://github.com/
|
|
9
|
+
"url": "https://github.com/maatara/Maatara"
|
|
10
10
|
},
|
|
11
11
|
"files": [
|
|
12
12
|
"core_pqc_wasm_bg.wasm",
|
|
13
|
+
"core_pqc_wasm_bg.js",
|
|
13
14
|
"core_pqc_wasm.js",
|
|
14
|
-
"core_pqc_wasm.d.ts"
|
|
15
|
+
"core_pqc_wasm.d.ts",
|
|
16
|
+
"node.js",
|
|
17
|
+
"README.md"
|
|
15
18
|
],
|
|
16
19
|
"main": "core_pqc_wasm.js",
|
|
17
20
|
"types": "core_pqc_wasm.d.ts",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./core_pqc_wasm.d.ts",
|
|
24
|
+
"node": "./node.js",
|
|
25
|
+
"import": "./core_pqc_wasm.js",
|
|
26
|
+
"default": "./core_pqc_wasm.js"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
18
29
|
"sideEffects": [
|
|
19
30
|
"./snippets/*"
|
|
20
31
|
]
|
package/LICENSE
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
Apache License
|
|
2
|
-
Version 2.0, January 2004
|
|
3
|
-
http://www.apache.org/licenses/
|
|
4
|
-
|
|
5
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
-
|
|
7
|
-
1. Definitions.
|
|
8
|
-
|
|
9
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
-
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
-
|
|
12
|
-
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
-
the copyright owner that is granting the License.
|
|
14
|
-
|
|
15
|
-
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
-
other entities that control, are controlled by, or are under common
|
|
17
|
-
control with that entity. For the purposes of this definition,
|
|
18
|
-
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
-
direction or management of such entity, whether by contract or
|
|
20
|
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
-
|
|
23
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
-
exercising permissions granted by this License.
|
|
25
|
-
|
|
26
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
-
including but not limited to software source code, documentation
|
|
28
|
-
source, and configuration files.
|
|
29
|
-
|
|
30
|
-
"Object" form shall mean any form resulting from mechanical
|
|
31
|
-
transformation or translation of a Source form, including but
|
|
32
|
-
not limited to compiled object code, generated documentation,
|
|
33
|
-
and conversions to other media types.
|
|
34
|
-
|
|
35
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
-
Object form, made available under the License, as indicated by a
|
|
37
|
-
copyright notice that is included in or attached to the work
|
|
38
|
-
(an example is provided in the Appendix below).
|
|
39
|
-
|
|
40
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
-
form, that is based on (or derived from) the Work and for which the
|
|
42
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
-
of this License, Derivative Works shall not include works that remain
|
|
45
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
-
the Work and Derivative Works thereof.
|
|
47
|
-
|
|
48
|
-
"Contribution" shall mean any work of authorship, including
|
|
49
|
-
the original version of the Work and any modifications or additions
|
|
50
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
-
means any form of electronic, verbal, or written communication sent
|
|
55
|
-
to the Licensor or its representatives, including but not limited to
|
|
56
|
-
communication on electronic mailing lists, source code control systems,
|
|
57
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
-
excluding communication that is conspicuously marked or otherwise
|
|
60
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
-
|
|
62
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
-
subsequently incorporated within the Work.
|
|
65
|
-
|
|
66
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
-
Work and such Derivative Works in Source or Object form.
|
|
72
|
-
|
|
73
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
-
(except as stated in this section) patent license to make, have made,
|
|
77
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
-
where such license applies only to those patent claims licensable
|
|
79
|
-
by such Contributor that are necessarily infringed by their
|
|
80
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
-
institute patent litigation against any entity (including a
|
|
83
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
-
or contributory patent infringement, then any patent licenses
|
|
86
|
-
granted to You under this License for that Work shall terminate
|
|
87
|
-
as of the date such litigation is filed.
|
|
88
|
-
|
|
89
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
-
modifications, and in Source or Object form, provided that You
|
|
92
|
-
meet the following conditions:
|
|
93
|
-
|
|
94
|
-
(a) You must give any other recipients of the Work or
|
|
95
|
-
Derivative Works a copy of this License; and
|
|
96
|
-
|
|
97
|
-
(b) You must cause any modified files to carry prominent notices
|
|
98
|
-
stating that You changed the files; and
|
|
99
|
-
|
|
100
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
-
that You distribute, all copyright, patent, trademark, and
|
|
102
|
-
attribution notices from the Source form of the Work,
|
|
103
|
-
excluding those notices that do not pertain to any part of
|
|
104
|
-
the Derivative Works; and
|
|
105
|
-
|
|
106
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
-
distribution, then any Derivative Works that You distribute must
|
|
108
|
-
include a readable copy of the attribution notices contained
|
|
109
|
-
within such NOTICE file, excluding those notices that do not
|
|
110
|
-
pertain to any part of the Derivative Works, in at least one
|
|
111
|
-
of the following places: within a NOTICE text file distributed
|
|
112
|
-
as part of the Derivative Works; within the Source form or
|
|
113
|
-
documentation, if provided along with the Derivative Works; or,
|
|
114
|
-
within a display generated by the Derivative Works, if and
|
|
115
|
-
wherever such third-party notices normally appear. The contents
|
|
116
|
-
of the NOTICE file are for informational purposes only and
|
|
117
|
-
do not modify the License. You may add Your own attribution
|
|
118
|
-
notices within Derivative Works that You distribute, alongside
|
|
119
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
-
that such additional attribution notices cannot be construed
|
|
121
|
-
as modifying the License.
|
|
122
|
-
|
|
123
|
-
You may add Your own copyright statement to Your modifications and
|
|
124
|
-
may provide additional or different license terms and conditions
|
|
125
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
-
the conditions stated in this License.
|
|
129
|
-
|
|
130
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
-
this License, without any additional terms or conditions.
|
|
134
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
-
the terms of any separate license agreement you may have executed
|
|
136
|
-
with Licensor regarding such Contributions.
|
|
137
|
-
|
|
138
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
-
except as required for reasonable and customary use in describing the
|
|
141
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
-
|
|
143
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
-
implied, including, without limitation, any warranties or conditions
|
|
148
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
-
appropriateness of using or redistributing the Work and assume any
|
|
151
|
-
risks associated with Your exercise of permissions under this License.
|
|
152
|
-
|
|
153
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
-
unless required by applicable law (such as deliberate and grossly
|
|
156
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
-
liable to You for damages, including any direct, indirect, special,
|
|
158
|
-
incidental, or consequential damages of any character arising as a
|
|
159
|
-
result of this License or out of the use or inability to use the
|
|
160
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
-
other commercial damages or losses), even if such Contributor
|
|
163
|
-
has been advised of the possibility of such damages.
|
|
164
|
-
|
|
165
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
-
or other liability obligations and/or rights consistent with this
|
|
169
|
-
License. However, in accepting such obligations, You may act only
|
|
170
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
-
defend, and hold each Contributor harmless for any liability
|
|
173
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
-
of your accepting any such warranty or additional liability.
|
|
175
|
-
|
|
176
|
-
END OF TERMS AND CONDITIONS
|
|
177
|
-
|
|
178
|
-
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
-
|
|
180
|
-
To apply the Apache License to your work, attach the following
|
|
181
|
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
-
replaced with your own identifying information. (Don't include
|
|
183
|
-
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
-
comment syntax for the file format. We also recommend that a
|
|
185
|
-
file or class name and description of purpose be included on the
|
|
186
|
-
same "printed page" as the copyright notice for easier
|
|
187
|
-
identification within third-party archives.
|
|
188
|
-
|
|
189
|
-
Copyright [2025] [Ma'atara Contributors]
|
|
190
|
-
|
|
191
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
-
you may not use this file except in compliance with the License.
|
|
193
|
-
You may obtain a copy of the License at
|
|
194
|
-
|
|
195
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
-
|
|
197
|
-
Unless required by applicable law or agreed to in writing, software
|
|
198
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
-
See the License for the specific language governing permissions and
|
|
201
|
-
limitations under the License.
|