@motebit/crypto 0.8.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,7 +5,7 @@
5
5
  * artifacts. A third party needs these to produce valid signed artifacts that
6
6
  * any verifier will accept.
7
7
  *
8
- * Moved from BSL @motebit/crypto to MIT @motebit/crypto.
8
+ * Moved from BSL @motebit/encryption to the permissive floor in @motebit/crypto (Apache-2.0).
9
9
  */
10
10
  /**
11
11
  * Shape of an execution receipt for signing/verification.
@@ -28,22 +28,140 @@ export interface SignableReceipt {
28
28
  delegation_receipts?: SignableReceipt[];
29
29
  relay_task_id?: string;
30
30
  delegated_scope?: string;
31
+ /**
32
+ * Cryptosuite discriminator. Always `"motebit-jcs-ed25519-b64-v1"` today —
33
+ * the verification recipe is JCS canonicalization of the unsigned body,
34
+ * Ed25519 primitive, base64url signature encoding. Every ExecutionReceipt
35
+ * on the wire carries this field; verifiers reject missing or unknown
36
+ * values fail-closed. Widening this literal to add a PQ suite is a
37
+ * deliberate registry change (see @motebit/protocol `SuiteId`).
38
+ */
39
+ suite: "motebit-jcs-ed25519-b64-v1";
31
40
  signature: string;
32
41
  }
42
+ /** The one suite ExecutionReceipts sign under today. */
43
+ export declare const EXECUTION_RECEIPT_SUITE: "motebit-jcs-ed25519-b64-v1";
33
44
  /**
34
- * Sign an execution receipt. Produces a canonical JSON representation
35
- * of all fields except `signature`, signs it with Ed25519, and sets
36
- * the `signature` field to the base64url-encoded result.
45
+ * Sign an execution receipt. Stamps the cryptosuite discriminator into
46
+ * the receipt body, canonicalizes with JCS, dispatches the primitive
47
+ * signature through `signBySuite`, and encodes as base64url per the
48
+ * suite's rules.
49
+ *
50
+ * Callers pass a receipt *without* `signature` or `suite`; the signer
51
+ * owns both. The returned object is a full `SignableReceipt` with
52
+ * `suite` and `signature` set.
37
53
  */
38
- export declare function signExecutionReceipt<T extends Omit<SignableReceipt, "signature">>(receipt: T, privateKey: Uint8Array, publicKey?: Uint8Array): Promise<T & {
54
+ export declare function signExecutionReceipt<T extends Omit<SignableReceipt, "signature" | "suite">>(receipt: T, privateKey: Uint8Array, publicKey?: Uint8Array): Promise<T & {
55
+ suite: typeof EXECUTION_RECEIPT_SUITE;
39
56
  signature: string;
40
57
  }>;
41
58
  /**
42
- * Verify an execution receipt's Ed25519 signature.
43
- * Reconstructs the canonical JSON from all fields except `signature`
44
- * and verifies against the provided public key.
59
+ * Verify an execution receipt's signature by dispatching through the
60
+ * recipe named in `receipt.suite`. Reconstructs the canonical JSON from
61
+ * all fields except `signature` (the suite IS part of the signed body,
62
+ * so tampering with it breaks verification).
63
+ *
64
+ * Fail-closed on:
65
+ * - unknown suite value (dispatcher rejects)
66
+ * - suite other than `EXECUTION_RECEIPT_SUITE` (until a PQ variant
67
+ * lands in the registry, this narrow check rejects any other
68
+ * value — widens when the union widens)
69
+ * - base64url decode errors
70
+ * - primitive-level verification failure
45
71
  */
46
72
  export declare function verifyExecutionReceipt(receipt: SignableReceipt, publicKey: Uint8Array): Promise<boolean>;
73
+ /**
74
+ * Companion to `verifyExecutionReceipt` that returns diagnostic detail
75
+ * alongside the boolean verdict. Intended for failure-path observability:
76
+ * when verification fails, the caller can log `canonical_sha256` and
77
+ * `canonical_preview` and the producer can byte-diff against its own
78
+ * sign-time hash to localize the mutation. Same canonicalization recipe
79
+ * as the boolean function — the diagnostic is derived from the exact bytes
80
+ * the verifier checked.
81
+ *
82
+ * Cost: one extra `canonicalJson` + SHA-256 per call. Negligible for the
83
+ * verify-failed path (rare); callers on the hot success path should still
84
+ * use `verifyExecutionReceipt` directly.
85
+ */
86
+ export interface ReceiptVerifyDetail {
87
+ valid: boolean;
88
+ /** Hex SHA-256 of the canonical bytes the verifier checked. */
89
+ canonical_sha256: string;
90
+ /** First 256 chars of the canonical JSON — enough to spot most field-level diffs. */
91
+ canonical_preview: string;
92
+ /** Reason category if valid is false; `"ok"` if true. */
93
+ reason: "ok" | "wrong_suite" | "bad_base64" | "ed25519_mismatch";
94
+ }
95
+ export declare function verifyExecutionReceiptDetailed(receipt: SignableReceipt, publicKey: Uint8Array): Promise<ReceiptVerifyDetail>;
96
+ /**
97
+ * Shape of a tool-invocation receipt for signing/verification.
98
+ * Structurally compatible with `@motebit/protocol` ToolInvocationReceipt.
99
+ *
100
+ * A per-tool-call signed artifact: one receipt per invocation of a tool
101
+ * during an agent turn. The slab emits these live as tool calls
102
+ * complete. Binding to the enclosing task is by `task_id`; a verifier
103
+ * can gather all invocations for a task by matching it.
104
+ *
105
+ * Commits to structural facts only — tool name, canonical-JSON SHA-256
106
+ * hashes of args and result, timestamps, identities. The raw args and
107
+ * raw result bytes are *not* part of the receipt; a verifier who holds
108
+ * them can recompute the hash and check against the signature.
109
+ */
110
+ export interface SignableToolInvocationReceipt {
111
+ invocation_id: string;
112
+ task_id: string;
113
+ motebit_id: string;
114
+ /** Signer's Ed25519 public key (hex). Enables verification without relay lookup. */
115
+ public_key?: string;
116
+ device_id: string;
117
+ tool_name: string;
118
+ started_at: number;
119
+ completed_at: number;
120
+ status: "completed" | "failed" | "denied";
121
+ args_hash: string;
122
+ result_hash: string;
123
+ /** Optional surface-determinism discriminator; signature-bound when present. */
124
+ invocation_origin?: "user-tap" | "ai-loop" | "scheduled" | "agent-to-agent";
125
+ /**
126
+ * Cryptosuite discriminator. Always `"motebit-jcs-ed25519-b64-v1"` for
127
+ * this artifact today — same verification recipe as `ExecutionReceipt`.
128
+ * Narrowed to the single suite today so widening requires intentional
129
+ * registry + type change.
130
+ */
131
+ suite: "motebit-jcs-ed25519-b64-v1";
132
+ signature: string;
133
+ }
134
+ /** The one suite ToolInvocationReceipts sign under today. */
135
+ export declare const TOOL_INVOCATION_RECEIPT_SUITE: "motebit-jcs-ed25519-b64-v1";
136
+ /**
137
+ * Compute the `args_hash` / `result_hash` for a tool-invocation receipt.
138
+ * JCS-canonicalizes the value, then SHA-256s the UTF-8 bytes. Returns
139
+ * hex. Use on both sides of the wire: the producer computes the hash at
140
+ * sign time; a verifier with the raw value recomputes and matches.
141
+ *
142
+ * For `string` values (e.g., a plain result string), the canonicalization
143
+ * is the value itself wrapped with JSON escaping rules; `canonicalJson`
144
+ * handles both scalar and object inputs uniformly.
145
+ */
146
+ export declare function hashToolPayload(value: unknown): Promise<string>;
147
+ /**
148
+ * Sign a tool-invocation receipt. Mirrors `signExecutionReceipt`:
149
+ * stamps the cryptosuite into the body, canonicalizes with JCS,
150
+ * dispatches through `signBySuite`, and encodes as base64url.
151
+ *
152
+ * Callers pass a receipt *without* `signature` or `suite`; the signer
153
+ * owns both. Also embeds the public key (hex) so the receipt is
154
+ * independently verifiable with no relay lookup.
155
+ */
156
+ export declare function signToolInvocationReceipt<T extends Omit<SignableToolInvocationReceipt, "signature" | "suite">>(receipt: T, privateKey: Uint8Array, publicKey?: Uint8Array): Promise<T & {
157
+ suite: typeof TOOL_INVOCATION_RECEIPT_SUITE;
158
+ signature: string;
159
+ }>;
160
+ /**
161
+ * Verify a tool-invocation receipt. Fails closed on unknown suite, bad
162
+ * base64, or signature mismatch — same rules as `verifyExecutionReceipt`.
163
+ */
164
+ export declare function verifyToolInvocationReceipt(receipt: SignableToolInvocationReceipt, publicKey: Uint8Array): Promise<boolean>;
47
165
  /**
48
166
  * Inputs for a sovereign payment receipt — produced by the *payee* when
49
167
  * a counterparty pays them directly via an onchain wallet rail (Solana,
@@ -132,28 +250,39 @@ export declare function verifyReceiptSequence(chain: ReceiptChainEntry[]): Promi
132
250
  index?: number;
133
251
  }>;
134
252
  /**
135
- * A signed delegation token authorizing one entity to act on behalf of another.
136
- * The delegator signs (delegator_id, delegate_id, scope, issued_at, expires_at)
137
- * with their private key, proving they authorized the delegate.
138
- */
139
- export interface DelegationToken {
140
- delegator_id: string;
141
- delegator_public_key: string;
142
- delegate_id: string;
143
- delegate_public_key: string;
144
- scope: string;
145
- issued_at: number;
146
- expires_at: number;
147
- signature: string;
148
- }
253
+ * Re-export `DelegationToken` from the canonical protocol type package.
254
+ * The interface body lives in `@motebit/protocol` because `DelegationToken`
255
+ * is a wire-format type (per the synchronization-invariant doctrine,
256
+ * every spec-declared wire type must be exported from `@motebit/protocol`).
257
+ *
258
+ * Two statements so check-deps sees the `import type` prefix on the one
259
+ * line that references another workspace package — a bare
260
+ * `export type { X } from "..."` is technically type-only by TypeScript
261
+ * semantics, but the drift probe's regex only recognizes `import type`.
262
+ */
263
+ import type { DelegationToken } from "@motebit/protocol";
264
+ export type { DelegationToken };
265
+ /** The one suite DelegationTokens sign under today. */
266
+ export declare const DELEGATION_TOKEN_SUITE: "motebit-jcs-ed25519-b64-v1";
149
267
  /**
150
268
  * Sign a delegation token. The delegator authorizes the delegate to act
151
- * within the given scope. The signature covers all fields except `signature`.
269
+ * within the given scope. Stamps the cryptosuite into the signed body,
270
+ * dispatches the primitive signature through `signBySuite`.
271
+ *
272
+ * Callers pass the token without `signature` or `suite`; the signer owns
273
+ * both. Public keys must already be hex-encoded — this signer does not
274
+ * transcode, so the input carries the same encoding the output will.
152
275
  */
153
- export declare function signDelegation(delegation: Omit<DelegationToken, "signature">, delegatorPrivateKey: Uint8Array): Promise<DelegationToken>;
276
+ export declare function signDelegation(delegation: Omit<DelegationToken, "signature" | "suite">, delegatorPrivateKey: Uint8Array): Promise<DelegationToken>;
154
277
  /**
155
278
  * Verify a delegation token's signature and (optionally) expiration.
156
279
  *
280
+ * Rejects fail-closed on:
281
+ * - missing or unknown `suite` value (anything other than `DELEGATION_TOKEN_SUITE`)
282
+ * - expired token (unless `options.checkExpiry === false`)
283
+ * - malformed hex public key or base64url signature
284
+ * - primitive-level verification failure
285
+ *
157
286
  * @param delegation - The delegation token to verify
158
287
  * @param options.checkExpiry - If true (default), reject expired tokens. Pass false
159
288
  * only when verifying historical chains where expiration is irrelevant.
@@ -177,6 +306,205 @@ export declare function verifyDelegationChain(chain: DelegationToken[]): Promise
177
306
  valid: boolean;
178
307
  error?: string;
179
308
  }>;
309
+ import type { AdjudicatorVote, DisputeAppeal, DisputeEvidence, DisputeRequest, DisputeResolution } from "@motebit/protocol";
310
+ export type { AdjudicatorVote, DisputeAppeal, DisputeEvidence, DisputeRequest, DisputeResolution };
311
+ /** The one suite AdjudicatorVotes sign under today — matches spec/dispute-v1.md §6.4. */
312
+ export declare const ADJUDICATOR_VOTE_SUITE: "motebit-jcs-ed25519-b64-v1";
313
+ /** The one suite DisputeResolutions sign under today — matches spec/dispute-v1.md §6.4. */
314
+ export declare const DISPUTE_RESOLUTION_SUITE: "motebit-jcs-ed25519-b64-v1";
315
+ /** The one suite DisputeRequest filings sign under today — spec/dispute-v1.md §4.2. */
316
+ export declare const DISPUTE_REQUEST_SUITE: "motebit-jcs-ed25519-b64-v1";
317
+ /** The one suite DisputeEvidence submissions sign under today — spec/dispute-v1.md §5.2. */
318
+ export declare const DISPUTE_EVIDENCE_SUITE: "motebit-jcs-ed25519-b64-v1";
319
+ /** The one suite DisputeAppeal filings sign under today — spec/dispute-v1.md §8.2. */
320
+ export declare const DISPUTE_APPEAL_SUITE: "motebit-jcs-ed25519-b64-v1";
321
+ /**
322
+ * Sign a federation peer's adjudication vote. The `dispute_id` IS part
323
+ * of the signed body — spec §6.5 Foundation Law: "Each AdjudicatorVote
324
+ * signature MUST cover its `dispute_id`. Votes are not portable across
325
+ * disputes — a malicious adjudicator collecting old votes from other
326
+ * disputes cannot stuff them into a new resolution because the
327
+ * dispute_id binding breaks the signature."
328
+ *
329
+ * Callers pass the body without `signature` or `suite`; the signer owns
330
+ * both.
331
+ */
332
+ export declare function signAdjudicatorVote(vote: Omit<AdjudicatorVote, "signature" | "suite">, peerPrivateKey: Uint8Array): Promise<AdjudicatorVote>;
333
+ /**
334
+ * Verify an adjudicator vote against the voting peer's public key.
335
+ * Fail-closed on unknown suite, base64url decode error, and primitive
336
+ * verification failure. Matching of `peer_id` to a legitimate federation
337
+ * peer is the caller's responsibility (this function verifies the
338
+ * signature; peer-membership is a trust decision).
339
+ */
340
+ export declare function verifyAdjudicatorVote(vote: AdjudicatorVote, peerPublicKey: Uint8Array): Promise<boolean>;
341
+ /**
342
+ * Sign a dispute resolution. For single-relay adjudication
343
+ * (`adjudicator_votes: []`) the relay signs with its own identity key.
344
+ * For federation resolutions, the leader collects signed
345
+ * `AdjudicatorVote` entries, then signs the aggregate.
346
+ *
347
+ * Callers pass the body without `signature` or `suite`; the signer
348
+ * owns both.
349
+ *
350
+ * Per spec §6.5 Foundation Law, a federation resolution MUST include
351
+ * individual `AdjudicatorVote` entries — aggregated-only verdicts are
352
+ * rejected. This signer does not enforce that at sign time (the
353
+ * orchestrator decides whether federation is required); the verifier
354
+ * re-checks every embedded vote signature when the array is non-empty.
355
+ */
356
+ export declare function signDisputeResolution(resolution: Omit<DisputeResolution, "signature" | "suite">, adjudicatorPrivateKey: Uint8Array): Promise<DisputeResolution>;
357
+ /**
358
+ * Verify a dispute resolution. Two layers:
359
+ * 1. Outer signature verifies against `adjudicatorPublicKey`.
360
+ * 2. When `adjudicator_votes.length > 0`, every embedded
361
+ * AdjudicatorVote's signature is re-checked against the
362
+ * corresponding `peerKeys` entry (lookup by `peer_id`). Per §6.5,
363
+ * aggregated-only verdicts without individual peer signatures are
364
+ * rejected — a missing peer key in the lookup is treated as a
365
+ * verification failure.
366
+ *
367
+ * Fail-closed on unknown suite, decode errors, primitive verification
368
+ * failures, any missing peer key, and any invalid embedded vote.
369
+ */
370
+ export declare function verifyDisputeResolution(resolution: DisputeResolution, adjudicatorPublicKey: Uint8Array, peerKeys?: Map<string, Uint8Array>): Promise<boolean>;
371
+ /**
372
+ * Sign a DisputeRequest. Filing party signs over canonical JSON of
373
+ * every field except `signature`. The relay verifies against the
374
+ * filer's registered public key before accepting the filing — without
375
+ * the signature, anyone could file a dispute as anyone (foundation
376
+ * law §4.4: filing party must be a direct party to the task; without
377
+ * the signature binding, the relay cannot enforce that). Callers pass
378
+ * the body without `signature` or `suite`; the signer owns both.
379
+ */
380
+ export declare function signDisputeRequest(request: Omit<DisputeRequest, "signature" | "suite">, filerPrivateKey: Uint8Array): Promise<DisputeRequest>;
381
+ /**
382
+ * Verify a DisputeRequest against the filing party's public key.
383
+ * Fail-closed on unknown suite, base64url decode error, and primitive
384
+ * verification failure. Eligibility checks (`filed_by` is a real party
385
+ * to `task_id`, trust threshold, evidence_refs non-empty) are the
386
+ * caller's responsibility — this verifies the signature only.
387
+ */
388
+ export declare function verifyDisputeRequest(request: DisputeRequest, filerPublicKey: Uint8Array): Promise<boolean>;
389
+ /**
390
+ * Sign a DisputeEvidence submission. The submitting party — either
391
+ * the dispute's filer or respondent — signs over the canonical JSON
392
+ * of every field except `signature`. The relay verifies against the
393
+ * submitter's registered public key (foundation law §5.4: evidence
394
+ * must be cryptographically verifiable; unsigned/tampered evidence
395
+ * is rejected).
396
+ */
397
+ export declare function signDisputeEvidence(evidence: Omit<DisputeEvidence, "signature" | "suite">, submitterPrivateKey: Uint8Array): Promise<DisputeEvidence>;
398
+ /**
399
+ * Verify a DisputeEvidence submission against the submitting party's
400
+ * public key. Inner `evidence_data` validation against its own per-
401
+ * type schema (e.g. ExecutionReceiptSchema for `execution_receipt`)
402
+ * is the adjudicator's responsibility — this verifies the outer
403
+ * envelope signature only.
404
+ */
405
+ export declare function verifyDisputeEvidence(evidence: DisputeEvidence, submitterPublicKey: Uint8Array): Promise<boolean>;
406
+ /**
407
+ * Sign a DisputeAppeal. The appealing party — filer or respondent —
408
+ * signs over the canonical JSON of every field except `signature`.
409
+ * Foundation law §8.4: one appeal per dispute; the post-appeal state
410
+ * is terminal. The relay verifies against the appealer's registered
411
+ * public key before transitioning the dispute to `appealed`.
412
+ */
413
+ export declare function signDisputeAppeal(appeal: Omit<DisputeAppeal, "signature" | "suite">, appealerPrivateKey: Uint8Array): Promise<DisputeAppeal>;
414
+ /**
415
+ * Verify a DisputeAppeal against the appealing party's public key.
416
+ * Fail-closed on unknown suite, base64url decode error, and primitive
417
+ * verification failure.
418
+ */
419
+ export declare function verifyDisputeAppeal(appeal: DisputeAppeal, appealerPublicKey: Uint8Array): Promise<boolean>;
420
+ import type { ConsolidationReceipt } from "@motebit/protocol";
421
+ export type { ConsolidationReceipt };
422
+ /** The one suite ConsolidationReceipts sign under today. */
423
+ export declare const CONSOLIDATION_RECEIPT_SUITE: "motebit-jcs-ed25519-b64-v1";
424
+ /**
425
+ * Sign a consolidation receipt. The motebit's Ed25519 identity key
426
+ * commits to the structural counts of work performed during a
427
+ * consolidation cycle. Receipt is self-attesting: any holder of the
428
+ * signer's public key verifies without contacting any relay.
429
+ *
430
+ * Callers pass the body without `signature` or `suite`; the signer
431
+ * owns both. Pass `publicKey` to embed it in the receipt for portable
432
+ * verification (recommended — third parties verify from the receipt
433
+ * alone).
434
+ *
435
+ * The signed receipt is `Object.freeze`d before return so any
436
+ * post-sign mutation throws synchronously at the producer instead of
437
+ * surfacing as wire-corruption noise on a downstream verifier.
438
+ */
439
+ export declare function signConsolidationReceipt(receipt: Omit<ConsolidationReceipt, "signature" | "suite" | "public_key">, privateKey: Uint8Array, publicKey?: Uint8Array): Promise<ConsolidationReceipt>;
440
+ /**
441
+ * Verify a consolidation receipt against the signer's public key.
442
+ * Fail-closed on unknown `suite`, base64url decode error, primitive
443
+ * verification failure. The caller is responsible for matching
444
+ * `motebit_id` to whoever they expect signed; the cryptographic
445
+ * property here is "this body was signed by the holder of this key."
446
+ */
447
+ export declare function verifyConsolidationReceipt(receipt: ConsolidationReceipt, publicKey: Uint8Array): Promise<boolean>;
448
+ import type { BalanceWaiver } from "@motebit/protocol";
449
+ export type { BalanceWaiver };
450
+ /** The one suite BalanceWaivers sign under today — matches spec/migration-v1.md §7.2. */
451
+ export declare const BALANCE_WAIVER_SUITE: "motebit-jcs-ed25519-b64-v1";
452
+ /**
453
+ * Sign a balance waiver. The agent forfeits a named micro-unit amount to
454
+ * expedite departure from a relay (spec/migration-v1.md §7.2 + §7.3 — a
455
+ * waiver is one of the two terminal authorizations the depart route will
456
+ * accept, the other being a confirmed withdrawal).
457
+ *
458
+ * Callers pass the body without `signature` or `suite`; the signer owns
459
+ * both. The agent's identity key signs canonical JSON of the unsigned
460
+ * body (with `suite` stamped in), base64url-encoded.
461
+ */
462
+ export declare function signBalanceWaiver(waiver: Omit<BalanceWaiver, "signature" | "suite">, agentPrivateKey: Uint8Array): Promise<BalanceWaiver>;
463
+ /**
464
+ * Verify a balance waiver against the agent's public key. Rejects
465
+ * fail-closed on unknown `suite`, base64url decode error, and primitive
466
+ * verification failure. Matching of `motebit_id` to the authorizing
467
+ * agent, and `waived_amount` to the actual virtual-account balance, is
468
+ * the caller's responsibility (neither is a cryptographic property).
469
+ */
470
+ export declare function verifyBalanceWaiver(waiver: BalanceWaiver, agentPublicKey: Uint8Array): Promise<boolean>;
471
+ import type { SettlementRecord } from "@motebit/protocol";
472
+ export type { SettlementRecord };
473
+ /** The one suite SettlementRecords sign under today. */
474
+ export declare const SETTLEMENT_RECORD_SUITE: "motebit-jcs-ed25519-b64-v1";
475
+ /**
476
+ * Sign a settlement record. The issuing relay commits to the (amount,
477
+ * fee, rate, status) tuple; a malicious relay therefore cannot issue
478
+ * inconsistent records to different observers.
479
+ *
480
+ * Callers pass the record without `signature` or `suite`; the signer
481
+ * owns both.
482
+ *
483
+ * Foundation Law (services/api/CLAUDE.md rule 6): every truth the
484
+ * relay asserts is independently verifiable. Per-agent settlements
485
+ * deliver this through the signature; federation settlements
486
+ * additionally get Merkle-batched and onchain-anchored.
487
+ */
488
+ export declare function signSettlement(settlement: Omit<SettlementRecord, "signature" | "suite">, issuerPrivateKey: Uint8Array): Promise<SettlementRecord>;
489
+ /**
490
+ * Verify a settlement record's signature. Reconstructs canonical JSON
491
+ * over all fields except `signature` and verifies Ed25519 against the
492
+ * issuing relay's public key.
493
+ *
494
+ * The caller supplies the public key — typically resolved from the
495
+ * `issuer_relay_id` via the federation peer registry or a known-keys
496
+ * store. The signature alone proves the record was issued by the
497
+ * holder of `issuerPublicKey`; trust in that key is a separate
498
+ * concern (federation membership, key rotation chain, etc).
499
+ *
500
+ * Fail-closed on:
501
+ * - missing or unknown `suite` value
502
+ * - base64url decode errors
503
+ * - primitive-level verification failure
504
+ */
505
+ export declare function verifySettlement(settlement: SettlementRecord, issuerPublicKey: Uint8Array): Promise<boolean>;
506
+ /** The one suite KeySuccessionRecords sign under today. */
507
+ export declare const KEY_SUCCESSION_SUITE: "motebit-jcs-ed25519-hex-v1";
180
508
  /**
181
509
  * A key succession record proving that one Ed25519 key has been replaced by another.
182
510
  * Normal rotation: both old and new keys sign. Guardian recovery: guardian + new key sign.
@@ -186,6 +514,13 @@ export interface KeySuccessionRecord {
186
514
  new_public_key: string;
187
515
  timestamp: number;
188
516
  reason?: string;
517
+ /**
518
+ * Cryptosuite discriminator. Always `"motebit-jcs-ed25519-hex-v1"` —
519
+ * JCS canonicalization of the unsigned payload, Ed25519 primitive,
520
+ * hex signature encoding, hex public-key encoding. Structurally
521
+ * compatible with `@motebit/protocol` `KeySuccessionRecord`.
522
+ */
523
+ suite: typeof KEY_SUCCESSION_SUITE;
189
524
  old_key_signature?: string;
190
525
  new_key_signature: string;
191
526
  /** True when succession was authorized by guardian, not old key. */
@@ -195,6 +530,8 @@ export interface KeySuccessionRecord {
195
530
  }
196
531
  /**
197
532
  * Create a key succession record signed by both the old and new keys.
533
+ * Dispatches primitive signing through `signBySuite` per the
534
+ * `motebit-jcs-ed25519-hex-v1` suite.
198
535
  */
199
536
  export declare function signKeySuccession(oldPrivateKey: Uint8Array, newPrivateKey: Uint8Array, newPublicKey: Uint8Array, oldPublicKey: Uint8Array, reason?: string): Promise<KeySuccessionRecord>;
200
537
  /**
@@ -204,8 +541,10 @@ export declare function signKeySuccession(oldPrivateKey: Uint8Array, newPrivateK
204
541
  */
205
542
  export declare function signGuardianRecoverySuccession(guardianPrivateKey: Uint8Array, newPrivateKey: Uint8Array, oldPublicKey: Uint8Array, newPublicKey: Uint8Array, reason?: string): Promise<KeySuccessionRecord>;
206
543
  /**
207
- * Verify a key succession record. For normal rotation, checks old_key_signature + new_key_signature.
208
- * For guardian recovery (recovery: true), checks guardian_signature + new_key_signature.
544
+ * Verify a key succession record. For normal rotation, checks
545
+ * old_key_signature + new_key_signature. For guardian recovery
546
+ * (recovery: true), checks guardian_signature + new_key_signature.
547
+ * Rejects records whose `suite` is missing or not the succession suite.
209
548
  */
210
549
  export declare function verifyKeySuccession(record: KeySuccessionRecord, guardianPublicKeyHex?: string): Promise<boolean>;
211
550
  /** Result of verifying a key succession chain. */
@@ -224,9 +563,12 @@ export interface SuccessionChainResult {
224
563
  * representing a sequence of key rotations from a genesis key to the current active key.
225
564
  */
226
565
  export declare function verifySuccessionChain(chain: KeySuccessionRecord[], guardianPublicKeyHex?: string): Promise<SuccessionChainResult>;
566
+ /** Guardian revocation shares the identity-file suite (JCS + hex). */
567
+ export declare const GUARDIAN_REVOCATION_SUITE: "motebit-jcs-ed25519-hex-v1";
227
568
  /**
228
569
  * Sign a guardian revocation payload — requires BOTH identity and guardian keys.
229
570
  * Neither party can unilaterally dissolve the custody relationship.
571
+ * Dispatches the primitive through `signBySuite`.
230
572
  */
231
573
  export declare function signGuardianRevocation(identityPrivateKey: Uint8Array, guardianPrivateKey: Uint8Array, timestamp?: number): Promise<{
232
574
  payload: string;
@@ -236,33 +578,90 @@ export declare function signGuardianRevocation(identityPrivateKey: Uint8Array, g
236
578
  }>;
237
579
  /**
238
580
  * Verify a guardian revocation proof — both signatures must be valid.
581
+ * Dispatches primitive verification through `verifyBySuite`.
239
582
  */
240
583
  export declare function verifyGuardianRevocation(revocation: {
241
584
  identity_signature: string;
242
585
  guardian_signature: string;
243
586
  timestamp: number;
244
587
  }, identityPublicKeyHex: string, guardianPublicKeyHex: string): Promise<boolean>;
588
+ /** The one suite CollaborativeReceipts sign under today. */
589
+ export declare const COLLABORATIVE_RECEIPT_SUITE: "motebit-jcs-ed25519-b64-v1";
245
590
  export interface SignableCollaborativeReceipt {
246
591
  proposal_id: string;
247
592
  plan_id: string;
248
593
  participant_receipts: SignableReceipt[];
249
594
  content_hash: string;
595
+ /**
596
+ * Cryptosuite discriminator. Always `"motebit-jcs-ed25519-b64-v1"` —
597
+ * JCS canonicalization over the signing payload, Ed25519 primitive,
598
+ * base64url signature encoding. Same recipe as ExecutionReceipt.
599
+ */
600
+ suite: typeof COLLABORATIVE_RECEIPT_SUITE;
250
601
  initiator_signature: string;
251
602
  }
252
603
  /**
253
604
  * Sign a collaborative receipt. Computes a content hash over the canonical
254
- * JSON of all participant receipts, then signs the aggregate with the
255
- * initiator's Ed25519 private key.
605
+ * JSON of all participant receipts, then signs the aggregate through
606
+ * `signBySuite` under `motebit-jcs-ed25519-b64-v1`.
256
607
  */
257
- export declare function signCollaborativeReceipt(receipt: Omit<SignableCollaborativeReceipt, "content_hash" | "initiator_signature">, initiatorPrivateKey: Uint8Array): Promise<SignableCollaborativeReceipt>;
608
+ export declare function signCollaborativeReceipt(receipt: Omit<SignableCollaborativeReceipt, "content_hash" | "initiator_signature" | "suite">, initiatorPrivateKey: Uint8Array): Promise<SignableCollaborativeReceipt>;
258
609
  /**
259
610
  * Verify a collaborative receipt:
260
- * 1. Recomputes content hash from participant receipts and checks it matches.
261
- * 2. Verifies the initiator's Ed25519 signature over the aggregate.
262
- * 3. Optionally verifies each participant receipt against known keys.
611
+ * 1. Rejects any record whose `suite` is missing or not the collaborative suite.
612
+ * 2. Recomputes content hash from participant receipts and checks it matches.
613
+ * 3. Verifies the initiator's Ed25519 signature over the aggregate via `verifyBySuite`.
614
+ * 4. Optionally verifies each participant receipt against known keys.
263
615
  */
264
616
  export declare function verifyCollaborativeReceipt(receipt: SignableCollaborativeReceipt, initiatorPublicKey: Uint8Array, participantKeys?: KnownKeys): Promise<{
265
617
  valid: boolean;
266
618
  error?: string;
267
619
  }>;
620
+ /** The one suite device-registration requests sign under today. */
621
+ export declare const DEVICE_REGISTRATION_SUITE: "motebit-jcs-ed25519-b64-v1";
622
+ /**
623
+ * Shape of a device-registration request for signing/verification.
624
+ * Structurally compatible with @motebit/protocol `DeviceRegistrationRequest`.
625
+ */
626
+ export interface SignableDeviceRegistration {
627
+ motebit_id: string;
628
+ device_id: string;
629
+ public_key: string;
630
+ device_name?: string;
631
+ owner_id?: string;
632
+ timestamp: number;
633
+ suite: typeof DEVICE_REGISTRATION_SUITE;
634
+ signature: string;
635
+ }
636
+ /**
637
+ * Sign a device-registration request. Stamps the cryptosuite into the body,
638
+ * canonicalizes with JCS, dispatches the primitive signature through
639
+ * `signBySuite`, and encodes as base64url per the suite's rules.
640
+ *
641
+ * Callers pass the body without `signature` and (optionally) without `suite`;
642
+ * the signer owns both. The returned object is a complete signed request
643
+ * ready to POST to a relay's self-register endpoint.
644
+ */
645
+ export declare function signDeviceRegistration<T extends Omit<SignableDeviceRegistration, "signature" | "suite">>(body: T, privateKey: Uint8Array): Promise<T & {
646
+ suite: typeof DEVICE_REGISTRATION_SUITE;
647
+ signature: string;
648
+ }>;
649
+ /**
650
+ * Verify a device-registration request's signature against the public key
651
+ * carried in the request itself. The `now` parameter (defaulting to
652
+ * `Date.now()`) lets tests pin the clock for replay-window assertions; in
653
+ * production callers pass the relay's wall-clock at request receipt.
654
+ *
655
+ * Returns a discriminated reason on failure so callers can map to wire-level
656
+ * status codes (per `spec/device-self-registration-v1.md` §5.1).
657
+ */
658
+ export type DeviceRegistrationVerifyResult = {
659
+ valid: true;
660
+ } | {
661
+ valid: false;
662
+ reason: "malformed" | "stale" | "unsupported_suite" | "bad_signature";
663
+ };
664
+ /** Maximum drift between the signer's claimed timestamp and the verifier's clock. */
665
+ export declare const DEVICE_REGISTRATION_MAX_AGE_MS: number;
666
+ export declare function verifyDeviceRegistration(body: SignableDeviceRegistration, now?: number): Promise<DeviceRegistrationVerifyResult>;
268
667
  //# sourceMappingURL=artifacts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"artifacts.d.ts","sourceRoot":"","sources":["../src/artifacts.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAgBH;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,U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