@qntx/nostr-wasm 0.12.0 → 0.13.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # @qntx/nostr-wasm
2
2
 
3
- WebAssembly-accelerated cryptography for [`@qntx/nostr`](https://www.npmjs.com/package/@qntx/nostr) (BIP-340 signing and event verification), built from the `nk-wasm` Rust crate.
3
+ WebAssembly-accelerated cryptography for [`@qntx/nostr`](https://www.npmjs.com/package/@qntx/nostr) (BIP-340 signing and event verification), built from the shared libsecp256k1 C core in `@qntx/nostr-native` (`packages/nostr-native/cpp`) compiled for wasm32.
4
4
 
5
5
  ```bash
6
6
  npm install @qntx/nostr-wasm @qntx/nostr
@@ -1,4 +1,4 @@
1
- import { EventVerifier, SigningBackend, WasmPoisonedError as WasmPoisonedError$1 } from "@qntx/nostr/core";
1
+ import { EventVerifier, NostrError, SigningBackend } from "@qntx/nostr/core";
2
2
  //#region src/instance.d.ts
3
3
  type LoadNostrWasmOptions = {
4
4
  /** Bytes, or a URL whose bytes will be read by the platform loader. */
@@ -10,5 +10,11 @@ type NostrWasm = SigningBackend & {
10
10
  verifyEvent: EventVerifier;
11
11
  };
12
12
  //#endregion
13
- export { LoadNostrWasmOptions as n, NostrWasm as r, WasmPoisonedError$1 as t };
14
- //# sourceMappingURL=adapter-BPemxR6e.d.mts.map
13
+ //#region src/adapter.d.ts
14
+ /** Wasm instance aborted; later calls on that instance fail. */
15
+ declare class WasmPoisonedError extends NostrError {
16
+ name: string;
17
+ }
18
+ //#endregion
19
+ export { LoadNostrWasmOptions as n, NostrWasm as r, WasmPoisonedError as t };
20
+ //# sourceMappingURL=adapter-DMQvHVO_.d.mts.map
@@ -1,4 +1,4 @@
1
- import { n as LoadNostrWasmOptions, r as NostrWasm, t as WasmPoisonedError } from "./adapter-BPemxR6e.mjs";
1
+ import { n as LoadNostrWasmOptions, r as NostrWasm, t as WasmPoisonedError } from "./adapter-DMQvHVO_.mjs";
2
2
  //#region src/load.browser.d.ts
3
3
  /** Instantiate once. Repeats reuse the same module. Failure throws; no noble fallback. */
4
4
  export declare function loadNostrWasm(opts?: LoadNostrWasmOptions): Promise<NostrWasm>;
package/dist/browser.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { i as WasmPoisonedError, n as fetchWasmUrl, r as isWasmBytes, t as createNostrWasmLoader } from "./instance-CFwzTT0p.mjs";
1
+ import { i as WasmPoisonedError, n as fetchWasmUrl, r as isWasmBytes, t as createNostrWasmLoader } from "./instance-6y1G4BjC.mjs";
2
2
  import { CryptoError } from "@qntx/nostr/core";
3
3
  //#region src/load.browser.ts
4
4
  async function wasmBytes(opts) {
@@ -6,7 +6,7 @@ async function wasmBytes(opts) {
6
6
  if (source !== void 0 && isWasmBytes(source)) return source;
7
7
  if (source instanceof URL && source.protocol !== "file:") return fetchWasmUrl(source);
8
8
  if (source instanceof URL) throw new CryptoError(`cannot fetch wasm from ${source.href}`);
9
- return fetchWasmUrl(new URL("nk_wasm.wasm", import.meta.url));
9
+ return fetchWasmUrl(new URL("nostr_wasm.wasm", import.meta.url));
10
10
  }
11
11
  const loader = createNostrWasmLoader(wasmBytes);
12
12
  /** Instantiate once. Repeats reuse the same module. Failure throws; no noble fallback. */
@@ -1 +1 @@
1
- {"version":3,"file":"browser.mjs","names":[],"sources":["../src/load.browser.ts"],"sourcesContent":["import { CryptoError } from \"@qntx/nostr/core\";\n\nimport { createNostrWasmLoader, fetchWasmUrl, isWasmBytes } from \"./instance.ts\";\nimport type { LoadNostrWasmOptions, NostrWasm } from \"./instance.ts\";\n\nexport type { LoadNostrWasmOptions, NostrWasm } from \"./instance.ts\";\n\nasync function wasmBytes(opts?: LoadNostrWasmOptions): Promise<ArrayBuffer | ArrayBufferView> {\n const source = opts?.module;\n if (source !== undefined && isWasmBytes(source)) {\n return source;\n }\n if (source instanceof URL && source.protocol !== \"file:\") {\n return fetchWasmUrl(source);\n }\n if (source instanceof URL) {\n throw new CryptoError(`cannot fetch wasm from ${source.href}`);\n }\n return fetchWasmUrl(new URL(\"nk_wasm.wasm\", import.meta.url));\n}\n\nconst loader = createNostrWasmLoader(wasmBytes);\n\n/** Instantiate once. Repeats reuse the same module. Failure throws; no noble fallback. */\nexport async function loadNostrWasm(opts?: LoadNostrWasmOptions): Promise<NostrWasm> {\n return loader.loadNostrWasm(opts);\n}\n"],"mappings":";;;AAOA,eAAe,UAAU,MAAqE;CAC5F,MAAM,SAAS,MAAM;CACrB,IAAI,WAAW,KAAA,KAAa,YAAY,MAAM,GAC5C,OAAO;CAET,IAAI,kBAAkB,OAAO,OAAO,aAAa,SAC/C,OAAO,aAAa,MAAM;CAE5B,IAAI,kBAAkB,KACpB,MAAM,IAAI,YAAY,0BAA0B,OAAO,MAAM;CAE/D,OAAO,aAAa,IAAI,IAAI,gBAAgB,YAAY,GAAG,CAAC;AAC9D;AAEA,MAAM,SAAS,sBAAsB,SAAS;;AAG9C,eAAsB,cAAc,MAAiD;CACnF,OAAO,OAAO,cAAc,IAAI;AAClC"}
1
+ {"version":3,"file":"browser.mjs","names":[],"sources":["../src/load.browser.ts"],"sourcesContent":["import { CryptoError } from \"@qntx/nostr/core\";\n\nimport { createNostrWasmLoader, fetchWasmUrl, isWasmBytes } from \"./instance.ts\";\nimport type { LoadNostrWasmOptions, NostrWasm } from \"./instance.ts\";\n\nexport type { LoadNostrWasmOptions, NostrWasm } from \"./instance.ts\";\n\nasync function wasmBytes(opts?: LoadNostrWasmOptions): Promise<ArrayBuffer | ArrayBufferView> {\n const source = opts?.module;\n if (source !== undefined && isWasmBytes(source)) {\n return source;\n }\n if (source instanceof URL && source.protocol !== \"file:\") {\n return fetchWasmUrl(source);\n }\n if (source instanceof URL) {\n throw new CryptoError(`cannot fetch wasm from ${source.href}`);\n }\n return fetchWasmUrl(new URL(\"nostr_wasm.wasm\", import.meta.url));\n}\n\nconst loader = createNostrWasmLoader(wasmBytes);\n\n/** Instantiate once. Repeats reuse the same module. Failure throws; no noble fallback. */\nexport async function loadNostrWasm(opts?: LoadNostrWasmOptions): Promise<NostrWasm> {\n return loader.loadNostrWasm(opts);\n}\n"],"mappings":";;;AAOA,eAAe,UAAU,MAAqE;CAC5F,MAAM,SAAS,MAAM;CACrB,IAAI,WAAW,KAAA,KAAa,YAAY,MAAM,GAC5C,OAAO;CAET,IAAI,kBAAkB,OAAO,OAAO,aAAa,SAC/C,OAAO,aAAa,MAAM;CAE5B,IAAI,kBAAkB,KACpB,MAAM,IAAI,YAAY,0BAA0B,OAAO,MAAM;CAE/D,OAAO,aAAa,IAAI,IAAI,mBAAmB,YAAY,GAAG,CAAC;AACjE;AAEA,MAAM,SAAS,sBAAsB,SAAS;;AAG9C,eAAsB,cAAc,MAAiD;CACnF,OAAO,OAAO,cAAc,IAAI;AAClC"}
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { n as LoadNostrWasmOptions, r as NostrWasm, t as WasmPoisonedError } from "./adapter-BPemxR6e.mjs";
1
+ import { n as LoadNostrWasmOptions, r as NostrWasm, t as WasmPoisonedError } from "./adapter-DMQvHVO_.mjs";
2
2
  //#region src/load.d.ts
3
3
  /** Instantiate once. Repeats reuse the same module. Failure throws; no noble fallback. */
4
4
  export declare function loadNostrWasm(opts?: LoadNostrWasmOptions): Promise<NostrWasm>;
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import { i as WasmPoisonedError, n as fetchWasmUrl, r as isWasmBytes, t as createNostrWasmLoader } from "./instance-CFwzTT0p.mjs";
1
+ import { i as WasmPoisonedError, n as fetchWasmUrl, r as isWasmBytes, t as createNostrWasmLoader } from "./instance-6y1G4BjC.mjs";
2
2
  //#region src/load.ts
3
3
  async function defaultWasmHref() {
4
- return (await import("./nk_wasm-BbbBKBiH.mjs")).default;
4
+ return (await import("./nostr_wasm-BkgBL7qN.mjs")).default;
5
5
  }
6
6
  async function readWasmUrl(url) {
7
7
  if (url.protocol === "file:") {
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/load.ts"],"sourcesContent":["import { createNostrWasmLoader, fetchWasmUrl, isWasmBytes } from \"./instance.ts\";\nimport type { LoadNostrWasmOptions, NostrWasm } from \"./instance.ts\";\n\nexport { WasmPoisonedError } from \"./adapter.ts\";\nexport type { LoadNostrWasmOptions, NostrWasm } from \"./instance.ts\";\n\nasync function defaultWasmHref(): Promise<string> {\n const mod = await import(\"./nk_wasm.wasm?url\");\n return mod.default;\n}\n\nasync function readWasmUrl(url: URL): Promise<Uint8Array> {\n if (url.protocol === \"file:\") {\n const { readFile } = await import(\"node:fs/promises\");\n const { fileURLToPath } = await import(\"node:url\");\n return new Uint8Array(await readFile(fileURLToPath(url)));\n }\n return fetchWasmUrl(url);\n}\n\nasync function wasmBytes(opts?: LoadNostrWasmOptions): Promise<ArrayBuffer | ArrayBufferView> {\n const source = opts?.module;\n if (source !== undefined && isWasmBytes(source)) {\n return source;\n }\n const href = source instanceof URL ? source : new URL(await defaultWasmHref(), import.meta.url);\n return readWasmUrl(href);\n}\n\nconst loader = createNostrWasmLoader(wasmBytes);\n\n/** Instantiate once. Repeats reuse the same module. Failure throws; no noble fallback. */\nexport async function loadNostrWasm(opts?: LoadNostrWasmOptions): Promise<NostrWasm> {\n return loader.loadNostrWasm(opts);\n}\n"],"mappings":";;AAMA,eAAe,kBAAmC;CAEhD,QAAO,MADW,OAAO,0BAAA,CACd;AACb;AAEA,eAAe,YAAY,KAA+B;CACxD,IAAI,IAAI,aAAa,SAAS;EAC5B,MAAM,EAAE,aAAa,MAAM,OAAO;EAClC,MAAM,EAAE,kBAAkB,MAAM,OAAO;EACvC,OAAO,IAAI,WAAW,MAAM,SAAS,cAAc,GAAG,CAAC,CAAC;CAC1D;CACA,OAAO,aAAa,GAAG;AACzB;AAEA,eAAe,UAAU,MAAqE;CAC5F,MAAM,SAAS,MAAM;CACrB,IAAI,WAAW,KAAA,KAAa,YAAY,MAAM,GAC5C,OAAO;CAGT,OAAO,YADM,kBAAkB,MAAM,SAAS,IAAI,IAAI,MAAM,gBAAgB,GAAG,YAAY,GAAG,CACvE;AACzB;AAEA,MAAM,SAAS,sBAAsB,SAAS;;AAG9C,eAAsB,cAAc,MAAiD;CACnF,OAAO,OAAO,cAAc,IAAI;AAClC"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/load.ts"],"sourcesContent":["import { createNostrWasmLoader, fetchWasmUrl, isWasmBytes } from \"./instance.ts\";\nimport type { LoadNostrWasmOptions, NostrWasm } from \"./instance.ts\";\n\nexport { WasmPoisonedError } from \"./adapter.ts\";\nexport type { LoadNostrWasmOptions, NostrWasm } from \"./instance.ts\";\n\nasync function defaultWasmHref(): Promise<string> {\n const mod = await import(\"./nostr_wasm.wasm?url\");\n return mod.default;\n}\n\nasync function readWasmUrl(url: URL): Promise<Uint8Array> {\n if (url.protocol === \"file:\") {\n const { readFile } = await import(\"node:fs/promises\");\n const { fileURLToPath } = await import(\"node:url\");\n return new Uint8Array(await readFile(fileURLToPath(url)));\n }\n return fetchWasmUrl(url);\n}\n\nasync function wasmBytes(opts?: LoadNostrWasmOptions): Promise<ArrayBuffer | ArrayBufferView> {\n const source = opts?.module;\n if (source !== undefined && isWasmBytes(source)) {\n return source;\n }\n const href = source instanceof URL ? source : new URL(await defaultWasmHref(), import.meta.url);\n return readWasmUrl(href);\n}\n\nconst loader = createNostrWasmLoader(wasmBytes);\n\n/** Instantiate once. Repeats reuse the same module. Failure throws; no noble fallback. */\nexport async function loadNostrWasm(opts?: LoadNostrWasmOptions): Promise<NostrWasm> {\n return loader.loadNostrWasm(opts);\n}\n"],"mappings":";;AAMA,eAAe,kBAAmC;CAEhD,QAAO,MADW,OAAO,6BAAA,CACd;AACb;AAEA,eAAe,YAAY,KAA+B;CACxD,IAAI,IAAI,aAAa,SAAS;EAC5B,MAAM,EAAE,aAAa,MAAM,OAAO;EAClC,MAAM,EAAE,kBAAkB,MAAM,OAAO;EACvC,OAAO,IAAI,WAAW,MAAM,SAAS,cAAc,GAAG,CAAC,CAAC;CAC1D;CACA,OAAO,aAAa,GAAG;AACzB;AAEA,eAAe,UAAU,MAAqE;CAC5F,MAAM,SAAS,MAAM;CACrB,IAAI,WAAW,KAAA,KAAa,YAAY,MAAM,GAC5C,OAAO;CAGT,OAAO,YADM,kBAAkB,MAAM,SAAS,IAAI,IAAI,MAAM,gBAAgB,GAAG,YAAY,GAAG,CACvE;AACzB;AAEA,MAAM,SAAS,sBAAsB,SAAS;;AAG9C,eAAsB,cAAc,MAAiD;CACnF,OAAO,OAAO,cAAc,IAAI;AAClC"}
@@ -1,4 +1,5 @@
1
- import { CryptoError, WasmPoisonedError, WasmPoisonedError as WasmPoisonedError$1, createEventVerifier } from "@qntx/nostr/core";
1
+ import { CryptoError, NostrError, createEventVerifier, randomBytes } from "@qntx/nostr/core";
2
+ const SEED_LEN = 32;
2
3
  const ID_LEN = 32;
3
4
  const PUBKEY_LEN = 32;
4
5
  const SIG_LEN = 64;
@@ -14,20 +15,24 @@ function requireFn(value, name) {
14
15
  function asExports(raw) {
15
16
  return {
16
17
  memory: requireMemory(raw["memory"]),
17
- nk_abi_version: requireFn(raw["nk_abi_version"], "nk_abi_version"),
18
- nk_buffer: requireFn(raw["nk_buffer"], "nk_buffer"),
19
- nk_verify: requireFn(raw["nk_verify"], "nk_verify"),
20
- nk_verify_serialized: requireFn(raw["nk_verify_serialized"], "nk_verify_serialized"),
21
- nk_sign: requireFn(raw["nk_sign"], "nk_sign"),
22
- nk_public_key: requireFn(raw["nk_public_key"], "nk_public_key")
18
+ nostr_abi_version: requireFn(raw["nostr_abi_version"], "nostr_abi_version"),
19
+ nostr_init: requireFn(raw["nostr_init"], "nostr_init"),
20
+ nostr_buffer: requireFn(raw["nostr_buffer"], "nostr_buffer"),
21
+ nostr_verify: requireFn(raw["nostr_verify"], "nostr_verify"),
22
+ nostr_verify_serialized: requireFn(raw["nostr_verify_serialized"], "nostr_verify_serialized"),
23
+ nostr_sign: requireFn(raw["nostr_sign"], "nostr_sign"),
24
+ nostr_public_key: requireFn(raw["nostr_public_key"], "nostr_public_key")
23
25
  };
24
26
  }
25
27
  /**
26
- * Reserve `total` bytes in the wasm scratch region and return a fresh view. The view is taken after
27
- * `nk_buffer` ran, so a growth inside it cannot leave a detached view in the caller's hands.
28
+ * Reserve `total` bytes in the wasm scratch region and return a fresh view. `nostr_buffer` returns
29
+ * NULL when `memory.grow` fails; `__heap_base` is never 0, so 0 is unambiguously an allocation
30
+ * failure — throw instead of writing at address 0. The view is taken after `nostr_buffer` ran, so a
31
+ * growth inside it cannot leave a detached view in the caller's hands.
28
32
  */
29
33
  function scratch(exports, total) {
30
- const ptr = exports.nk_buffer(total) >>> 0;
34
+ const ptr = exports.nostr_buffer(total) >>> 0;
35
+ if (ptr === 0) throw new CryptoError("wasm scratch allocation failed");
31
36
  return {
32
37
  ptr,
33
38
  view: new Uint8Array(exports.memory.buffer, ptr, total)
@@ -45,7 +50,7 @@ function wasmVerify(exports, id, pubkey, sig) {
45
50
  view.set(id, 0);
46
51
  view.set(pubkey, ID_LEN);
47
52
  view.set(sig, 64);
48
- return exports.nk_verify(ptr, ptr + ID_LEN, ptr + ID_LEN + PUBKEY_LEN) === 0;
53
+ return exports.nostr_verify(ptr, ptr + ID_LEN, ptr + ID_LEN + PUBKEY_LEN) === 0;
49
54
  }
50
55
  function wasmVerifySerialized(exports, serialized, id, pubkey, sig) {
51
56
  if (id.length !== ID_LEN || pubkey.length !== PUBKEY_LEN || sig.length !== SIG_LEN) return false;
@@ -55,11 +60,11 @@ function wasmVerifySerialized(exports, serialized, id, pubkey, sig) {
55
60
  view.set(id, serLen);
56
61
  view.set(pubkey, serLen + ID_LEN);
57
62
  view.set(sig, serLen + ID_LEN + PUBKEY_LEN);
58
- return exports.nk_verify_serialized(ptr, serLen, ptr + serLen, ptr + serLen + ID_LEN, ptr + serLen + ID_LEN + PUBKEY_LEN) === 0;
63
+ return exports.nostr_verify_serialized(ptr, serLen, ptr + serLen, ptr + serLen + ID_LEN, ptr + serLen + ID_LEN + PUBKEY_LEN) === 0;
59
64
  }
60
65
  /**
61
- * Returns the 64-byte signature, or an empty array on failure (invalid input). The Rust side zeroes
62
- * the scratch copy of `seckey` before returning.
66
+ * Returns the 64-byte signature, or an empty array on failure (invalid input). The wasm module
67
+ * zeroes the scratch copy of `seckey` before returning.
63
68
  */
64
69
  function wasmSign(exports, id, seckey, aux) {
65
70
  const outOffset = 96;
@@ -67,35 +72,43 @@ function wasmSign(exports, id, seckey, aux) {
67
72
  view.set(id, 0);
68
73
  view.set(seckey, ID_LEN);
69
74
  view.set(aux, 64);
70
- if (exports.nk_sign(ptr, ptr + ID_LEN, ptr + ID_LEN + SECKEY_LEN, ptr + outOffset) !== 0) return /* @__PURE__ */ new Uint8Array(0);
75
+ if (exports.nostr_sign(ptr, ptr + ID_LEN, ptr + ID_LEN + SECKEY_LEN, ptr + outOffset) !== 0) return /* @__PURE__ */ new Uint8Array(0);
71
76
  return takeOut(exports, ptr + outOffset, SIG_LEN);
72
77
  }
73
78
  /**
74
- * Returns the 32-byte x-only public key, or an empty array on failure. The Rust side zeroes the
79
+ * Returns the 32-byte x-only public key, or an empty array on failure. The wasm module zeroes the
75
80
  * scratch copy of `seckey` before returning.
76
81
  */
77
82
  function wasmPublicKey(exports, seckey) {
78
83
  const { ptr, view } = scratch(exports, 64);
79
84
  view.set(seckey, 0);
80
- if (exports.nk_public_key(ptr, ptr + SECKEY_LEN) !== 0) return /* @__PURE__ */ new Uint8Array(0);
85
+ if (exports.nostr_public_key(ptr, ptr + SECKEY_LEN) !== 0) return /* @__PURE__ */ new Uint8Array(0);
81
86
  return takeOut(exports, ptr + SECKEY_LEN, PUBKEY_LEN);
82
87
  }
83
88
  /**
84
- * Compile and instantiate `nk_wasm.wasm`. The module must declare no imports and must implement ABI
85
- * version {@link NK_ABI_VERSION} — a mismatch means the artifact predates or postdates this loader
86
- * and instantiation fails.
89
+ * Compile and instantiate `nostr_wasm.wasm`. The module must declare no imports and must implement
90
+ * ABI version {@link NOSTR_ABI_VERSION} — a mismatch means the artifact predates or postdates this
91
+ * loader and instantiation fails.
87
92
  */
88
93
  async function instantiateCryptoWasm(bytes) {
89
94
  const module = await WebAssembly.compile(bytes);
90
95
  const imports = WebAssembly.Module.imports(module);
91
- if (imports.length > 0) throw new TypeError(`nk_wasm module must not import anything, got ${imports.length} imports`);
96
+ if (imports.length > 0) throw new TypeError(`nostr_wasm module must not import anything, got ${imports.length} imports`);
92
97
  const instance = await WebAssembly.instantiate(module, {});
93
- const version = requireFn(instance.exports["nk_abi_version"], "nk_abi_version")();
94
- if (version !== 1) throw new CryptoError(`unsupported nk_wasm ABI version ${String(version)}, expected 1`);
95
- return asExports(instance.exports);
98
+ const version = requireFn(instance.exports["nostr_abi_version"], "nostr_abi_version")();
99
+ if (version !== 3) throw new CryptoError(`unsupported nostr_wasm ABI version ${String(version)}, expected 3`);
100
+ const exports = asExports(instance.exports);
101
+ const { ptr, view } = scratch(exports, SEED_LEN);
102
+ view.set(randomBytes(SEED_LEN), 0);
103
+ if (exports.nostr_init(ptr) !== 0) throw new CryptoError("nostr_init failed to randomize the wasm context");
104
+ return exports;
96
105
  }
97
106
  //#endregion
98
107
  //#region src/adapter.ts
108
+ /** Wasm instance aborted; later calls on that instance fail. */
109
+ var WasmPoisonedError = class extends NostrError {
110
+ name = "WasmPoisonedError";
111
+ };
99
112
  /**
100
113
  * Run `fn` unless the instance is already poisoned; a `WebAssembly.RuntimeError` aborts the
101
114
  * instance, so it is converted to {@link WasmPoisonedError} and rethrown on every later call.
@@ -191,6 +204,6 @@ function createNostrWasmLoader(wasmBytes) {
191
204
  };
192
205
  }
193
206
  //#endregion
194
- export { WasmPoisonedError$1 as i, fetchWasmUrl as n, isWasmBytes as r, createNostrWasmLoader as t };
207
+ export { WasmPoisonedError as i, fetchWasmUrl as n, isWasmBytes as r, createNostrWasmLoader as t };
195
208
 
196
- //# sourceMappingURL=instance-CFwzTT0p.mjs.map
209
+ //# sourceMappingURL=instance-6y1G4BjC.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instance-6y1G4BjC.mjs","names":[],"sources":["../src/abi.ts","../src/adapter.ts","../src/instance.ts"],"sourcesContent":["import { CryptoError, randomBytes } from \"@qntx/nostr/core\";\n\n/**\n * Byte-ABI version 3 surface exported by `nostr_wasm.wasm` (`packages/nostr-wasm/c/nostr_wasm.c`\n * over the shared `nostr_core.c` in `packages/nostr-native/cpp`). All inputs are caller-written\n * regions of a single scratch buffer; status codes are 0 ok/verified, 1 verification failed, 2\n * invalid input. `nostr_init` must succeed once with a 32-byte seed before the crypto ops run.\n */\nexport type CryptoWasmExports = {\n memory: WebAssembly.Memory;\n nostr_abi_version: () => number;\n nostr_init: (seed: number) => number;\n nostr_buffer: (len: number) => number;\n nostr_verify: (id: number, pubkey: number, sig: number) => number;\n nostr_verify_serialized: (\n ser: number,\n serLen: number,\n id: number,\n pubkey: number,\n sig: number,\n ) => number;\n nostr_sign: (id: number, seckey: number, aux: number, outSig: number) => number;\n nostr_public_key: (seckey: number, outPubkey: number) => number;\n};\n\nexport const NOSTR_ABI_VERSION = 3;\n\nconst SEED_LEN = 32;\n\nconst ID_LEN = 32;\nconst PUBKEY_LEN = 32;\nconst SIG_LEN = 64;\nconst SECKEY_LEN = 32;\nconst AUX_LEN = 32;\n\nfunction requireMemory(value: WebAssembly.ExportValue | undefined): WebAssembly.Memory {\n if (!(value instanceof WebAssembly.Memory)) {\n throw new TypeError(\"wasm missing memory export\");\n }\n return value;\n}\n\n// oxlint-disable-next-line typescript/no-unnecessary-type-parameters -- T binds the declared ABI signature at each call site\nfunction requireFn<T extends (...args: number[]) => unknown>(\n value: WebAssembly.ExportValue | undefined,\n name: string,\n): T {\n if (typeof value !== \"function\") {\n throw new TypeError(`wasm missing ${name} export`);\n }\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion -- wasm exports are opaque; each name is bound to the signature the ABI contract requires\n return value as T;\n}\n\nfunction asExports(raw: WebAssembly.Exports): CryptoWasmExports {\n return {\n memory: requireMemory(raw[\"memory\"]),\n nostr_abi_version: requireFn(raw[\"nostr_abi_version\"], \"nostr_abi_version\"),\n nostr_init: requireFn(raw[\"nostr_init\"], \"nostr_init\"),\n nostr_buffer: requireFn(raw[\"nostr_buffer\"], \"nostr_buffer\"),\n nostr_verify: requireFn(raw[\"nostr_verify\"], \"nostr_verify\"),\n nostr_verify_serialized: requireFn(raw[\"nostr_verify_serialized\"], \"nostr_verify_serialized\"),\n nostr_sign: requireFn(raw[\"nostr_sign\"], \"nostr_sign\"),\n nostr_public_key: requireFn(raw[\"nostr_public_key\"], \"nostr_public_key\"),\n };\n}\n\n/**\n * Reserve `total` bytes in the wasm scratch region and return a fresh view. `nostr_buffer` returns\n * NULL when `memory.grow` fails; `__heap_base` is never 0, so 0 is unambiguously an allocation\n * failure — throw instead of writing at address 0. The view is taken after `nostr_buffer` ran, so a\n * growth inside it cannot leave a detached view in the caller's hands.\n */\nfunction scratch(exports: CryptoWasmExports, total: number): { ptr: number; view: Uint8Array } {\n const ptr = exports.nostr_buffer(total) >>> 0;\n if (ptr === 0) {\n throw new CryptoError(\"wasm scratch allocation failed\");\n }\n return { ptr, view: new Uint8Array(exports.memory.buffer, ptr, total) };\n}\n\n/** Copies `len` scratch bytes out; the view is re-acquired after the call. */\nfunction takeOut(exports: CryptoWasmExports, ptr: number, len: number): Uint8Array {\n const out = new Uint8Array(len);\n out.set(new Uint8Array(exports.memory.buffer, ptr, len));\n return out;\n}\n\nexport function wasmVerify(\n exports: CryptoWasmExports,\n id: Uint8Array,\n pubkey: Uint8Array,\n sig: Uint8Array,\n): boolean {\n if (id.length !== ID_LEN || pubkey.length !== PUBKEY_LEN || sig.length !== SIG_LEN) {\n return false; // fixed-size ABI: a wrong-length input simply cannot verify\n }\n const { ptr, view } = scratch(exports, ID_LEN + PUBKEY_LEN + SIG_LEN);\n view.set(id, 0);\n view.set(pubkey, ID_LEN);\n view.set(sig, ID_LEN + PUBKEY_LEN);\n return exports.nostr_verify(ptr, ptr + ID_LEN, ptr + ID_LEN + PUBKEY_LEN) === 0;\n}\n\nexport function wasmVerifySerialized(\n exports: CryptoWasmExports,\n serialized: Uint8Array,\n id: Uint8Array,\n pubkey: Uint8Array,\n sig: Uint8Array,\n): boolean {\n if (id.length !== ID_LEN || pubkey.length !== PUBKEY_LEN || sig.length !== SIG_LEN) {\n return false;\n }\n const serLen = serialized.length;\n const { ptr, view } = scratch(exports, serLen + ID_LEN + PUBKEY_LEN + SIG_LEN);\n view.set(serialized, 0);\n view.set(id, serLen);\n view.set(pubkey, serLen + ID_LEN);\n view.set(sig, serLen + ID_LEN + PUBKEY_LEN);\n return (\n exports.nostr_verify_serialized(\n ptr,\n serLen,\n ptr + serLen,\n ptr + serLen + ID_LEN,\n ptr + serLen + ID_LEN + PUBKEY_LEN,\n ) === 0\n );\n}\n\n/**\n * Returns the 64-byte signature, or an empty array on failure (invalid input). The wasm module\n * zeroes the scratch copy of `seckey` before returning.\n */\nexport function wasmSign(\n exports: CryptoWasmExports,\n id: Uint8Array,\n seckey: Uint8Array,\n aux: Uint8Array,\n): Uint8Array {\n const outOffset = ID_LEN + SECKEY_LEN + AUX_LEN;\n const { ptr, view } = scratch(exports, outOffset + SIG_LEN);\n view.set(id, 0);\n view.set(seckey, ID_LEN);\n view.set(aux, ID_LEN + SECKEY_LEN);\n const status = exports.nostr_sign(ptr, ptr + ID_LEN, ptr + ID_LEN + SECKEY_LEN, ptr + outOffset);\n if (status !== 0) {\n return new Uint8Array(0);\n }\n return takeOut(exports, ptr + outOffset, SIG_LEN);\n}\n\n/**\n * Returns the 32-byte x-only public key, or an empty array on failure. The wasm module zeroes the\n * scratch copy of `seckey` before returning.\n */\nexport function wasmPublicKey(exports: CryptoWasmExports, seckey: Uint8Array): Uint8Array {\n const { ptr, view } = scratch(exports, SECKEY_LEN + PUBKEY_LEN);\n view.set(seckey, 0);\n const status = exports.nostr_public_key(ptr, ptr + SECKEY_LEN);\n if (status !== 0) {\n return new Uint8Array(0);\n }\n return takeOut(exports, ptr + SECKEY_LEN, PUBKEY_LEN);\n}\n\n/**\n * Compile and instantiate `nostr_wasm.wasm`. The module must declare no imports and must implement\n * ABI version {@link NOSTR_ABI_VERSION} — a mismatch means the artifact predates or postdates this\n * loader and instantiation fails.\n */\nexport async function instantiateCryptoWasm(\n bytes: ArrayBuffer | ArrayBufferView,\n): Promise<CryptoWasmExports> {\n const module = await WebAssembly.compile(bytes);\n const imports = WebAssembly.Module.imports(module);\n if (imports.length > 0) {\n throw new TypeError(\n `nostr_wasm module must not import anything, got ${imports.length} imports`,\n );\n }\n const instance = await WebAssembly.instantiate(module, {});\n const version = requireFn(instance.exports[\"nostr_abi_version\"], \"nostr_abi_version\")();\n if (version !== NOSTR_ABI_VERSION) {\n throw new CryptoError(\n `unsupported nostr_wasm ABI version ${String(version)}, expected ${NOSTR_ABI_VERSION}`,\n );\n }\n const exports = asExports(instance.exports);\n // Seed the context: 32 bytes of fresh randomness into the scratch buffer; the C side\n // randomizes the context and wipes the seed region on every path.\n const { ptr, view } = scratch(exports, SEED_LEN);\n view.set(randomBytes(SEED_LEN), 0);\n if (exports.nostr_init(ptr) !== 0) {\n throw new CryptoError(\"nostr_init failed to randomize the wasm context\");\n }\n return exports;\n}\n","import { NostrError, createEventVerifier } from \"@qntx/nostr/core\";\nimport type { EventVerifier, SerializedEventVerifier } from \"@qntx/nostr/core\";\n\n/** Wasm instance aborted; later calls on that instance fail. */\nexport class WasmPoisonedError extends NostrError {\n override name = \"WasmPoisonedError\";\n}\n\n/**\n * Run `fn` unless the instance is already poisoned; a `WebAssembly.RuntimeError` aborts the\n * instance, so it is converted to {@link WasmPoisonedError} and rethrown on every later call.\n */\nexport function runPoisoned<T>(poison: { error?: Error }, fn: () => T): T {\n if (poison.error !== undefined) {\n throw poison.error;\n }\n try {\n return fn();\n } catch (error) {\n if (error instanceof WebAssembly.RuntimeError) {\n poison.error = new WasmPoisonedError(\"wasm instance aborted\", {\n cause: error,\n });\n throw poison.error;\n }\n throw error;\n }\n}\n\n/**\n * Build the WASM event verifier on {@link createEventVerifier}. A `WebAssembly.RuntimeError` from\n * the module means the instance aborted — it poisons every later call with the same\n * `WasmPoisonedError`; any other backend error verifies `false` (the event is marked failed).\n */\nexport function createWasmEventVerifier(\n verifySerialized: SerializedEventVerifier,\n poison: { error?: Error },\n): EventVerifier {\n const backend: SerializedEventVerifier = (serializedUtf8, id, pubkey, sig) => {\n try {\n return runPoisoned(poison, () => verifySerialized(serializedUtf8, id, pubkey, sig));\n } catch (error) {\n if (error instanceof WasmPoisonedError) {\n throw error;\n }\n return false;\n }\n };\n return createEventVerifier(backend);\n}\n","import { CryptoError } from \"@qntx/nostr/core\";\nimport type { SigningBackend, EventVerifier } from \"@qntx/nostr/core\";\n\nimport {\n instantiateCryptoWasm,\n wasmPublicKey,\n wasmSign,\n wasmVerify,\n wasmVerifySerialized,\n} from \"./abi.ts\";\nimport type { CryptoWasmExports } from \"./abi.ts\";\nimport { createWasmEventVerifier, runPoisoned } from \"./adapter.ts\";\n\nexport type LoadNostrWasmOptions = {\n /** Bytes, or a URL whose bytes will be read by the platform loader. */\n module?: ArrayBuffer | ArrayBufferView | URL | undefined;\n};\n\nexport type NostrWasm = SigningBackend & {\n verify: (id: Uint8Array, pubkey: Uint8Array, sig: Uint8Array) => boolean;\n verifySerialized: (\n serializedUtf8: Uint8Array,\n id: Uint8Array,\n pubkey: Uint8Array,\n sig: Uint8Array,\n ) => boolean;\n verifyEvent: EventVerifier;\n};\n\nexport function isWasmBytes(value: unknown): value is ArrayBuffer | ArrayBufferView {\n return value instanceof ArrayBuffer || ArrayBuffer.isView(value);\n}\n\nexport async function fetchWasmUrl(url: URL): Promise<Uint8Array> {\n const res = await fetch(url);\n if (!res.ok) {\n throw new CryptoError(`failed to fetch wasm: ${res.status} ${url.href}`);\n }\n return new Uint8Array(await res.arrayBuffer());\n}\n\nfunction requireByteLength(bytes: Uint8Array, expected: number, label: string): void {\n if (bytes.length !== expected) {\n throw new CryptoError(`invalid ${label} length: expected ${expected}, got ${bytes.length}`);\n }\n}\n\nfunction bindExports(exports: CryptoWasmExports): NostrWasm {\n const poison: { error?: Error } = {};\n const rawSerialized = (\n serializedUtf8: Uint8Array,\n id: Uint8Array,\n pubkey: Uint8Array,\n sig: Uint8Array,\n ): boolean => wasmVerifySerialized(exports, serializedUtf8, id, pubkey, sig);\n return {\n verify: (id, pubkey, sig) => runPoisoned(poison, () => wasmVerify(exports, id, pubkey, sig)),\n verifySerialized: (serializedUtf8, id, pubkey, sig) =>\n runPoisoned(poison, () => rawSerialized(serializedUtf8, id, pubkey, sig)),\n verifyEvent: createWasmEventVerifier(rawSerialized, poison),\n sign: (id, seckey, aux) =>\n runPoisoned(poison, () => {\n requireByteLength(id, 32, \"id\");\n requireByteLength(seckey, 32, \"secret key\");\n requireByteLength(aux, 32, \"aux\");\n const sig = wasmSign(exports, id, seckey, aux);\n if (sig.length !== 64) {\n throw new CryptoError(\"wasm sign failed\");\n }\n return sig;\n }),\n publicKey: (seckey) =>\n runPoisoned(poison, () => {\n requireByteLength(seckey, 32, \"secret key\");\n const pk = wasmPublicKey(exports, seckey);\n if (pk.length !== 32) {\n throw new CryptoError(\"wasm publicKey failed\");\n }\n return pk;\n }),\n };\n}\n\n/** Builds a loader that interns a single instance per module slot. */\nexport function createNostrWasmLoader(\n wasmBytes: (opts?: LoadNostrWasmOptions) => Promise<ArrayBuffer | ArrayBufferView>,\n): {\n loadNostrWasm: (opts?: LoadNostrWasmOptions) => Promise<NostrWasm>;\n resetNostrWasm: () => void;\n} {\n let interned: Promise<NostrWasm> | undefined;\n\n async function instantiate(opts?: LoadNostrWasmOptions): Promise<NostrWasm> {\n const bytes = await wasmBytes(opts);\n const exports = await instantiateCryptoWasm(bytes);\n return bindExports(exports);\n }\n\n /** Instantiate once. Repeats reuse the same module. Failure throws; no noble fallback. */\n async function loadNostrWasm(opts?: LoadNostrWasmOptions): Promise<NostrWasm> {\n if (interned) {\n return interned;\n }\n const pending = instantiate(opts);\n interned = pending;\n try {\n return await pending;\n } catch (error) {\n if (interned === pending) {\n interned = undefined;\n }\n throw error;\n }\n }\n\n function resetNostrWasm(): void {\n interned = undefined;\n }\n\n return { loadNostrWasm, resetNostrWasm };\n}\n"],"mappings":";AA2BA,MAAM,WAAW;AAEjB,MAAM,SAAS;AACf,MAAM,aAAa;AACnB,MAAM,UAAU;AAChB,MAAM,aAAa;AAGnB,SAAS,cAAc,OAAgE;CACrF,IAAI,EAAE,iBAAiB,YAAY,SACjC,MAAM,IAAI,UAAU,4BAA4B;CAElD,OAAO;AACT;AAGA,SAAS,UACP,OACA,MACG;CACH,IAAI,OAAO,UAAU,YACnB,MAAM,IAAI,UAAU,gBAAgB,KAAK,QAAQ;CAGnD,OAAO;AACT;AAEA,SAAS,UAAU,KAA6C;CAC9D,OAAO;EACL,QAAQ,cAAc,IAAI,SAAS;EACnC,mBAAmB,UAAU,IAAI,sBAAsB,mBAAmB;EAC1E,YAAY,UAAU,IAAI,eAAe,YAAY;EACrD,cAAc,UAAU,IAAI,iBAAiB,cAAc;EAC3D,cAAc,UAAU,IAAI,iBAAiB,cAAc;EAC3D,yBAAyB,UAAU,IAAI,4BAA4B,yBAAyB;EAC5F,YAAY,UAAU,IAAI,eAAe,YAAY;EACrD,kBAAkB,UAAU,IAAI,qBAAqB,kBAAkB;CACzE;AACF;;;;;;;AAQA,SAAS,QAAQ,SAA4B,OAAkD;CAC7F,MAAM,MAAM,QAAQ,aAAa,KAAK,MAAM;CAC5C,IAAI,QAAQ,GACV,MAAM,IAAI,YAAY,gCAAgC;CAExD,OAAO;EAAE;EAAK,MAAM,IAAI,WAAW,QAAQ,OAAO,QAAQ,KAAK,KAAK;CAAE;AACxE;;AAGA,SAAS,QAAQ,SAA4B,KAAa,KAAyB;CACjF,MAAM,MAAM,IAAI,WAAW,GAAG;CAC9B,IAAI,IAAI,IAAI,WAAW,QAAQ,OAAO,QAAQ,KAAK,GAAG,CAAC;CACvD,OAAO;A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B,kBAAkB,QAAQ,IAAI,YAAY;GAC1C,MAAM,KAAK,cAAc,SAAS,MAAM;GACxC,IAAI,GAAG,WAAW,IAChB,MAAM,IAAI,YAAY,uBAAuB;GAE/C,OAAO;EACT,CAAC;CACL;AACF;;AAGA,SAAgB,sBACd,WAIA;CACA,IAAI;CAEJ,eAAe,YAAY,MAAiD;EAG1E,OAAO,YAAY,MADG,sBAAsB,MADxB,UAAU,IAAI,CACe,CACvB;CAC5B;;CAGA,eAAe,cAAc,MAAiD;EAC5E,IAAI,UACF,OAAO;EAET,MAAM,UAAU,YAAY,IAAI;EAChC,WAAW;EACX,IAAI;GACF,OAAO,MAAM;EACf,SAAS,OAAO;GACd,IAAI,aAAa,SACf,WAAW,KAAA;GAEb,MAAM;EACR;CACF;CAEA,SAAS,iBAAuB;EAC9B,WAAW,KAAA;CACb;CAEA,OAAO;EAAE;EAAe;CAAe;AACzC"}
@@ -0,0 +1,4 @@
1
+ //#region \0wasm-url:/home/runner/work/nostr/nostr/packages/nostr-wasm/src/nostr_wasm.wasm
2
+ var nostr_wasm_default = new URL("nostr_wasm.wasm", import.meta.url).href;
3
+ //#endregion
4
+ export { nostr_wasm_default as default };
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qntx/nostr-wasm",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "description": "WebAssembly-accelerated cryptography backend for @qntx/nostr",
5
5
  "keywords": [
6
6
  "nostr",
@@ -55,16 +55,17 @@
55
55
  "devDependencies": {
56
56
  "@arethetypeswrong/cli": "0.18.5",
57
57
  "@noble/curves": "2.4.0",
58
- "@qntx/nostr": "0.12.0",
58
+ "@qntx/nostr": "0.13.0",
59
+ "@qntx/nostr-native": "0.13.0",
59
60
  "@qntx/tsconfig": "1.0.1",
60
- "@types/node": "26.6.3",
61
+ "@types/node": "26.6.4",
61
62
  "binaryen": "132.0.0",
62
- "publint": "0.3.24",
63
+ "publint": "0.3.25",
63
64
  "typescript": "7.0.2",
64
65
  "vite-plus": "1.0.0"
65
66
  },
66
67
  "peerDependencies": {
67
- "@qntx/nostr": "^0.12.0"
68
+ "@qntx/nostr": "^0.13.0"
68
69
  },
69
70
  "devEngines": {
70
71
  "packageManager": {
@@ -1 +0,0 @@
1
- {"version":3,"file":"instance-CFwzTT0p.mjs","names":[],"sources":["../src/abi.ts","../src/adapter.ts","../src/instance.ts"],"sourcesContent":["import { CryptoError } from \"@qntx/nostr/core\";\n\n/**\n * Byte-ABI version 1 surface exported by `nk_wasm.wasm` (`crates/nk-wasm/src/abi.rs`). All inputs\n * are caller-written regions of a single scratch buffer; status codes are 0 ok/verified, 1\n * verification failed, 2 invalid input.\n */\nexport type CryptoWasmExports = {\n memory: WebAssembly.Memory;\n nk_abi_version: () => number;\n nk_buffer: (len: number) => number;\n nk_verify: (id: number, pubkey: number, sig: number) => number;\n nk_verify_serialized: (\n ser: number,\n serLen: number,\n id: number,\n pubkey: number,\n sig: number,\n ) => number;\n nk_sign: (id: number, seckey: number, aux: number, outSig: number) => number;\n nk_public_key: (seckey: number, outPubkey: number) => number;\n};\n\nexport const NK_ABI_VERSION = 1;\n\nconst ID_LEN = 32;\nconst PUBKEY_LEN = 32;\nconst SIG_LEN = 64;\nconst SECKEY_LEN = 32;\nconst AUX_LEN = 32;\n\nfunction requireMemory(value: WebAssembly.ExportValue | undefined): WebAssembly.Memory {\n if (!(value instanceof WebAssembly.Memory)) {\n throw new TypeError(\"wasm missing memory export\");\n }\n return value;\n}\n\n// oxlint-disable-next-line no-unnecessary-type-parameters -- T binds the declared ABI signature at each call site\nfunction requireFn<T extends (...args: number[]) => unknown>(\n value: WebAssembly.ExportValue | undefined,\n name: string,\n): T {\n if (typeof value !== \"function\") {\n throw new TypeError(`wasm missing ${name} export`);\n }\n // oxlint-disable-next-line no-unsafe-type-assertion -- wasm exports are opaque; each name is bound to the signature the ABI contract requires\n return value as T;\n}\n\nfunction asExports(raw: WebAssembly.Exports): CryptoWasmExports {\n return {\n memory: requireMemory(raw[\"memory\"]),\n nk_abi_version: requireFn(raw[\"nk_abi_version\"], \"nk_abi_version\"),\n nk_buffer: requireFn(raw[\"nk_buffer\"], \"nk_buffer\"),\n nk_verify: requireFn(raw[\"nk_verify\"], \"nk_verify\"),\n nk_verify_serialized: requireFn(raw[\"nk_verify_serialized\"], \"nk_verify_serialized\"),\n nk_sign: requireFn(raw[\"nk_sign\"], \"nk_sign\"),\n nk_public_key: requireFn(raw[\"nk_public_key\"], \"nk_public_key\"),\n };\n}\n\n/**\n * Reserve `total` bytes in the wasm scratch region and return a fresh view. The view is taken after\n * `nk_buffer` ran, so a growth inside it cannot leave a detached view in the caller's hands.\n */\nfunction scratch(exports: CryptoWasmExports, total: number): { ptr: number; view: Uint8Array } {\n const ptr = exports.nk_buffer(total) >>> 0;\n return { ptr, view: new Uint8Array(exports.memory.buffer, ptr, total) };\n}\n\n/** Copies `len` scratch bytes out; the view is re-acquired after the call. */\nfunction takeOut(exports: CryptoWasmExports, ptr: number, len: number): Uint8Array {\n const out = new Uint8Array(len);\n out.set(new Uint8Array(exports.memory.buffer, ptr, len));\n return out;\n}\n\nexport function wasmVerify(\n exports: CryptoWasmExports,\n id: Uint8Array,\n pubkey: Uint8Array,\n sig: Uint8Array,\n): boolean {\n if (id.length !== ID_LEN || pubkey.length !== PUBKEY_LEN || sig.length !== SIG_LEN) {\n return false; // fixed-size ABI: a wrong-length input simply cannot verify\n }\n const { ptr, view } = scratch(exports, ID_LEN + PUBKEY_LEN + SIG_LEN);\n view.set(id, 0);\n view.set(pubkey, ID_LEN);\n view.set(sig, ID_LEN + PUBKEY_LEN);\n return exports.nk_verify(ptr, ptr + ID_LEN, ptr + ID_LEN + PUBKEY_LEN) === 0;\n}\n\nexport function wasmVerifySerialized(\n exports: CryptoWasmExports,\n serialized: Uint8Array,\n id: Uint8Array,\n pubkey: Uint8Array,\n sig: Uint8Array,\n): boolean {\n if (id.length !== ID_LEN || pubkey.length !== PUBKEY_LEN || sig.length !== SIG_LEN) {\n return false;\n }\n const serLen = serialized.length;\n const { ptr, view } = scratch(exports, serLen + ID_LEN + PUBKEY_LEN + SIG_LEN);\n view.set(serialized, 0);\n view.set(id, serLen);\n view.set(pubkey, serLen + ID_LEN);\n view.set(sig, serLen + ID_LEN + PUBKEY_LEN);\n return (\n exports.nk_verify_serialized(\n ptr,\n serLen,\n ptr + serLen,\n ptr + serLen + ID_LEN,\n ptr + serLen + ID_LEN + PUBKEY_LEN,\n ) === 0\n );\n}\n\n/**\n * Returns the 64-byte signature, or an empty array on failure (invalid input). The Rust side zeroes\n * the scratch copy of `seckey` before returning.\n */\nexport function wasmSign(\n exports: CryptoWasmExports,\n id: Uint8Array,\n seckey: Uint8Array,\n aux: Uint8Array,\n): Uint8Array {\n const outOffset = ID_LEN + SECKEY_LEN + AUX_LEN;\n const { ptr, view } = scratch(exports, outOffset + SIG_LEN);\n view.set(id, 0);\n view.set(seckey, ID_LEN);\n view.set(aux, ID_LEN + SECKEY_LEN);\n const status = exports.nk_sign(ptr, ptr + ID_LEN, ptr + ID_LEN + SECKEY_LEN, ptr + outOffset);\n if (status !== 0) {\n return new Uint8Array(0);\n }\n return takeOut(exports, ptr + outOffset, SIG_LEN);\n}\n\n/**\n * Returns the 32-byte x-only public key, or an empty array on failure. The Rust side zeroes the\n * scratch copy of `seckey` before returning.\n */\nexport function wasmPublicKey(exports: CryptoWasmExports, seckey: Uint8Array): Uint8Array {\n const { ptr, view } = scratch(exports, SECKEY_LEN + PUBKEY_LEN);\n view.set(seckey, 0);\n const status = exports.nk_public_key(ptr, ptr + SECKEY_LEN);\n if (status !== 0) {\n return new Uint8Array(0);\n }\n return takeOut(exports, ptr + SECKEY_LEN, PUBKEY_LEN);\n}\n\n/**\n * Compile and instantiate `nk_wasm.wasm`. The module must declare no imports and must implement ABI\n * version {@link NK_ABI_VERSION} — a mismatch means the artifact predates or postdates this loader\n * and instantiation fails.\n */\nexport async function instantiateCryptoWasm(\n bytes: ArrayBuffer | ArrayBufferView,\n): Promise<CryptoWasmExports> {\n const module = await WebAssembly.compile(bytes);\n const imports = WebAssembly.Module.imports(module);\n if (imports.length > 0) {\n throw new TypeError(`nk_wasm module must not import anything, got ${imports.length} imports`);\n }\n const instance = await WebAssembly.instantiate(module, {});\n const version = requireFn(instance.exports[\"nk_abi_version\"], \"nk_abi_version\")();\n if (version !== NK_ABI_VERSION) {\n throw new CryptoError(\n `unsupported nk_wasm ABI version ${String(version)}, expected ${NK_ABI_VERSION}`,\n );\n }\n return asExports(instance.exports);\n}\n","import { WasmPoisonedError, createEventVerifier } from \"@qntx/nostr/core\";\nimport type { EventVerifier, SerializedEventVerifier } from \"@qntx/nostr/core\";\n\nexport { WasmPoisonedError } from \"@qntx/nostr/core\";\n\n/**\n * Run `fn` unless the instance is already poisoned; a `WebAssembly.RuntimeError` aborts the\n * instance, so it is converted to {@link WasmPoisonedError} and rethrown on every later call.\n */\nexport function runPoisoned<T>(poison: { error?: Error }, fn: () => T): T {\n if (poison.error !== undefined) {\n throw poison.error;\n }\n try {\n return fn();\n } catch (error) {\n if (error instanceof WebAssembly.RuntimeError) {\n poison.error = new WasmPoisonedError(\"wasm instance aborted\", {\n cause: error,\n });\n throw poison.error;\n }\n throw error;\n }\n}\n\n/**\n * Build the WASM event verifier on {@link createEventVerifier}. A `WebAssembly.RuntimeError` from\n * the module means the instance aborted — it poisons every later call with the same\n * `WasmPoisonedError`; any other backend error verifies `false` (the event is marked failed).\n */\nexport function createWasmEventVerifier(\n verifySerialized: SerializedEventVerifier,\n poison: { error?: Error },\n): EventVerifier {\n const backend: SerializedEventVerifier = (serializedUtf8, id, pubkey, sig) => {\n try {\n return runPoisoned(poison, () => verifySerialized(serializedUtf8, id, pubkey, sig));\n } catch (error) {\n if (error instanceof WasmPoisonedError) {\n throw error;\n }\n return false;\n }\n };\n return createEventVerifier(backend);\n}\n","import { CryptoError } from \"@qntx/nostr/core\";\nimport type { SigningBackend, EventVerifier } from \"@qntx/nostr/core\";\n\nimport {\n instantiateCryptoWasm,\n wasmPublicKey,\n wasmSign,\n wasmVerify,\n wasmVerifySerialized,\n} from \"./abi.ts\";\nimport type { CryptoWasmExports } from \"./abi.ts\";\nimport { createWasmEventVerifier, runPoisoned } from \"./adapter.ts\";\n\nexport type LoadNostrWasmOptions = {\n /** Bytes, or a URL whose bytes will be read by the platform loader. */\n module?: ArrayBuffer | ArrayBufferView | URL | undefined;\n};\n\nexport type NostrWasm = SigningBackend & {\n verify: (id: Uint8Array, pubkey: Uint8Array, sig: Uint8Array) => boolean;\n verifySerialized: (\n serializedUtf8: Uint8Array,\n id: Uint8Array,\n pubkey: Uint8Array,\n sig: Uint8Array,\n ) => boolean;\n verifyEvent: EventVerifier;\n};\n\nexport function isWasmBytes(value: unknown): value is ArrayBuffer | ArrayBufferView {\n return value instanceof ArrayBuffer || ArrayBuffer.isView(value);\n}\n\nexport async function fetchWasmUrl(url: URL): Promise<Uint8Array> {\n const res = await fetch(url);\n if (!res.ok) {\n throw new CryptoError(`failed to fetch wasm: ${res.status} ${url.href}`);\n }\n return new Uint8Array(await res.arrayBuffer());\n}\n\nfunction requireByteLength(bytes: Uint8Array, expected: number, label: string): void {\n if (bytes.length !== expected) {\n throw new CryptoError(`invalid ${label} length: expected ${expected}, got ${bytes.length}`);\n }\n}\n\nfunction bindExports(exports: CryptoWasmExports): NostrWasm {\n const poison: { error?: Error } = {};\n const rawSerialized = (\n serializedUtf8: Uint8Array,\n id: Uint8Array,\n pubkey: Uint8Array,\n sig: Uint8Array,\n ): boolean => wasmVerifySerialized(exports, serializedUtf8, id, pubkey, sig);\n return {\n verify: (id, pubkey, sig) => runPoisoned(poison, () => wasmVerify(exports, id, pubkey, sig)),\n verifySerialized: (serializedUtf8, id, pubkey, sig) =>\n runPoisoned(poison, () => rawSerialized(serializedUtf8, id, pubkey, sig)),\n verifyEvent: createWasmEventVerifier(rawSerialized, poison),\n sign: (id, seckey, aux) =>\n runPoisoned(poison, () => {\n requireByteLength(id, 32, \"id\");\n requireByteLength(seckey, 32, \"secret key\");\n requireByteLength(aux, 32, \"aux\");\n const sig = wasmSign(exports, id, seckey, aux);\n if (sig.length !== 64) {\n throw new CryptoError(\"wasm sign failed\");\n }\n return sig;\n }),\n publicKey: (seckey) =>\n runPoisoned(poison, () => {\n requireByteLength(seckey, 32, \"secret key\");\n const pk = wasmPublicKey(exports, seckey);\n if (pk.length !== 32) {\n throw new CryptoError(\"wasm publicKey failed\");\n }\n return pk;\n }),\n };\n}\n\n/** Builds a loader that interns a single instance per module slot. */\nexport function createNostrWasmLoader(\n wasmBytes: (opts?: LoadNostrWasmOptions) => Promise<ArrayBuffer | ArrayBufferView>,\n): {\n loadNostrWasm: (opts?: LoadNostrWasmOptions) => Promise<NostrWasm>;\n resetNostrWasm: () => void;\n} {\n let interned: Promise<NostrWasm> | undefined;\n\n async function instantiate(opts?: LoadNostrWasmOptions): Promise<NostrWasm> {\n const bytes = await wasmBytes(opts);\n const exports = await instantiateCryptoWasm(bytes);\n return bindExports(exports);\n }\n\n /** Instantiate once. Repeats reuse the same module. Failure throws; no noble fallback. */\n async function loadNostrWasm(opts?: LoadNostrWasmOptions): Promise<NostrWasm> {\n if (interned) {\n return interned;\n }\n const pending = instantiate(opts);\n interned = pending;\n try {\n return await pending;\n } catch (error) {\n if (interned === pending) {\n interned = undefined;\n }\n throw error;\n }\n }\n\n function resetNostrWasm(): void {\n interned = undefined;\n }\n\n return { loadNostrWasm, resetNostrWasm };\n}\n"],"mappings":";AAyBA,MAAM,SAAS;AACf,MAAM,aAAa;AACnB,MAAM,UAAU;AAChB,MAAM,aAAa;AAGnB,SAAS,cAAc,OAAgE;CACrF,IAAI,EAAE,iBAAiB,YAAY,SACjC,MAAM,IAAI,UAAU,4BAA4B;CAElD,OAAO;AACT;AAGA,SAAS,UACP,OACA,MACG;CACH,IAAI,OAAO,UAAU,YACnB,MAAM,IAAI,UAAU,gBAAgB,KAAK,QAAQ;CAGnD,OAAO;AACT;AAEA,SAAS,UAAU,KAA6C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c,cAAc,gBAAgB,IAAI,QAAQ,GAAG,CAAC;EAC1E,aAAa,wBAAwB,eAAe,MAAM;EAC1D,OAAO,IAAI,QAAQ,QACjB,YAAY,cAAc;GACxB,kBAAkB,IAAI,IAAI,IAAI;GAC9B,kBAAkB,QAAQ,IAAI,YAAY;GAC1C,kBAAkB,KAAK,IAAI,KAAK;GAChC,MAAM,MAAM,SAAS,SAAS,IAAI,QAAQ,GAAG;GAC7C,IAAI,IAAI,WAAW,IACjB,MAAM,IAAI,YAAY,kBAAkB;GAE1C,OAAO;EACT,CAAC;EACH,YAAY,WACV,YAAY,cAAc;GACxB,kBAAkB,QAAQ,IAAI,YAAY;GAC1C,MAAM,KAAK,cAAc,SAAS,MAAM;GACxC,IAAI,GAAG,WAAW,IAChB,MAAM,IAAI,YAAY,uBAAuB;GAE/C,OAAO;EACT,CAAC;CACL;AACF;;AAGA,SAAgB,sBACd,WAIA;CACA,IAAI;CAEJ,eAAe,YAAY,MAAiD;EAG1E,OAAO,YAAY,MADG,sBAAsB,MADxB,UAAU,IAAI,CACe,CACvB;CAC5B;;CAGA,eAAe,cAAc,MAAiD;EAC5E,IAAI,UACF,OAAO;EAET,MAAM,UAAU,YAAY,IAAI;EAChC,WAAW;EACX,IAAI;GACF,OAAO,MAAM;EACf,SAAS,OAAO;GACd,IAAI,aAAa,SACf,WAAW,KAAA;GAEb,MAAM;EACR;CACF;CAEA,SAAS,iBAAuB;EAC9B,WAAW,KAAA;CACb;CAEA,OAAO;EAAE;EAAe;CAAe;AACzC"}
@@ -1,4 +0,0 @@
1
- //#region \0wasm-url:/home/runner/work/nostr/nostr/packages/nostr-wasm/src/nk_wasm.wasm
2
- var nk_wasm_default = new URL("nk_wasm.wasm", import.meta.url).href;
3
- //#endregion
4
- export { nk_wasm_default as default };
package/dist/nk_wasm.wasm DELETED
Binary file