@needmoretruth/nmts-cli 0.46.0 → 0.47.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.
Files changed (66) hide show
  1. package/AGENTS.md +8 -8
  2. package/CHANGELOG.md +18 -1
  3. package/README.ko.md +1 -1
  4. package/README.md +19 -11
  5. package/dist/arg-options.d.ts +11 -1
  6. package/dist/args.js +7 -1
  7. package/dist/artifact-about.d.ts +1 -1
  8. package/dist/autonomy.js +3 -3
  9. package/dist/commands/handover.d.ts +2 -0
  10. package/dist/commands/handover.js +65 -17
  11. package/dist/commands/link.d.ts +12 -0
  12. package/dist/commands/link.js +121 -0
  13. package/dist/commands/public-code-manage.d.ts +24 -0
  14. package/dist/commands/public-code-manage.js +217 -0
  15. package/dist/commands/public-code.d.ts +7 -2
  16. package/dist/commands/public-code.js +104 -55
  17. package/dist/commands/receive.js +11 -5
  18. package/dist/commands/share-dispatch.js +14 -1
  19. package/dist/commands/share.d.ts +2 -0
  20. package/dist/commands/share.js +45 -35
  21. package/dist/commands/shares-sent.js +8 -3
  22. package/dist/crypto-surface.d.ts +27 -0
  23. package/dist/crypto-surface.js +10 -0
  24. package/dist/crypto.d.ts +5 -0
  25. package/dist/crypto.js +5 -0
  26. package/dist/handover-codes.d.ts +25 -0
  27. package/dist/handover-codes.js +106 -0
  28. package/dist/handover.d.ts +21 -3
  29. package/dist/handover.js +47 -29
  30. package/dist/help-options.js +9 -2
  31. package/dist/help.js +9 -1
  32. package/dist/links.d.ts +58 -0
  33. package/dist/links.js +206 -0
  34. package/dist/main.js +3 -2
  35. package/dist/mcp-tools/reads.js +20 -6
  36. package/dist/mcp-tools/share.js +47 -1
  37. package/dist/mcp-tools/tiers.js +16 -1
  38. package/dist/portable.d.ts +8 -0
  39. package/dist/portable.js +8 -0
  40. package/dist/product.d.ts +1 -1
  41. package/dist/product.js +1 -1
  42. package/dist/public-code-activity.d.ts +35 -0
  43. package/dist/public-code-activity.js +88 -0
  44. package/dist/public-code-refusals.d.ts +25 -0
  45. package/dist/public-code-refusals.js +87 -0
  46. package/dist/public-codes.d.ts +76 -0
  47. package/dist/public-codes.js +182 -0
  48. package/dist/risk.d.ts +25 -1
  49. package/dist/risk.js +32 -1
  50. package/dist/share-codes.d.ts +40 -0
  51. package/dist/share-codes.js +151 -0
  52. package/dist/share.d.ts +34 -0
  53. package/dist/share.js +53 -12
  54. package/dist/shared/lib/share/public-link.d.ts +41 -0
  55. package/dist/shared/lib/share/public-link.js +107 -0
  56. package/docs/commands/handover.md +17 -1
  57. package/docs/commands/link.md +27 -0
  58. package/docs/commands/mcp.md +2 -1
  59. package/docs/commands/public-code.md +21 -9
  60. package/docs/commands/share.md +6 -3
  61. package/package.json +1 -1
  62. package/server.json +2 -2
  63. package/vendor/nmts-crypto/nmts_crypto_wasm.d.ts +91 -5
  64. package/vendor/nmts-crypto/nmts_crypto_wasm.js +259 -4
  65. package/vendor/nmts-crypto/nmts_crypto_wasm_bg.wasm +0 -0
  66. package/vendor/nmts-crypto/nmts_crypto_wasm_bg.wasm.d.ts +11 -1
package/server.json CHANGED
@@ -6,13 +6,13 @@
6
6
  "url": "https://github.com/needmoretruth/nmts-cli",
7
7
  "source": "github"
8
8
  },
9
- "version": "0.46.0",
9
+ "version": "0.47.0",
10
10
  "packages": [
11
11
  {
12
12
  "registryType": "npm",
13
13
  "registryBaseUrl": "https://registry.npmjs.org",
14
14
  "identifier": "@needmoretruth/nmts-cli",
15
- "version": "0.46.0",
15
+ "version": "0.47.0",
16
16
  "transport": {
17
17
  "type": "stdio"
18
18
  },
@@ -207,7 +207,7 @@ export function envelope_seal(key: Uint8Array, aad: Uint8Array, plaintext: Uint8
207
207
  *
208
208
  * ⚠ The ADDRESS is deliberately not exported. Computing it needs the curve's point arithmetic,
209
209
  * which added 63 KB to a package every visitor downloads (measured 2026-09-24: 539,169 → 602,131
210
- * bytes; the key alone is 545,338) for a value no browser screen shows. The command-line tool and
210
+ * bytes; the key alone is 545,370) for a value no browser screen shows. The command-line tool and
211
211
  * the recovery tool compute the address themselves.
212
212
  */
213
213
  export function evm_key_for(wallet_root: Uint8Array, index: number): Uint8Array;
@@ -246,7 +246,7 @@ export function header_plaintext_len(header: Uint8Array): number;
246
246
  /**
247
247
  * Derives the account keys from the 20 raw account-code bytes (NCF-3 §1).
248
248
  *
249
- * Returns one concatenated buffer (`KDF_DERIVE_LEN` = 288 bytes) the caller slices:
249
+ * Returns one concatenated buffer (`KDF_DERIVE_LEN` = 320 bytes) the caller slices:
250
250
  * ```text
251
251
  * 0.. 16 account_id public — the server's lookup key
252
252
  * 16.. 48 auth_secret secret — sent to the server over TLS at login
@@ -258,12 +258,13 @@ export function header_plaintext_len(header: Uint8Array): number;
258
258
  * 208..224 share_address public — the address a user hands out to be shared with
259
259
  * 224..256 share_sig_seed secret — ML-DSA-44 seed; its key IS the identity root (§5.2a)
260
260
  * 256..288 ai_account_root secret — parent of every AI-account code (§1.5, the product rule of 2026-09-06)
261
+ * 288..320 share_id_root secret — parent of share identities 1 and up (§5.9, 2026-09-23)
261
262
  * ```
262
263
  * Every secret region above must be retained inside the crypto worker and never cross the
263
264
  * postMessage boundary.
264
265
  *
265
- * ⚠ **This layout only ever grows at the TAIL**, and `ai_account_root` was appended on 2026-09-06
266
- * under the same rule. `share_sig_seed` was appended in 2026-08-02
266
+ * ⚠ **This layout only ever grows at the TAIL**: `ai_account_root` was appended on 2026-09-06 and
267
+ * `share_id_root` on 2026-09-23 under that rule. `share_sig_seed` was appended in 2026-08-02
267
268
  * rather than filed beside the other two share secrets, where it would read better, because
268
269
  * inserting it there would shift `wallet_root` and `share_address` and every constant on the
269
270
  * JS side would be silently wrong about which 32 bytes it was holding. Readability loses to
@@ -275,6 +276,33 @@ export function header_plaintext_len(header: Uint8Array): number;
275
276
  */
276
277
  export function kdf_derive(code_bytes: Uint8Array): Uint8Array;
277
278
 
279
+ /**
280
+ * A fresh 32-byte link secret `S`, drawn inside Rust from WebCrypto. One per link.
281
+ */
282
+ export function link_generate_secret(): Uint8Array;
283
+
284
+ /**
285
+ * Opens a link secret sealed by `link_seal_secret`, returning the 32-byte `S`.
286
+ */
287
+ export function link_open_secret(data_key: Uint8Array, sealed: Uint8Array): Uint8Array;
288
+
289
+ /**
290
+ * Seals a link secret under the uploader's dataKey: `E(dataKey, "nmts/v3/link-secret", S)`,
291
+ * 104 bytes. Stored beside the link so the uploader can copy the same link again later.
292
+ */
293
+ export function link_seal_secret(data_key: Uint8Array, link_secret: Uint8Array): Uint8Array;
294
+
295
+ /**
296
+ * Opens a link's wrapped DEK with the secret from the fragment, returning the 32-byte DEK.
297
+ */
298
+ export function link_unwrap_dek(link_secret: Uint8Array, wrapped: Uint8Array): Uint8Array;
299
+
300
+ /**
301
+ * Wraps a file DEK under a link secret: `E(S, "nmts/v3/link-wrap", DEK)`, 104 bytes. The server
302
+ * stores the result beside the link's token.
303
+ */
304
+ export function link_wrap_dek(link_secret: Uint8Array, dek: Uint8Array): Uint8Array;
305
+
278
306
  /**
279
307
  * The 16-byte LOCATOR a wallet signature yields — the name the server files this opener's slot
280
308
  * under, and the name a sign-in asks for it back by (NCF-3 §1.7).
@@ -367,6 +395,12 @@ export function recovery_patch_name(data_key: Uint8Array): string;
367
395
  */
368
396
  export function sha256(data: Uint8Array): Uint8Array;
369
397
 
398
+ /**
399
+ * The 16-byte share ADDRESS of identity number `index`, from its signing seed alone — no
400
+ * signature is made to answer it. At index 0 it is `kdf_derive`'s `share_address` (208..224).
401
+ */
402
+ export function share_address_at(share_sig_seed: Uint8Array, index: number): Uint8Array;
403
+
370
404
  /**
371
405
  * The display form of a share address (`kdf_derive` bytes 208..224):
372
406
  * `XXXXXXXXX-XXXXXXXXX-XXXXXXXXC` — Crockford Base32 with a trailing check symbol.
@@ -402,6 +436,19 @@ export function share_address_parse(input: string): Uint8Array;
402
436
  */
403
437
  export function share_claimed_sender(envelope: Uint8Array): Uint8Array;
404
438
 
439
+ /**
440
+ * The three secret seeds of share identity number `index` (1-based) from the 32-byte
441
+ * `share_id_root` at `kdf_derive` bytes 288..320: `kem(32) || auth(32) || sig(32)`, 96 bytes.
442
+ *
443
+ * ⛔ It takes the ROOT rather than the account code for the reason `wallet_seed_for` does: the
444
+ * browser derives once at sign-in and keeps only the roots, and a person makes a new public code
445
+ * whenever they like. Holding the root grants identities 1 and up and nothing else.
446
+ *
447
+ * Rejects `index` 0. All 96 bytes are secret and stay inside the crypto worker, like the
448
+ * `kdf_derive` regions they sit beside.
449
+ */
450
+ export function share_id_seeds(share_id_root: Uint8Array, index: number): Uint8Array;
451
+
405
452
  /**
406
453
  * The 4989-byte PUBLIC share identity, built from the three secrets at `kdf_derive` bytes
407
454
  * 112..176 and 224..256 (KEM seed, auth secret, signing seed).
@@ -417,6 +464,15 @@ export function share_claimed_sender(envelope: Uint8Array): Uint8Array;
417
464
  */
418
465
  export function share_public_key(share_kem_seed: Uint8Array, share_auth_secret: Uint8Array, share_sig_seed: Uint8Array): Uint8Array;
419
466
 
467
+ /**
468
+ * The 4989-byte PUBLIC share identity number `index`: the bundle `share_public_key` builds, with
469
+ * `derivation_index = index`. At index 0 it is `share_public_key`, byte for byte.
470
+ *
471
+ * The number is inside the root, so each number has its own address; the self-signature covers
472
+ * it, so a numbered bundle is verified by exactly the steps any bundle is.
473
+ */
474
+ export function share_public_key_at(share_kem_seed: Uint8Array, share_auth_secret: Uint8Array, share_sig_seed: Uint8Array, index: number): Uint8Array;
475
+
420
476
  /**
421
477
  * Unwraps a share envelope addressed to us, returning the 32-byte file DEK.
422
478
  *
@@ -427,6 +483,15 @@ export function share_public_key(share_kem_seed: Uint8Array, share_auth_secret:
427
483
  */
428
484
  export function share_unwrap_dek(share_kem_seed: Uint8Array, share_auth_secret: Uint8Array, share_sig_seed: Uint8Array, sender_public: Uint8Array, envelope: Uint8Array, item_id: string, name_share_ct: Uint8Array, content_hash_share_ct: Uint8Array): Uint8Array;
429
485
 
486
+ /**
487
+ * `share_unwrap_dek` as identity number `index`, returning the 32-byte file DEK.
488
+ *
489
+ * An envelope does not name its recipient, so the caller picks the number — the inbox knows
490
+ * which address a share was stored against. Opened as the wrong number it fails with the same
491
+ * message as an envelope meant for somebody else, a forged sender or a rewritten row.
492
+ */
493
+ export function share_unwrap_dek_as(share_kem_seed: Uint8Array, share_auth_secret: Uint8Array, share_sig_seed: Uint8Array, index: number, sender_public: Uint8Array, envelope: Uint8Array, item_id: string, name_share_ct: Uint8Array, content_hash_share_ct: Uint8Array): Uint8Array;
494
+
430
495
  /**
431
496
  * Wraps a file DEK for ONE recipient, given the public key the server returned AND the address
432
497
  * the sender was actually given.
@@ -449,6 +514,17 @@ export function share_unwrap_dek(share_kem_seed: Uint8Array, share_auth_secret:
449
514
  */
450
515
  export function share_wrap_dek(sender_auth_secret: Uint8Array, sender_sig_seed: Uint8Array, recipient_public: Uint8Array, recipient_address: Uint8Array, dek: Uint8Array, item_id: string, name_share_ct: Uint8Array, content_hash_share_ct: Uint8Array): Uint8Array;
451
516
 
517
+ /**
518
+ * `share_wrap_dek` sending AS identity number `sender_index`: the two sender secrets are that
519
+ * identity's, and the envelope's sender address is that identity's address.
520
+ *
521
+ * Every other argument and every check is `share_wrap_dek`'s — the recipient key is checked
522
+ * against `recipient_address` before anything is encrypted to it, the last three arguments are
523
+ * the row the envelope is bound to, and fresh randomness is drawn per call. Returns the 1240-byte
524
+ * share envelope.
525
+ */
526
+ export function share_wrap_dek_as(sender_auth_secret: Uint8Array, sender_sig_seed: Uint8Array, sender_index: number, recipient_public: Uint8Array, recipient_address: Uint8Array, dek: Uint8Array, item_id: string, name_share_ct: Uint8Array, content_hash_share_ct: Uint8Array): Uint8Array;
527
+
452
528
  /**
453
529
  * Decrypts a whole NCF-3 stream under the file DEK, verifying framing/anti-tamper.
454
530
  */
@@ -548,6 +624,11 @@ export interface InitOutput {
548
624
  readonly streamencryptor_push: (a: number, b: number, c: number) => [number, number, number, number];
549
625
  readonly streamencryptor_resumeFromHeader: (a: number, b: number, c: number, d: number) => [number, number, number];
550
626
  readonly verify_part_set: (a: number, b: number) => [number, number];
627
+ readonly share_address_at: (a: number, b: number, c: number) => [number, number, number, number];
628
+ readonly share_id_seeds: (a: number, b: number, c: number) => [number, number, number, number];
629
+ readonly share_public_key_at: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number, number];
630
+ readonly share_unwrap_dek_as: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number, p: number, q: number) => [number, number, number, number];
631
+ readonly share_wrap_dek_as: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number, p: number, q: number) => [number, number, number, number];
551
632
  readonly opener_locator: (a: number, b: number) => [number, number, number, number];
552
633
  readonly opener_message: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
553
634
  readonly opener_open: (a: number, b: number, c: number, d: number) => [number, number, number, number];
@@ -556,12 +637,17 @@ export interface InitOutput {
556
637
  readonly passkey_open: (a: number, b: number, c: number, d: number) => [number, number, number, number];
557
638
  readonly passkey_prf_salt: () => [number, number];
558
639
  readonly passkey_seal: (a: number, b: number, c: number, d: number) => [number, number, number, number];
640
+ readonly link_generate_secret: () => [number, number];
641
+ readonly link_open_secret: (a: number, b: number, c: number, d: number) => [number, number, number, number];
642
+ readonly link_seal_secret: (a: number, b: number, c: number, d: number) => [number, number, number, number];
643
+ readonly link_unwrap_dek: (a: number, b: number, c: number, d: number) => [number, number, number, number];
644
+ readonly link_wrap_dek: (a: number, b: number, c: number, d: number) => [number, number, number, number];
559
645
  readonly account_code_display: (a: number, b: number) => [number, number, number, number];
560
646
  readonly account_code_generate: () => [number, number];
561
647
  readonly account_code_parse: (a: number, b: number) => [number, number, number, number];
562
648
  readonly account_code_phrase: (a: number, b: number, c: number, d: number) => [number, number, number, number];
563
- readonly evm_key_for: (a: number, b: number, c: number) => [number, number, number, number];
564
649
  readonly voucher_hash_from_input: (a: number, b: number) => [number, number];
650
+ readonly evm_key_for: (a: number, b: number, c: number) => [number, number, number, number];
565
651
  readonly wallet_seed_for: (a: number, b: number, c: number) => [number, number, number, number];
566
652
  readonly __wbindgen_exn_store: (a: number) => void;
567
653
  readonly __externref_table_alloc: () => number;
@@ -507,7 +507,7 @@ export function envelope_seal(key, aad, plaintext) {
507
507
  *
508
508
  * ⚠ The ADDRESS is deliberately not exported. Computing it needs the curve's point arithmetic,
509
509
  * which added 63 KB to a package every visitor downloads (measured 2026-09-24: 539,169 → 602,131
510
- * bytes; the key alone is 545,338) for a value no browser screen shows. The command-line tool and
510
+ * bytes; the key alone is 545,370) for a value no browser screen shows. The command-line tool and
511
511
  * the recovery tool compute the address themselves.
512
512
  * @param {Uint8Array} wallet_root
513
513
  * @param {number} index
@@ -617,7 +617,7 @@ export function header_plaintext_len(header) {
617
617
  /**
618
618
  * Derives the account keys from the 20 raw account-code bytes (NCF-3 §1).
619
619
  *
620
- * Returns one concatenated buffer (`KDF_DERIVE_LEN` = 288 bytes) the caller slices:
620
+ * Returns one concatenated buffer (`KDF_DERIVE_LEN` = 320 bytes) the caller slices:
621
621
  * ```text
622
622
  * 0.. 16 account_id public — the server's lookup key
623
623
  * 16.. 48 auth_secret secret — sent to the server over TLS at login
@@ -629,12 +629,13 @@ export function header_plaintext_len(header) {
629
629
  * 208..224 share_address public — the address a user hands out to be shared with
630
630
  * 224..256 share_sig_seed secret — ML-DSA-44 seed; its key IS the identity root (§5.2a)
631
631
  * 256..288 ai_account_root secret — parent of every AI-account code (§1.5, the product rule of 2026-09-06)
632
+ * 288..320 share_id_root secret — parent of share identities 1 and up (§5.9, 2026-09-23)
632
633
  * ```
633
634
  * Every secret region above must be retained inside the crypto worker and never cross the
634
635
  * postMessage boundary.
635
636
  *
636
- * ⚠ **This layout only ever grows at the TAIL**, and `ai_account_root` was appended on 2026-09-06
637
- * under the same rule. `share_sig_seed` was appended in 2026-08-02
637
+ * ⚠ **This layout only ever grows at the TAIL**: `ai_account_root` was appended on 2026-09-06 and
638
+ * `share_id_root` on 2026-09-23 under that rule. `share_sig_seed` was appended in 2026-08-02
638
639
  * rather than filed beside the other two share secrets, where it would read better, because
639
640
  * inserting it there would shift `wallet_root` and `share_address` and every constant on the
640
641
  * JS side would be silently wrong about which 32 bytes it was holding. Readability loses to
@@ -658,6 +659,99 @@ export function kdf_derive(code_bytes) {
658
659
  return v2;
659
660
  }
660
661
 
662
+ /**
663
+ * A fresh 32-byte link secret `S`, drawn inside Rust from WebCrypto. One per link.
664
+ * @returns {Uint8Array}
665
+ */
666
+ export function link_generate_secret() {
667
+ const ret = wasm.link_generate_secret();
668
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
669
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
670
+ return v1;
671
+ }
672
+
673
+ /**
674
+ * Opens a link secret sealed by `link_seal_secret`, returning the 32-byte `S`.
675
+ * @param {Uint8Array} data_key
676
+ * @param {Uint8Array} sealed
677
+ * @returns {Uint8Array}
678
+ */
679
+ export function link_open_secret(data_key, sealed) {
680
+ const ptr0 = passArray8ToWasm0(data_key, wasm.__wbindgen_malloc);
681
+ const len0 = WASM_VECTOR_LEN;
682
+ const ptr1 = passArray8ToWasm0(sealed, wasm.__wbindgen_malloc);
683
+ const len1 = WASM_VECTOR_LEN;
684
+ const ret = wasm.link_open_secret(ptr0, len0, ptr1, len1);
685
+ if (ret[3]) {
686
+ throw takeFromExternrefTable0(ret[2]);
687
+ }
688
+ var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
689
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
690
+ return v3;
691
+ }
692
+
693
+ /**
694
+ * Seals a link secret under the uploader's dataKey: `E(dataKey, "nmts/v3/link-secret", S)`,
695
+ * 104 bytes. Stored beside the link so the uploader can copy the same link again later.
696
+ * @param {Uint8Array} data_key
697
+ * @param {Uint8Array} link_secret
698
+ * @returns {Uint8Array}
699
+ */
700
+ export function link_seal_secret(data_key, link_secret) {
701
+ const ptr0 = passArray8ToWasm0(data_key, wasm.__wbindgen_malloc);
702
+ const len0 = WASM_VECTOR_LEN;
703
+ const ptr1 = passArray8ToWasm0(link_secret, wasm.__wbindgen_malloc);
704
+ const len1 = WASM_VECTOR_LEN;
705
+ const ret = wasm.link_seal_secret(ptr0, len0, ptr1, len1);
706
+ if (ret[3]) {
707
+ throw takeFromExternrefTable0(ret[2]);
708
+ }
709
+ var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
710
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
711
+ return v3;
712
+ }
713
+
714
+ /**
715
+ * Opens a link's wrapped DEK with the secret from the fragment, returning the 32-byte DEK.
716
+ * @param {Uint8Array} link_secret
717
+ * @param {Uint8Array} wrapped
718
+ * @returns {Uint8Array}
719
+ */
720
+ export function link_unwrap_dek(link_secret, wrapped) {
721
+ const ptr0 = passArray8ToWasm0(link_secret, wasm.__wbindgen_malloc);
722
+ const len0 = WASM_VECTOR_LEN;
723
+ const ptr1 = passArray8ToWasm0(wrapped, wasm.__wbindgen_malloc);
724
+ const len1 = WASM_VECTOR_LEN;
725
+ const ret = wasm.link_unwrap_dek(ptr0, len0, ptr1, len1);
726
+ if (ret[3]) {
727
+ throw takeFromExternrefTable0(ret[2]);
728
+ }
729
+ var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
730
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
731
+ return v3;
732
+ }
733
+
734
+ /**
735
+ * Wraps a file DEK under a link secret: `E(S, "nmts/v3/link-wrap", DEK)`, 104 bytes. The server
736
+ * stores the result beside the link's token.
737
+ * @param {Uint8Array} link_secret
738
+ * @param {Uint8Array} dek
739
+ * @returns {Uint8Array}
740
+ */
741
+ export function link_wrap_dek(link_secret, dek) {
742
+ const ptr0 = passArray8ToWasm0(link_secret, wasm.__wbindgen_malloc);
743
+ const len0 = WASM_VECTOR_LEN;
744
+ const ptr1 = passArray8ToWasm0(dek, wasm.__wbindgen_malloc);
745
+ const len1 = WASM_VECTOR_LEN;
746
+ const ret = wasm.link_wrap_dek(ptr0, len0, ptr1, len1);
747
+ if (ret[3]) {
748
+ throw takeFromExternrefTable0(ret[2]);
749
+ }
750
+ var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
751
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
752
+ return v3;
753
+ }
754
+
661
755
  /**
662
756
  * The 16-byte LOCATOR a wallet signature yields — the name the server files this opener's slot
663
757
  * under, and the name a sign-in asks for it back by (NCF-3 §1.7).
@@ -886,6 +980,25 @@ export function sha256(data) {
886
980
  return v2;
887
981
  }
888
982
 
983
+ /**
984
+ * The 16-byte share ADDRESS of identity number `index`, from its signing seed alone — no
985
+ * signature is made to answer it. At index 0 it is `kdf_derive`'s `share_address` (208..224).
986
+ * @param {Uint8Array} share_sig_seed
987
+ * @param {number} index
988
+ * @returns {Uint8Array}
989
+ */
990
+ export function share_address_at(share_sig_seed, index) {
991
+ const ptr0 = passArray8ToWasm0(share_sig_seed, wasm.__wbindgen_malloc);
992
+ const len0 = WASM_VECTOR_LEN;
993
+ const ret = wasm.share_address_at(ptr0, len0, index);
994
+ if (ret[3]) {
995
+ throw takeFromExternrefTable0(ret[2]);
996
+ }
997
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
998
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
999
+ return v2;
1000
+ }
1001
+
889
1002
  /**
890
1003
  * The display form of a share address (`kdf_derive` bytes 208..224):
891
1004
  * `XXXXXXXXX-XXXXXXXXX-XXXXXXXXC` — Crockford Base32 with a trailing check symbol.
@@ -978,6 +1091,32 @@ export function share_claimed_sender(envelope) {
978
1091
  return v2;
979
1092
  }
980
1093
 
1094
+ /**
1095
+ * The three secret seeds of share identity number `index` (1-based) from the 32-byte
1096
+ * `share_id_root` at `kdf_derive` bytes 288..320: `kem(32) || auth(32) || sig(32)`, 96 bytes.
1097
+ *
1098
+ * ⛔ It takes the ROOT rather than the account code for the reason `wallet_seed_for` does: the
1099
+ * browser derives once at sign-in and keeps only the roots, and a person makes a new public code
1100
+ * whenever they like. Holding the root grants identities 1 and up and nothing else.
1101
+ *
1102
+ * Rejects `index` 0. All 96 bytes are secret and stay inside the crypto worker, like the
1103
+ * `kdf_derive` regions they sit beside.
1104
+ * @param {Uint8Array} share_id_root
1105
+ * @param {number} index
1106
+ * @returns {Uint8Array}
1107
+ */
1108
+ export function share_id_seeds(share_id_root, index) {
1109
+ const ptr0 = passArray8ToWasm0(share_id_root, wasm.__wbindgen_malloc);
1110
+ const len0 = WASM_VECTOR_LEN;
1111
+ const ret = wasm.share_id_seeds(ptr0, len0, index);
1112
+ if (ret[3]) {
1113
+ throw takeFromExternrefTable0(ret[2]);
1114
+ }
1115
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1116
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1117
+ return v2;
1118
+ }
1119
+
981
1120
  /**
982
1121
  * The 4989-byte PUBLIC share identity, built from the three secrets at `kdf_derive` bytes
983
1122
  * 112..176 and 224..256 (KEM seed, auth secret, signing seed).
@@ -1011,6 +1150,34 @@ export function share_public_key(share_kem_seed, share_auth_secret, share_sig_se
1011
1150
  return v4;
1012
1151
  }
1013
1152
 
1153
+ /**
1154
+ * The 4989-byte PUBLIC share identity number `index`: the bundle `share_public_key` builds, with
1155
+ * `derivation_index = index`. At index 0 it is `share_public_key`, byte for byte.
1156
+ *
1157
+ * The number is inside the root, so each number has its own address; the self-signature covers
1158
+ * it, so a numbered bundle is verified by exactly the steps any bundle is.
1159
+ * @param {Uint8Array} share_kem_seed
1160
+ * @param {Uint8Array} share_auth_secret
1161
+ * @param {Uint8Array} share_sig_seed
1162
+ * @param {number} index
1163
+ * @returns {Uint8Array}
1164
+ */
1165
+ export function share_public_key_at(share_kem_seed, share_auth_secret, share_sig_seed, index) {
1166
+ const ptr0 = passArray8ToWasm0(share_kem_seed, wasm.__wbindgen_malloc);
1167
+ const len0 = WASM_VECTOR_LEN;
1168
+ const ptr1 = passArray8ToWasm0(share_auth_secret, wasm.__wbindgen_malloc);
1169
+ const len1 = WASM_VECTOR_LEN;
1170
+ const ptr2 = passArray8ToWasm0(share_sig_seed, wasm.__wbindgen_malloc);
1171
+ const len2 = WASM_VECTOR_LEN;
1172
+ const ret = wasm.share_public_key_at(ptr0, len0, ptr1, len1, ptr2, len2, index);
1173
+ if (ret[3]) {
1174
+ throw takeFromExternrefTable0(ret[2]);
1175
+ }
1176
+ var v4 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1177
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1178
+ return v4;
1179
+ }
1180
+
1014
1181
  /**
1015
1182
  * Unwraps a share envelope addressed to us, returning the 32-byte file DEK.
1016
1183
  *
@@ -1054,6 +1221,49 @@ export function share_unwrap_dek(share_kem_seed, share_auth_secret, share_sig_se
1054
1221
  return v9;
1055
1222
  }
1056
1223
 
1224
+ /**
1225
+ * `share_unwrap_dek` as identity number `index`, returning the 32-byte file DEK.
1226
+ *
1227
+ * An envelope does not name its recipient, so the caller picks the number — the inbox knows
1228
+ * which address a share was stored against. Opened as the wrong number it fails with the same
1229
+ * message as an envelope meant for somebody else, a forged sender or a rewritten row.
1230
+ * @param {Uint8Array} share_kem_seed
1231
+ * @param {Uint8Array} share_auth_secret
1232
+ * @param {Uint8Array} share_sig_seed
1233
+ * @param {number} index
1234
+ * @param {Uint8Array} sender_public
1235
+ * @param {Uint8Array} envelope
1236
+ * @param {string} item_id
1237
+ * @param {Uint8Array} name_share_ct
1238
+ * @param {Uint8Array} content_hash_share_ct
1239
+ * @returns {Uint8Array}
1240
+ */
1241
+ export function share_unwrap_dek_as(share_kem_seed, share_auth_secret, share_sig_seed, index, sender_public, envelope, item_id, name_share_ct, content_hash_share_ct) {
1242
+ const ptr0 = passArray8ToWasm0(share_kem_seed, wasm.__wbindgen_malloc);
1243
+ const len0 = WASM_VECTOR_LEN;
1244
+ const ptr1 = passArray8ToWasm0(share_auth_secret, wasm.__wbindgen_malloc);
1245
+ const len1 = WASM_VECTOR_LEN;
1246
+ const ptr2 = passArray8ToWasm0(share_sig_seed, wasm.__wbindgen_malloc);
1247
+ const len2 = WASM_VECTOR_LEN;
1248
+ const ptr3 = passArray8ToWasm0(sender_public, wasm.__wbindgen_malloc);
1249
+ const len3 = WASM_VECTOR_LEN;
1250
+ const ptr4 = passArray8ToWasm0(envelope, wasm.__wbindgen_malloc);
1251
+ const len4 = WASM_VECTOR_LEN;
1252
+ const ptr5 = passStringToWasm0(item_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1253
+ const len5 = WASM_VECTOR_LEN;
1254
+ const ptr6 = passArray8ToWasm0(name_share_ct, wasm.__wbindgen_malloc);
1255
+ const len6 = WASM_VECTOR_LEN;
1256
+ const ptr7 = passArray8ToWasm0(content_hash_share_ct, wasm.__wbindgen_malloc);
1257
+ const len7 = WASM_VECTOR_LEN;
1258
+ const ret = wasm.share_unwrap_dek_as(ptr0, len0, ptr1, len1, ptr2, len2, index, ptr3, len3, ptr4, len4, ptr5, len5, ptr6, len6, ptr7, len7);
1259
+ if (ret[3]) {
1260
+ throw takeFromExternrefTable0(ret[2]);
1261
+ }
1262
+ var v9 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1263
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1264
+ return v9;
1265
+ }
1266
+
1057
1267
  /**
1058
1268
  * Wraps a file DEK for ONE recipient, given the public key the server returned AND the address
1059
1269
  * the sender was actually given.
@@ -1109,6 +1319,51 @@ export function share_wrap_dek(sender_auth_secret, sender_sig_seed, recipient_pu
1109
1319
  return v9;
1110
1320
  }
1111
1321
 
1322
+ /**
1323
+ * `share_wrap_dek` sending AS identity number `sender_index`: the two sender secrets are that
1324
+ * identity's, and the envelope's sender address is that identity's address.
1325
+ *
1326
+ * Every other argument and every check is `share_wrap_dek`'s — the recipient key is checked
1327
+ * against `recipient_address` before anything is encrypted to it, the last three arguments are
1328
+ * the row the envelope is bound to, and fresh randomness is drawn per call. Returns the 1240-byte
1329
+ * share envelope.
1330
+ * @param {Uint8Array} sender_auth_secret
1331
+ * @param {Uint8Array} sender_sig_seed
1332
+ * @param {number} sender_index
1333
+ * @param {Uint8Array} recipient_public
1334
+ * @param {Uint8Array} recipient_address
1335
+ * @param {Uint8Array} dek
1336
+ * @param {string} item_id
1337
+ * @param {Uint8Array} name_share_ct
1338
+ * @param {Uint8Array} content_hash_share_ct
1339
+ * @returns {Uint8Array}
1340
+ */
1341
+ export function share_wrap_dek_as(sender_auth_secret, sender_sig_seed, sender_index, recipient_public, recipient_address, dek, item_id, name_share_ct, content_hash_share_ct) {
1342
+ const ptr0 = passArray8ToWasm0(sender_auth_secret, wasm.__wbindgen_malloc);
1343
+ const len0 = WASM_VECTOR_LEN;
1344
+ const ptr1 = passArray8ToWasm0(sender_sig_seed, wasm.__wbindgen_malloc);
1345
+ const len1 = WASM_VECTOR_LEN;
1346
+ const ptr2 = passArray8ToWasm0(recipient_public, wasm.__wbindgen_malloc);
1347
+ const len2 = WASM_VECTOR_LEN;
1348
+ const ptr3 = passArray8ToWasm0(recipient_address, wasm.__wbindgen_malloc);
1349
+ const len3 = WASM_VECTOR_LEN;
1350
+ const ptr4 = passArray8ToWasm0(dek, wasm.__wbindgen_malloc);
1351
+ const len4 = WASM_VECTOR_LEN;
1352
+ const ptr5 = passStringToWasm0(item_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1353
+ const len5 = WASM_VECTOR_LEN;
1354
+ const ptr6 = passArray8ToWasm0(name_share_ct, wasm.__wbindgen_malloc);
1355
+ const len6 = WASM_VECTOR_LEN;
1356
+ const ptr7 = passArray8ToWasm0(content_hash_share_ct, wasm.__wbindgen_malloc);
1357
+ const len7 = WASM_VECTOR_LEN;
1358
+ const ret = wasm.share_wrap_dek_as(ptr0, len0, ptr1, len1, sender_index, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5, ptr6, len6, ptr7, len7);
1359
+ if (ret[3]) {
1360
+ throw takeFromExternrefTable0(ret[2]);
1361
+ }
1362
+ var v9 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1363
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1364
+ return v9;
1365
+ }
1366
+
1112
1367
  /**
1113
1368
  * Decrypts a whole NCF-3 stream under the file DEK, verifying framing/anti-tamper.
1114
1369
  * @param {Uint8Array} dek
@@ -41,6 +41,11 @@ export const streamencryptor_new: (a: number, b: number, c: number, d: number, e
41
41
  export const streamencryptor_push: (a: number, b: number, c: number) => [number, number, number, number];
42
42
  export const streamencryptor_resumeFromHeader: (a: number, b: number, c: number, d: number) => [number, number, number];
43
43
  export const verify_part_set: (a: number, b: number) => [number, number];
44
+ export const share_address_at: (a: number, b: number, c: number) => [number, number, number, number];
45
+ export const share_id_seeds: (a: number, b: number, c: number) => [number, number, number, number];
46
+ export const share_public_key_at: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number, number];
47
+ export const share_unwrap_dek_as: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number, p: number, q: number) => [number, number, number, number];
48
+ export const share_wrap_dek_as: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number, p: number, q: number) => [number, number, number, number];
44
49
  export const opener_locator: (a: number, b: number) => [number, number, number, number];
45
50
  export const opener_message: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
46
51
  export const opener_open: (a: number, b: number, c: number, d: number) => [number, number, number, number];
@@ -49,12 +54,17 @@ export const passkey_locator: (a: number, b: number) => [number, number, number,
49
54
  export const passkey_open: (a: number, b: number, c: number, d: number) => [number, number, number, number];
50
55
  export const passkey_prf_salt: () => [number, number];
51
56
  export const passkey_seal: (a: number, b: number, c: number, d: number) => [number, number, number, number];
57
+ export const link_generate_secret: () => [number, number];
58
+ export const link_open_secret: (a: number, b: number, c: number, d: number) => [number, number, number, number];
59
+ export const link_seal_secret: (a: number, b: number, c: number, d: number) => [number, number, number, number];
60
+ export const link_unwrap_dek: (a: number, b: number, c: number, d: number) => [number, number, number, number];
61
+ export const link_wrap_dek: (a: number, b: number, c: number, d: number) => [number, number, number, number];
52
62
  export const account_code_display: (a: number, b: number) => [number, number, number, number];
53
63
  export const account_code_generate: () => [number, number];
54
64
  export const account_code_parse: (a: number, b: number) => [number, number, number, number];
55
65
  export const account_code_phrase: (a: number, b: number, c: number, d: number) => [number, number, number, number];
56
- export const evm_key_for: (a: number, b: number, c: number) => [number, number, number, number];
57
66
  export const voucher_hash_from_input: (a: number, b: number) => [number, number];
67
+ export const evm_key_for: (a: number, b: number, c: number) => [number, number, number, number];
58
68
  export const wallet_seed_for: (a: number, b: number, c: number) => [number, number, number, number];
59
69
  export const __wbindgen_exn_store: (a: number) => void;
60
70
  export const __externref_table_alloc: () => number;