@ninsei-labs/sdk 0.55.4 → 0.57.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.
Files changed (68) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/LICENSE-POLICY.md +9 -2
  3. package/README.md +51 -24
  4. package/THIRD_PARTY_NOTICES.md +174 -0
  5. package/assets/vendors/MANIFEST.json +18 -0
  6. package/assets/vendors/sdk/sdk-browser.js +2059 -2
  7. package/engine/atomic/dleq2.js +187 -22
  8. package/engine/atomic/order.js +21 -3
  9. package/engine/core/config.js +17 -24
  10. package/engine/core/deployments.generated.js +103 -0
  11. package/engine/core/store.js +25 -4
  12. package/engine/core/swap.js +54 -52
  13. package/engine/evm/asyncRoute.js +1 -1
  14. package/engine/evm/claimGas.js +2 -1
  15. package/engine/evm/escrow.js +13 -8
  16. package/engine/evm/factory.js +24 -26
  17. package/engine/evm/funding.js +8 -3
  18. package/engine/evm/index.js +2 -4
  19. package/engine/evm/session.js +3 -3
  20. package/engine/monero/scan.js +101 -22
  21. package/engine/recovery/restore.js +8 -8
  22. package/engine/sdk/bridge.js +3 -6
  23. package/index.d.ts +57 -27
  24. package/package.json +25 -8
  25. package/src/actions.mjs +52 -9
  26. package/src/adapters/evm-wallet.mjs +24 -5
  27. package/src/adapters/index.d.ts +66 -0
  28. package/src/adapters/index.mjs +0 -6
  29. package/src/codes.mjs +14 -0
  30. package/src/config.mjs +1 -0
  31. package/src/engine.mjs +6 -6
  32. package/src/feeEstimate.mjs +11 -4
  33. package/src/http.mjs +4 -1
  34. package/src/index.mjs +4 -3
  35. package/src/legs/kyber.mjs +23 -0
  36. package/src/lock.mjs +2 -1
  37. package/src/order.mjs +108 -20
  38. package/src/primitives.mjs +4 -5
  39. package/src/probes.mjs +9 -3
  40. package/src/provider/envFile.mjs +11 -1
  41. package/src/public/networks.d.ts +45 -0
  42. package/src/public/networks.mjs +10 -1
  43. package/src/public/order.d.ts +4 -0
  44. package/src/public/recovery.d.ts +40 -54
  45. package/src/public/recovery.mjs +2 -8
  46. package/src/public/xmr.d.ts +14 -3
  47. package/src/public/xmr.mjs +1 -1
  48. package/src/quoteEip712Spec.mjs +9 -1
  49. package/src/quotes.mjs +118 -49
  50. package/src/record.mjs +3 -3
  51. package/src/recovery-key.mjs +161 -237
  52. package/src/relayFeatures.mjs +25 -13
  53. package/src/relayFirmClient.mjs +69 -6
  54. package/src/relayQuote.mjs +87 -10
  55. package/src/relayRequest.mjs +12 -3
  56. package/src/relayView.mjs +3 -3
  57. package/src/swap-flow.mjs +153 -67
  58. package/src/swaps.mjs +346 -174
  59. package/src/sweep-restore.mjs +14 -6
  60. package/src/sweep.mjs +34 -11
  61. package/src/version.mjs +1 -1
  62. package/src/xmr-arrival.mjs +55 -24
  63. package/assets/vendors/atomic/atomic-browser.js +0 -24
  64. package/engine/atomic/order-client.js +0 -56
  65. package/engine/atomic/order-worker.js +0 -156
  66. package/engine/evm/asyncExec.js +0 -577
  67. package/engine/evm/asyncLegs.js +0 -308
  68. package/src/adapters/node-test-evm-wallet.mjs +0 -357
@@ -1,10 +1,9 @@
1
1
  // ATOMIC SWAP PRIMITIVES - FROM THE SAME npm PACKAGES AS THE PAGE BUNDLE.
2
2
  //
3
- // The bundle entry point (tools/atomic-browser-entry.mjs) hands the page exactly five names: ed25519, secp256k1,
4
- // keccak256, sha3_512, randomBytes. The order-side build modules (www/js/atomic/order.js) do NOT import them
5
- // themselves - they arrive as parameters. That is what lets the SDK expose the same primitives from the same
6
- // packages instead of dragging a hashed build artefact into the core: a package never has a "version with a
7
- // different cache".
3
+ // The order builder takes exactly five names: ed25519, secp256k1, keccak256, sha3_512, randomBytes. The
4
+ // order-side build modules (www/js/atomic/order.js) do NOT import them themselves - they arrive as parameters.
5
+ // That is what lets the SDK use the same primitives from the same packages instead of dragging a hashed build
6
+ // artefact into the core: a package never has a "version with a different cache".
8
7
  //
9
8
  // WHY EXACTLY THESE PACKAGES, AND NOT JUST ANY. keccak256 and sha3_512 are DIFFERENT functions, and they must
10
9
  // not be confused: the commitment for a half is computed with keccak256 (exactly as Solidity does it), while the
package/src/probes.mjs CHANGED
@@ -40,16 +40,22 @@ export async function probeMoneroNode({ url, fetchImpl = globalThis.fetch, timeo
40
40
  signal: controller ? controller.signal : undefined,
41
41
  });
42
42
  } catch (error) {
43
+ if (timer) clearTimeout(timer);
43
44
  const aborted = error && (error.name === "AbortError" || error.code === "ABORT_ERR");
44
45
  return { ok: false, why: aborted ? "timeout" : "unreachable", ms: Date.now() - started };
45
- } finally {
46
- if (timer) clearTimeout(timer);
47
46
  }
48
47
  if (!response || !response.ok) {
48
+ if (timer) clearTimeout(timer);
49
49
  return { ok: false, why: "http", status: response ? response.status : null, ms: Date.now() - started };
50
50
  }
51
51
  let body = null;
52
- try { body = await response.json(); } catch { return { ok: false, why: "not-json", ms: Date.now() - started }; }
52
+ // THE TIMER COVERS THE BODY TOO. Clearing it when the headers arrived left a node that sent `{` and stopped
53
+ // holding the whole call forever.
54
+ try { body = await response.json(); } catch {
55
+ if (timer) clearTimeout(timer);
56
+ return { ok: false, why: "not-json", ms: Date.now() - started };
57
+ }
58
+ if (timer) clearTimeout(timer);
53
59
  if (!body || body.error) {
54
60
  return { ok: false, why: "rpc", rpc: body && body.error ? body.error.code ?? null : null, ms: Date.now() - started };
55
61
  }
@@ -18,7 +18,17 @@ import { tmpdir } from "node:os";
18
18
  // the settings were in place (the quote checks fell exactly on this, and `npm run payout` with them).
19
19
  // The reverse order can err in one direction only: on the server there is no .local file at all, and the production
20
20
  // one remains the only one. An explicit --env= still outranks everything.
21
- export const ENV_CANDIDATES = ["rfq.env.local", "rfq.env.local", "rfq.env", "rfq.env", ".env.local", ".env"];
21
+ // THE `rfq/` PATH IS A SUPPORTED LAYOUT, NOT A COMMENT: the node tree keeps its settings in `rfq/`, while a
22
+ // checkout run from the repository root has the same file one level down. The local file outranks the production
23
+ // file in BOTH layouts; an explicit --env= still outranks the list.
24
+ export const ENV_CANDIDATES = [
25
+ "rfq.env.local",
26
+ "rfq/rfq.env.local",
27
+ "rfq.env",
28
+ "rfq/rfq.env",
29
+ ".env.local",
30
+ ".env",
31
+ ];
22
32
 
23
33
  export function findEnvFile(cwd, candidates = ENV_CANDIDATES) {
24
34
  for (const rel of candidates) {
@@ -63,3 +63,48 @@ export declare const CHAINS: readonly Chain[];
63
63
  export declare const DEX_CHAINS: readonly string[];
64
64
  export declare const DEFAULT_CHAIN: string;
65
65
  export declare const ASYNC_ROUTE_PROVIDERS: Readonly<Record<string, AsyncRouteProvider>>;
66
+
67
+ /** One contract/program artifact in a deployment manifest. */
68
+ export interface DeploymentArtifact {
69
+ readonly role: string;
70
+ readonly kind: string;
71
+ readonly address: string;
72
+ readonly addressFormat: string;
73
+ readonly codeHash?: string;
74
+ readonly hashKind?: string;
75
+ readonly tx: { readonly kind: string; readonly value: string };
76
+ }
77
+
78
+ /** A VM-neutral deployment pin. Only the EVM artifacts are generated today. */
79
+ export interface DeploymentPin {
80
+ readonly vm: string;
81
+ readonly network: string;
82
+ readonly caip2: string;
83
+ readonly chainRef: string;
84
+ readonly status: "live" | "simulated" | "retired";
85
+ readonly release: {
86
+ readonly tag: string | null;
87
+ readonly commit: string | null;
88
+ readonly toolchain: string | null;
89
+ readonly deployedAt: string | null;
90
+ };
91
+ readonly anchor: { readonly kind: string; readonly value: string };
92
+ readonly artifacts: Readonly<Record<string, DeploymentArtifact>>;
93
+ /** EVM compatibility view used by `ChainConfig.escrow`. */
94
+ readonly escrow: {
95
+ readonly address: string;
96
+ readonly mode: string | null;
97
+ readonly deploymentBlock: number;
98
+ readonly cashier: string;
99
+ readonly registry: string;
100
+ readonly implementationCodeHash: string;
101
+ };
102
+ readonly knownFactoryCodes: readonly string[];
103
+ }
104
+
105
+ export declare const DEPLOYMENTS: Readonly<Record<string, DeploymentPin>>;
106
+ export declare const DEPLOYMENT_CHAINS: readonly string[];
107
+ export declare const DEPLOYMENT_VMS: readonly string[];
108
+ export declare function deploymentFor(
109
+ chainOrId: string | number | { readonly id?: string; readonly network?: string; readonly caip2?: string } | null,
110
+ ): DeploymentPin | null;
@@ -6,4 +6,13 @@
6
6
  //
7
7
  // Names only: the engine owns the values. Nothing here is re-implemented.
8
8
 
9
- export { ASYNC_ROUTE_PROVIDERS, CHAINS, DEFAULT_CHAIN, DEX_CHAINS } from "../../engine/core/config.js";
9
+ export {
10
+ ASYNC_ROUTE_PROVIDERS,
11
+ CHAINS,
12
+ DEFAULT_CHAIN,
13
+ DEX_CHAINS,
14
+ DEPLOYMENTS,
15
+ DEPLOYMENT_CHAINS,
16
+ DEPLOYMENT_VMS,
17
+ deploymentFor,
18
+ } from "../../engine/core/config.js";
@@ -112,6 +112,10 @@ export interface OrderQuote {
112
112
  readonly xmrAmount: string | number | bigint;
113
113
  /** The tip `claim` pays to a third-party sender out of the payout; zero means none. */
114
114
  readonly claimTip: string | number | bigint;
115
+ /** The depositor's half commitment and two Monero points, signed with the quote. */
116
+ readonly commitHalfLocker: string;
117
+ readonly edPointLocker: string;
118
+ readonly edViewPointLocker: string;
115
119
  /** The escrow factory the domain names as `verifyingContract`. */
116
120
  readonly factory: string;
117
121
  /** r || s || v over the digest, 65 bytes, with or without the `0x` prefix; v is normalised to 27/28. */
@@ -269,14 +269,10 @@ export declare function recoveryFileName(swapId?: string | null): string;
269
269
  export declare const RECOVERY_KEY_VERSION: number;
270
270
  /** Twelve words, by the BIP39 rules. */
271
271
  export declare const RECOVERY_KEY_WORDS: number;
272
- /** The default number of v1 indices one `findSwaps` call scans. */
273
- export declare const RECOVERY_SCAN_DEFAULT: number;
274
272
  /** The store key a browser adapter keeps the key under. */
275
273
  export declare const RECOVERY_KEY_STORE: string;
276
274
  /** The first line of a plain backup file. */
277
275
  export declare const RECOVERY_KEY_FILE_MAGIC: string;
278
- /** The domain half derivation binds to; the chain id and swap number join it. */
279
- export declare const RECOVERY_KEY_DOMAIN: string;
280
276
  /** The salt-based derivation domain; the chain, factory, role and order salt join it. */
281
277
  export declare const RECOVERY_KEY_DOMAIN_V2: string;
282
278
  /** The domain of the counterparty's view half, derived from the same one key. */
@@ -300,7 +296,6 @@ export interface RecoveryKey {
300
296
 
301
297
  /** A derived swap number: the halves cross JSON as hex scalars. */
302
298
  export interface TakerHalves {
303
- readonly index: number;
304
299
  readonly binding: string;
305
300
  readonly spendHalf: string;
306
301
  readonly viewHalf: string;
@@ -311,9 +306,8 @@ export interface TakerHalves {
311
306
  readonly spendCommitment: string;
312
307
  }
313
308
 
314
- /** A salt-based derivation: no number is reserved, and the public order salt is the input. */
315
- export interface TakerHalvesV2 extends Omit<TakerHalves, "index"> {
316
- readonly index: null;
309
+ /** A salt-based derivation: the public order salt is the input. */
310
+ export interface TakerHalvesV2 extends TakerHalves {
317
311
  readonly derivation: "salt-v2";
318
312
  readonly factory: string;
319
313
  readonly role: string;
@@ -353,10 +347,8 @@ export interface FoundSwap {
353
347
  * the expected clone. */
354
348
  readonly xmrAmount: string | null;
355
349
  readonly xmrAmountReason: "event" | "no-code-reader" | "code" | "not-clone" | null;
356
- /** The v1 swap number; null for a salt-based v2 order. */
357
- readonly index: number | null;
358
- /** Which derivation found this order. v1 orders keep recovering through the index path. */
359
- readonly derivation: "index-v1" | "salt-v2";
350
+ /** The derivation that found this order. */
351
+ readonly derivation: "salt-v2";
360
352
  /** The factory the order was read from; the v2 binding needs it. */
361
353
  readonly factory: string;
362
354
  readonly side: "locker" | "claimer";
@@ -379,16 +371,12 @@ export declare function createRecoveryKey(options?: { createdAt?: string | Date
379
371
  export declare function importRecoveryKey(mnemonic: string, options?: { createdAt?: string | Date }): RecoveryKey;
380
372
  /** The short public fingerprint (four hex characters) of the words. */
381
373
  export declare function fingerprintOf(mnemonic: string): string;
382
- /** The binding for a chain and swap number: `ninsei-taker-v1|<chainId>|<index>`. */
383
- export declare function recoveryBinding(chainId: number, index: number): string;
384
374
  /** The salt-based binding: `ninsei-taker-v2|<chainId>|<factory>|<role>|<salt>`. */
385
375
  export declare function recoveryBindingV2(request: { chainId: number; factory: string; role?: string; salt: string }): string;
386
376
  /** Normalises a 32-byte salt from an event word, a hex string, a bigint or a safe integer. */
387
377
  export declare function recoverySaltOf(value: string | number | bigint): string;
388
378
  /** A fresh 32-byte public salt for one salt-based order. */
389
379
  export declare function newRecoverySalt(): string;
390
- /** Derives the taker spend and view halves for one swap number. */
391
- export declare function takerHalves(request: { mnemonic: string; chainId: number; index: number }): TakerHalves;
392
380
  /** Derives the taker halves from a public per-order salt; no index is reserved. */
393
381
  export declare function takerHalvesV2(request: { mnemonic: string; chainId: number; factory: string; role?: string; salt: string }): TakerHalvesV2;
394
382
  /** The stable backup name, with `DO-NOT-DELETE` in it on purpose. */
@@ -397,51 +385,55 @@ export declare function recoveryKeyFileName(request: { mnemonic?: string; finger
397
385
  export declare function recoveryKeyText(request: { mnemonic: string; createdAt?: string | Date }): string;
398
386
  /** A backup file, optionally encrypted with a passphrase of at least 12 characters. */
399
387
  export declare function createRecoveryKeyFile(request: { mnemonic: string; createdAt?: string | Date; passphrase?: string }): Promise<string>;
400
- /** Reads a plain or encrypted backup file and validates the words. */
388
+ /** Reads a plain or encrypted backup file and validates the words. `createdAt` is the file's date: the plain
389
+ * header day at 00:00 UTC, the password envelope's sealed time. */
401
390
  export declare function openRecoveryKeyFile(contents: string, passphrase?: string): Promise<RecoveryKey>;
402
391
  /** Saves the key through a storage adapter. */
403
- export declare function saveRecoveryKey(storage: RecoveryKeyStorage, key: RecoveryKey & { nextIndex?: number; reserved?: Record<string, unknown>; retired?: Record<string, unknown>; backupConfirmed?: boolean }): RecoveryKey;
392
+ export declare function saveRecoveryKey(storage: RecoveryKeyStorage, key: RecoveryKey & { backupConfirmed?: boolean }): RecoveryKey;
404
393
  /** Reads the key from a storage adapter, or null. */
405
- export declare function loadRecoveryKey(storage: RecoveryKeyStorage): (RecoveryKey & { nextIndex: number; reserved: Record<string, unknown>; retired: Record<string, unknown>; backupConfirmed?: boolean }) | null;
406
- /** Reserves a swap number; the caller releases it if the request is abandoned. */
407
- export declare function reserveRecoveryIndex(storage: RecoveryKeyStorage, request: { chainId: number; swapId?: string | null }): number;
408
- /** True when an order already holds this number's commitment on chain. A page that starts swaps without the SDK's
409
- * start path calls this before using a number; an unreadable log is a refusal, not "free". */
410
- export declare function recoveryIndexTaken(request: {
411
- mnemonic: string;
412
- chainId: number;
413
- index: number;
414
- factory: string;
415
- evmLogs: (request: { address: string; topics: (string | null)[]; fromBlock: number | string; toBlock: number | string }) => Promise<unknown[]>;
394
+ export declare function loadRecoveryKey(storage: RecoveryKeyStorage): (RecoveryKey & { backupConfirmed?: boolean }) | null;
395
+
396
+ /** One settlement event read in bulk; the escrow is named by its address. */
397
+ export interface EscrowEvent {
398
+ readonly escrow: string;
399
+ readonly event: "HalfRevealed" | "Ready" | "Declined";
400
+ readonly blockNumber: number | string | null;
401
+ readonly transactionHash: string | null;
402
+ readonly logIndex: number | string | null;
403
+ readonly half?: string;
404
+ readonly byClaimer?: boolean;
405
+ readonly by?: string;
406
+ }
407
+
408
+ /** The three settlement event topics; exported so a caller does not copy the signatures. */
409
+ export declare const ESCROW_EVENT_TOPICS: {
410
+ readonly halfRevealed: string;
411
+ readonly ready: string;
412
+ readonly declined: string;
413
+ };
414
+
415
+ /** Read HalfRevealed, Ready and Declined for a list of escrows in one log request. */
416
+ export declare function readEscrowEvents(request: {
417
+ escrows: readonly string[];
418
+ evmLogs: (request: { address: readonly string[]; topics: (string | null)[][]; fromBlock: number | string; toBlock: number | string }) => Promise<unknown[]>;
416
419
  fromBlock?: number | string;
417
420
  toBlock?: number | string;
418
- }): Promise<boolean>;
419
- /** Releases a number that never reached the chain. */
420
- export declare function releaseRecoveryIndex(storage: RecoveryKeyStorage, index: number): void;
421
- /** Retires a number after its order exists on chain. */
422
- export declare function commitRecoveryIndex(storage: RecoveryKeyStorage, index: number): void;
421
+ }): Promise<EscrowEvent[]>;
422
+
423
423
  /** Finds orders whose commitment was made from the key's halves. */
424
424
  export declare function findSwaps(request: {
425
425
  mnemonic: string;
426
426
  chainId: number;
427
- factory: string;
427
+ /** One factory. When omitted, `factories` must name the chain's history. */
428
+ factory?: string | null;
429
+ /** Every factory of the chain, with its own deployment block; older orders stay searchable. */
430
+ factories?: readonly (string | { readonly address?: string; readonly factory?: string; readonly deploymentBlock?: number | null })[] | null;
428
431
  address?: string | null;
429
432
  evmLogs: (request: { address: string; topics: (string | null)[]; fromBlock: number | string; toBlock: number | string }) => Promise<unknown[]>;
430
433
  fromBlock?: number | string;
431
434
  /** The factory's deployment block from the chain registry; used when `fromBlock` is omitted. */
432
435
  deploymentBlock?: number | null;
433
436
  toBlock?: number | string;
434
- /** Deprecated and ignored: discovery no longer stops after a run of empty numbers. */
435
- gap?: number;
436
- /** The first index to try. Defaults to 0; a continuation passes the previous `nextIndex`. */
437
- fromIndex?: number;
438
- /** How many indices this call may try. Defaults to `RECOVERY_SCAN_DEFAULT` (1000), not the allocator ceiling. */
439
- maxIndex?: number;
440
- /** Stop the scan between chunks. An aborted scan returns `complete: false`, `incompleteReason: "aborted"` and
441
- * the `nextIndex` to resume from. */
442
- signal?: { readonly aborted: boolean } | null;
443
- /** Called after every chunk and after the last index, with the count and the index just scanned. */
444
- onProgress?: ((value: { readonly scanned: number; readonly index: number }) => void) | null;
445
437
  /** Reads the settlement block timestamp, in seconds: (blockNumber) -> seconds. */
446
438
  evmBlockTime?: (blockNumber: number) => Promise<number>;
447
439
  /** Reads contract code: (address) -> 0x-hex. Used to read the XMR amount from an order clone. */
@@ -459,13 +451,7 @@ export declare function findSwaps(request: {
459
451
  fetchImpl?: typeof fetch;
460
452
  }): Promise<{
461
453
  swaps: FoundSwap[];
462
- scanned: number;
463
- /** The last index tried, or null when no index was scanned. */
464
- searchedUpTo: number | null;
465
- /** True when every order in the logs was matched, or when the allocator range was searched to its end. */
454
+ /** True when every order in the logs was read. There is no index range to exhaust. */
466
455
  complete: boolean;
467
- /** `max-index` or `aborted` when a bound or the caller stopped the search before every order was matched. */
468
- incompleteReason?: string;
469
- /** The next index to pass as `fromIndex`; absent when the search is complete. */
470
- nextIndex?: number;
471
456
  }>;
457
+
@@ -24,7 +24,6 @@ export {
24
24
  // ONE RECOVERY KEY FOR EVERY SWAP (sdk#79): the taker's key, its derivation, its file and the on-chain search.
25
25
  export {
26
26
  RECOVERY_KEY_ALG,
27
- RECOVERY_KEY_DOMAIN,
28
27
  RECOVERY_KEY_DOMAIN_V2,
29
28
  RECOVERY_KEY_ENVELOPE_VERSION,
30
29
  RECOVERY_KEY_FILE_MAGIC,
@@ -33,25 +32,20 @@ export {
33
32
  RECOVERY_KEY_VERSION,
34
33
  MAKER_VIEW_HALF_DOMAIN,
35
34
  RECOVERY_KEY_WORDS,
36
- RECOVERY_SCAN_DEFAULT,
37
- commitRecoveryIndex,
38
35
  createRecoveryKey,
39
36
  createRecoveryKeyFile,
40
37
  findSwaps,
38
+ readEscrowEvents,
39
+ ESCROW_EVENT_TOPICS,
41
40
  fingerprintOf,
42
41
  importRecoveryKey,
43
42
  loadRecoveryKey,
44
43
  newRecoverySalt,
45
44
  openRecoveryKeyFile,
46
- recoveryBinding,
47
45
  recoveryBindingV2,
48
- recoveryIndexTaken,
49
46
  recoverySaltOf,
50
47
  recoveryKeyFileName,
51
48
  recoveryKeyText,
52
- releaseRecoveryIndex,
53
- reserveRecoveryIndex,
54
49
  saveRecoveryKey,
55
- takerHalves,
56
50
  takerHalvesV2,
57
51
  } from "../recovery-key.mjs";
@@ -194,10 +194,18 @@ export interface Dleq2ProofPart {
194
194
  readonly sig: Dleq2Signature;
195
195
  }
196
196
 
197
- /** The proof: the point X on both curves, and one part per bit of the smaller group order. */
197
+ /** A Schnorr proof that the point is a pure multiple of the curve generator. */
198
+ export interface Dleq2KnowledgeProof {
199
+ readonly R: string;
200
+ readonly s: string;
201
+ }
202
+
203
+ /** The proof: the point X on both curves, one knowledge proof per curve, and one part per bit. */
198
204
  export interface Dleq2Proof {
199
205
  readonly XA: string;
200
206
  readonly XB: string;
207
+ readonly pokA: Dleq2KnowledgeProof;
208
+ readonly pokB: Dleq2KnowledgeProof;
201
209
  readonly proofs: readonly Dleq2ProofPart[];
202
210
  }
203
211
 
@@ -216,6 +224,8 @@ export interface Dleq2Prepared {
216
224
  readonly XA: string;
217
225
  readonly XB: string;
218
226
  readonly context: string;
227
+ readonly pokA: Dleq2KnowledgeProof;
228
+ readonly pokB: Dleq2KnowledgeProof;
219
229
  readonly bits: readonly Dleq2PreparedBit[];
220
230
  }
221
231
 
@@ -241,8 +251,9 @@ export interface Dleq2 {
241
251
  readonly curves: { readonly A: Dleq2Curve; readonly B: Dleq2Curve };
242
252
  /** The whole proof. `onBit` reports progress every 16 bits and at the last. */
243
253
  readonly prove: (x: bigint | string | number, context: string, onBit?: (done: number, total: number) => void) => Dleq2Proof;
244
- /** Verifies a proof of untrusted shape: form is checked before counting, and every refusal is named. */
245
- readonly verify: (proof: unknown, context: string) => Dleq2Verdict;
254
+ /** Verifies a proof of untrusted shape: form is checked before counting, and every refusal is named.
255
+ * `requireKnowledge` defaults to true; set it to false only to inspect historical proofs. */
256
+ readonly verify: (proof: unknown, context: string, options?: { readonly requireKnowledge?: boolean }) => Dleq2Verdict;
246
257
  /** Step 1: the commitments. Sequential by construction. */
247
258
  readonly prepareProof: (x: bigint | string | number, context: string) => Dleq2Prepared;
248
259
  /** Step 2: one bit, on the prepared data alone - it needs neither the half nor the other bits. */
@@ -58,7 +58,7 @@ export {
58
58
  plainLoopbackAllowed,
59
59
  } from "../../engine/monero/daemonAddress.js";
60
60
 
61
- // WHAT A TRANSACTION WILL COST: the daemon's price per kilobyte, by priority, and the arithmetic that turns it into
61
+ // WHAT A TRANSACTION WILL COST: the daemon's price per byte, by priority, and the arithmetic that turns it into
62
62
  // a fee. The page learned the fee only after signing.
63
63
  export { moneroFeeEstimate, feeForBytes } from "../feeEstimate.mjs";
64
64
 
@@ -35,19 +35,24 @@
35
35
  // claimTip - the tip the escrow pays to whoever sends `claim`, out of the payout, in the same
36
36
  // transaction (#18). It is inside the signed set so a provider cannot raise it after the
37
37
  // taker has seen the quote. Zero means no tip and is the only value a buy uses.
38
+ // commitHalfLocker, - the depositor's half commitment and two Monero points. They used to travel beside the
39
+ // edPointLocker, quote, outside the signature: a taker could show one set and fund another escrow with
40
+ // edViewPointLocker a decoy. The chain now reads them from the signed quote, so one quote names one escrow.
38
41
  //
39
42
  // The domain's verifyingContract is the escrow FACTORY taken from the order: the contract that will verify the
40
43
  // quote in EVM (stage 2). The type order, the domain name and the version are part of the protocol - they may
41
44
  // change only together with the quote version.
42
45
  export const ORDER_QUOTE_DOMAIN_NAME = "NinseiEscrowFactory";
43
46
  export const ORDER_QUOTE_DOMAIN_VERSION = "1";
47
+ // 10: the signed EIP-712 field set grew the depositor's half commitment and two Monero points. They used to be
48
+ // factory arguments outside the signature, which let one quote fund an escrow with decoy locker fields.
44
49
  // 9: the signed EIP-712 field set grew `claimTip` (#18) - the tip a third-party sender of `claim` takes from the
45
50
  // payout, covered by the provider's signature like every other condition.
46
51
  // 8: the field set grew `xmrAmount` (#110 step 3). This is the request-shape generation label, and it moves WITH the
47
52
  // field set (see the note above). The DOMAIN name and the domain version string are UNCHANGED by it: they name the
48
53
  // domain (the factory address and the chain), which did not change. So here the label and the domain version string
49
54
  // move apart, and that is deliberate - the label tracks the message shape, not the domain identity.
50
- export const ORDER_QUOTE_VERSION = 9;
55
+ export const ORDER_QUOTE_VERSION = 10;
51
56
 
52
57
  // The domain type string is assembled from parts ON PURPOSE. A single literal of it is a phrase of several
53
58
  // space-separated words, and the SDK check reads such literals as user-facing text. Do not "simplify" it.
@@ -77,6 +82,9 @@ export const ORDER_QUOTE_FIELDS = [
77
82
  ["nonce", "uint256"],
78
83
  ["xmrAmount", "uint256"],
79
84
  ["claimTip", "uint256"],
85
+ ["commitHalfLocker", "bytes32"],
86
+ ["edPointLocker", "bytes32"],
87
+ ["edViewPointLocker", "bytes32"],
80
88
  ];
81
89
  export const ORDER_QUOTE_TYPE = "OrderQuote(" + ORDER_QUOTE_FIELDS.map((f) => f[1] + " " + f[0]).join(",") + ")";
82
90