@t3foundry/tasra-sdk 0.3.1 → 0.4.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 (255) hide show
  1. package/CHANGELOG.md +1067 -28
  2. package/README.md +15 -0
  3. package/dist/app/approvals.d.ts +66 -4
  4. package/dist/app/approvals.js +153 -16
  5. package/dist/app/authorization.d.ts +1 -1
  6. package/dist/app/authorization.js +1 -1
  7. package/dist/app/browser.d.ts +63 -0
  8. package/dist/app/browser.js +242 -0
  9. package/dist/app/client.d.ts +114 -13
  10. package/dist/app/client.js +302 -76
  11. package/dist/app/identity.js +21 -9
  12. package/dist/app/index.d.ts +28 -3
  13. package/dist/app/index.js +16 -1
  14. package/dist/app/memory-store.d.ts +7 -0
  15. package/dist/app/memory-store.js +55 -0
  16. package/dist/app/node.d.ts +34 -6
  17. package/dist/app/node.js +387 -64
  18. package/dist/app/paid-allowance.d.ts +325 -0
  19. package/dist/app/paid-allowance.js +1290 -0
  20. package/dist/app/paid-approval.d.ts +122 -0
  21. package/dist/app/paid-approval.js +379 -0
  22. package/dist/app/paid-journal.d.ts +51 -0
  23. package/dist/app/paid-journal.js +117 -0
  24. package/dist/app/paid-keys.d.ts +12 -0
  25. package/dist/app/paid-keys.js +20 -0
  26. package/dist/app/paid-operation.d.ts +821 -0
  27. package/dist/app/paid-operation.js +1720 -0
  28. package/dist/app/paid-reservation.d.ts +157 -0
  29. package/dist/app/paid-reservation.js +323 -0
  30. package/dist/app/paid-session.d.ts +147 -0
  31. package/dist/app/paid-session.js +578 -0
  32. package/dist/app/payer-queue.d.ts +11 -0
  33. package/dist/app/payer-queue.js +27 -0
  34. package/dist/app/policy-bootstrap.d.ts +342 -0
  35. package/dist/app/policy-bootstrap.js +365 -0
  36. package/dist/app/policy-operation.d.ts +47 -0
  37. package/dist/app/policy-operation.js +101 -0
  38. package/dist/app/ready-slot.d.ts +12 -0
  39. package/dist/app/ready-slot.js +5 -2
  40. package/dist/app/rotation-lock.d.ts +38 -0
  41. package/dist/app/rotation-lock.js +42 -0
  42. package/dist/app/session-decrypt.d.ts +135 -0
  43. package/dist/app/session-decrypt.js +335 -0
  44. package/dist/app/session-grants.d.ts +349 -0
  45. package/dist/app/session-grants.js +811 -0
  46. package/dist/app/signing-intents.d.ts +78 -0
  47. package/dist/app/signing-intents.js +95 -0
  48. package/dist/app/store-commit.d.ts +63 -0
  49. package/dist/app/store-commit.js +126 -0
  50. package/dist/app/store-errors.d.ts +8 -0
  51. package/dist/app/store-errors.js +11 -0
  52. package/dist/app/tasra-client.d.ts +2 -0
  53. package/dist/app/tasra-client.js +1 -1
  54. package/dist/app/wallet.js +4 -1
  55. package/dist/auth/holderProof.d.ts +3 -0
  56. package/dist/auth/holderProof.js +8 -7
  57. package/dist/auth/verifier.d.ts +4 -2
  58. package/dist/auth/verifier.js +5 -2
  59. package/dist/chain/abis/index.d.ts +6178 -4101
  60. package/dist/chain/abis/index.js +3 -0
  61. package/dist/chain/abis/keyRegistry.d.ts +256 -0
  62. package/dist/chain/abis/keyRegistry.js +333 -0
  63. package/dist/chain/abis/prepaidFaultOracle.d.ts +321 -0
  64. package/dist/chain/abis/prepaidFaultOracle.js +413 -0
  65. package/dist/chain/abis/settlement.d.ts +2203 -703
  66. package/dist/chain/abis/settlement.js +2685 -764
  67. package/dist/chain/allowance.d.ts +358 -0
  68. package/dist/chain/allowance.js +800 -0
  69. package/dist/chain/billing.d.ts +85 -0
  70. package/dist/chain/billing.js +197 -0
  71. package/dist/chain/chainId.d.ts +13 -0
  72. package/dist/chain/chainId.js +26 -0
  73. package/dist/chain/client.d.ts +15 -1
  74. package/dist/chain/client.js +57 -1
  75. package/dist/chain/commitmentRecovery.d.ts +51 -0
  76. package/dist/chain/commitmentRecovery.js +38 -0
  77. package/dist/chain/committeeClient.d.ts +17 -10
  78. package/dist/chain/committeeClient.js +64 -16
  79. package/dist/chain/committeeDraw.d.ts +12 -0
  80. package/dist/chain/committeeDraw.js +56 -0
  81. package/dist/chain/custodyHealth.d.ts +212 -0
  82. package/dist/chain/custodyHealth.js +365 -0
  83. package/dist/chain/deployments.js +2 -0
  84. package/dist/chain/events.js +2 -0
  85. package/dist/chain/headFollower.d.ts +77 -0
  86. package/dist/chain/headFollower.js +219 -0
  87. package/dist/chain/headPrefetch.d.ts +23 -0
  88. package/dist/chain/headPrefetch.js +67 -0
  89. package/dist/chain/index.d.ts +50 -8
  90. package/dist/chain/index.js +28 -3
  91. package/dist/chain/keeperExecution.d.ts +44 -0
  92. package/dist/chain/keeperExecution.js +127 -0
  93. package/dist/chain/keeperRecovery.d.ts +78 -0
  94. package/dist/chain/keeperRecovery.js +91 -0
  95. package/dist/chain/node.d.ts +24 -1
  96. package/dist/chain/node.js +88 -43
  97. package/dist/chain/offchain.d.ts +2 -0
  98. package/dist/chain/paidAgentTransport.d.ts +38 -0
  99. package/dist/chain/paidAgentTransport.js +1 -0
  100. package/dist/chain/paidEpoch.d.ts +66 -0
  101. package/dist/chain/paidEpoch.js +139 -0
  102. package/dist/chain/paidPacing.d.ts +81 -0
  103. package/dist/chain/paidPacing.js +136 -0
  104. package/dist/chain/pinnedReads.d.ts +49 -0
  105. package/dist/chain/pinnedReads.js +218 -0
  106. package/dist/chain/prepaid.d.ts +383 -0
  107. package/dist/chain/prepaid.js +1046 -0
  108. package/dist/chain/prepaidEscape.d.ts +274 -0
  109. package/dist/chain/prepaidEscape.js +432 -0
  110. package/dist/chain/prepaidFault.d.ts +94 -0
  111. package/dist/chain/prepaidFault.js +148 -0
  112. package/dist/chain/receipt.d.ts +24 -0
  113. package/dist/chain/receipt.js +82 -0
  114. package/dist/chain/registeredAgent.d.ts +68 -3
  115. package/dist/chain/registeredAgent.js +143 -42
  116. package/dist/chain/registeredOperation.d.ts +10 -1
  117. package/dist/chain/registeredOperation.js +18 -3
  118. package/dist/chain/registeredPaidAgent.d.ts +254 -0
  119. package/dist/chain/registeredPaidAgent.js +889 -0
  120. package/dist/chain/registeredRelay.d.ts +31 -1
  121. package/dist/chain/registeredRelay.js +164 -43
  122. package/dist/chain/relayVoucher.d.ts +64 -0
  123. package/dist/chain/relayVoucher.js +69 -0
  124. package/dist/chain/reservation.d.ts +239 -0
  125. package/dist/chain/reservation.js +746 -0
  126. package/dist/chain/reshareRoster.d.ts +64 -0
  127. package/dist/chain/reshareRoster.js +85 -0
  128. package/dist/chain/revertReason.d.ts +8 -0
  129. package/dist/chain/revertReason.js +2 -1
  130. package/dist/chain/rotationLock.d.ts +130 -0
  131. package/dist/chain/rotationLock.js +168 -0
  132. package/dist/chain/serviceRequestPolicy.d.ts +47 -0
  133. package/dist/chain/serviceRequestPolicy.js +86 -0
  134. package/dist/chain/services.d.ts +7 -0
  135. package/dist/chain/services.js +44 -4
  136. package/dist/chain/slotClient.js +11 -2
  137. package/dist/chain/slotHandoff.d.ts +81 -0
  138. package/dist/chain/slotHandoff.js +166 -0
  139. package/dist/chain/slotSeed.d.ts +47 -5
  140. package/dist/chain/slotSeed.js +173 -42
  141. package/dist/chain/verifierSnapshot.d.ts +36 -0
  142. package/dist/chain/verifierSnapshot.js +197 -0
  143. package/dist/chain/write.d.ts +111 -21
  144. package/dist/chain/write.js +378 -146
  145. package/dist/committee/blsSharing.d.ts +53 -0
  146. package/dist/committee/blsSharing.js +90 -0
  147. package/dist/committee/client.d.ts +62 -23
  148. package/dist/committee/client.js +288 -72
  149. package/dist/committee/dual-operation.d.ts +165 -0
  150. package/dist/committee/dual-operation.js +229 -0
  151. package/dist/committee/dual-sign.d.ts +26 -1
  152. package/dist/committee/dual-sign.js +85 -7
  153. package/dist/committee/ecdsa.d.ts +38 -0
  154. package/dist/committee/ecdsa.js +87 -15
  155. package/dist/committee/evidence.d.ts +30 -0
  156. package/dist/committee/evidence.js +65 -0
  157. package/dist/committee/execution.d.ts +414 -0
  158. package/dist/committee/execution.js +446 -0
  159. package/dist/committee/extraction.js +33 -26
  160. package/dist/committee/index.d.ts +30 -7
  161. package/dist/committee/index.js +18 -6
  162. package/dist/committee/keeperExecution.d.ts +37 -0
  163. package/dist/committee/keeperExecution.js +141 -0
  164. package/dist/committee/oauth.d.ts +14 -4
  165. package/dist/committee/oauth.js +17 -5
  166. package/dist/committee/payment.d.ts +369 -0
  167. package/dist/committee/payment.js +339 -0
  168. package/dist/committee/recovery.d.ts +136 -0
  169. package/dist/committee/recovery.js +204 -0
  170. package/dist/committee/recoveryJson.d.ts +2 -0
  171. package/dist/committee/recoveryJson.js +87 -0
  172. package/dist/committee/request.d.ts +63 -27
  173. package/dist/committee/request.js +77 -66
  174. package/dist/committee/session-grant.d.ts +320 -0
  175. package/dist/committee/session-grant.js +397 -0
  176. package/dist/committee/status-refresh.d.ts +257 -0
  177. package/dist/committee/status-refresh.js +619 -0
  178. package/dist/committee/token.d.ts +163 -15
  179. package/dist/committee/token.js +247 -10
  180. package/dist/crypto/bn254.d.ts +70 -0
  181. package/dist/crypto/bn254.js +222 -0
  182. package/dist/crypto/ibe.d.ts +32 -0
  183. package/dist/crypto/ibe.js +56 -8
  184. package/dist/crypto/index.d.ts +1 -1
  185. package/dist/crypto/index.js +1 -1
  186. package/dist/crypto/kem.d.ts +31 -0
  187. package/dist/crypto/kem.js +113 -7
  188. package/dist/crypto/recipient.d.ts +75 -0
  189. package/dist/crypto/recipient.js +107 -0
  190. package/dist/decryption/client.d.ts +10 -16
  191. package/dist/decryption/client.js +8 -76
  192. package/dist/decryption/index.d.ts +2 -0
  193. package/dist/decryption/index.js +2 -0
  194. package/dist/decryption/sealed.d.ts +72 -0
  195. package/dist/decryption/sealed.js +147 -0
  196. package/dist/decryption/session.d.ts +115 -0
  197. package/dist/decryption/session.js +358 -0
  198. package/dist/errors.d.ts +406 -1
  199. package/dist/errors.js +400 -5
  200. package/dist/index.d.ts +9 -2
  201. package/dist/index.js +6 -1
  202. package/dist/internal/bounded.d.ts +66 -0
  203. package/dist/internal/bounded.js +126 -0
  204. package/dist/internal/network.d.ts +4 -0
  205. package/dist/internal/network.js +40 -0
  206. package/dist/internal/retryAfter.d.ts +8 -0
  207. package/dist/internal/retryAfter.js +28 -0
  208. package/dist/internal/sleep.d.ts +6 -0
  209. package/dist/internal/sleep.js +15 -0
  210. package/dist/internal/typedData.d.ts +13 -0
  211. package/dist/internal/typedData.js +77 -0
  212. package/dist/internal/viemErrors.d.ts +26 -0
  213. package/dist/internal/viemErrors.js +49 -0
  214. package/dist/oid4vp/binding.d.ts +27 -1
  215. package/dist/oid4vp/binding.js +36 -1
  216. package/dist/oid4vp/jose.d.ts +4 -2
  217. package/dist/oid4vp/jose.js +39 -7
  218. package/dist/oid4vp/request-object.d.ts +61 -4
  219. package/dist/oid4vp/request-object.js +140 -5
  220. package/dist/oid4vp/verifier-agent.d.ts +18 -8
  221. package/dist/oid4vp/verifier-agent.js +48 -6
  222. package/dist/oid4vp/wallet.d.ts +2 -4
  223. package/dist/oid4vp/wallet.js +1 -0
  224. package/dist/retry.d.ts +78 -0
  225. package/dist/retry.js +137 -0
  226. package/dist/signing/frost.d.ts +1 -1
  227. package/dist/verifier-agent/index.d.ts +41 -5
  228. package/dist/verifier-agent/index.js +124 -9
  229. package/dist/verifier-agent/payment.d.ts +7 -0
  230. package/dist/verifier-agent/payment.js +17 -0
  231. package/docs/api.md +8 -2
  232. package/docs/application-api.md +25 -2
  233. package/docs/chain.md +155 -9
  234. package/docs/consumer-migrations.md +61 -0
  235. package/docs/encrypted-notes.md +3 -2
  236. package/docs/encryption.md +4 -2
  237. package/docs/errors.md +14 -1
  238. package/docs/flows.md +2 -2
  239. package/docs/funding.md +902 -0
  240. package/docs/native-approvals.md +63 -0
  241. package/docs/reference/README.md +9 -8
  242. package/docs/reference/app-browser.md +232 -0
  243. package/docs/reference/app-node.md +38 -8
  244. package/docs/reference/app.md +4621 -805
  245. package/docs/reference/chain-node.md +74 -16
  246. package/docs/reference/chain.md +6740 -1592
  247. package/docs/reference/committee.md +5630 -987
  248. package/docs/reference/main.md +1439 -140
  249. package/docs/reference/oid4vp.md +297 -144
  250. package/docs/reference/verifier-agent.md +77 -35
  251. package/docs/signing.md +6 -0
  252. package/examples/encrypted-notes.ts +21 -6
  253. package/examples/getting-started.ts +2 -7
  254. package/examples/live-config.ts +24 -17
  255. package/package.json +17 -5
@@ -0,0 +1,85 @@
1
+ import { type Address, type Hex, type PublicClient } from 'viem';
2
+ import { TasraError } from '../errors.js';
3
+ /** Billing a slot uses; `unknown` means the chain could not be read consistently. */
4
+ export type BillingMode = 'legacy' | 'prepaid' | 'unknown';
5
+ /** One consistent observation of a slot's billing mode. */
6
+ export interface BillingModeObservation {
7
+ /** Slot identifier. */
8
+ slot: Hex;
9
+ /** Detected billing. `unknown` never authorizes either flow. */
10
+ mode: BillingMode;
11
+ /** `Settlement.version()` when read. */
12
+ settlementVersion?: string;
13
+ /** `prepaidEnabled(slot)` when read (prepaid versions "2" and "3" only). */
14
+ prepaidEnabled?: boolean;
15
+ /** `prepaidFromGenesis()` when read (prepaid versions "2" and "3" only). */
16
+ prepaidFromGenesis?: boolean;
17
+ /** Block every value was read at, when the read completed. */
18
+ blockNumber?: bigint;
19
+ /** Hash of that block, rechecked after all reads. */
20
+ blockHash?: Hex;
21
+ /** Why the mode is unknown; safe for logs (no response bodies). */
22
+ reason?: string;
23
+ }
24
+ /** Chain and Settlement proxy whose billing is detected; independently approved by the application. */
25
+ export interface BillingDeployment {
26
+ /** Expected EVM chain ID. */
27
+ chainId: number;
28
+ /** Expected Settlement proxy. */
29
+ settlement: Address;
30
+ }
31
+ /** A paid entry point was asked to act on a slot that is not (or not knowably) prepaid. */
32
+ export declare class BillingModeError extends TasraError {
33
+ /** Slot the paid operation was refused for. */
34
+ readonly slotId: Hex;
35
+ /** Detected mode: `legacy` (use the unpaid flow) or `unknown` (resolve the chain read first). */
36
+ readonly mode: Exclude<BillingMode, 'prepaid'>;
37
+ /** Settlement implementation version, when read. */
38
+ readonly settlementVersion?: string;
39
+ constructor(observation: BillingModeObservation & {
40
+ mode: Exclude<BillingMode, 'prepaid'>;
41
+ });
42
+ }
43
+ /** True for a `Settlement.version()` with prepaid billing ("2", "3" or "4"); any other answer is not. */
44
+ export declare function isPrepaidSettlementVersion(version: unknown): boolean;
45
+ /**
46
+ * Read a slot's billing mode at one block: version "1" is legacy; version "2" or "3" (the
47
+ * same prepaid billing plus the payer timeout escape) is prepaid when
48
+ * `prepaidEnabled(slot)` or `prepaidFromGenesis()` holds (an unfunded slot on a prepaid-from-genesis
49
+ * deployment becomes prepaid at its first funding, and legacy settlement refuses it), otherwise
50
+ * legacy until cutover. Any other version, a failed read, a chain mismatch or a reorganized block
51
+ * is `unknown`. Never throws for a chain failure; throws only for invalid arguments.
52
+ * @param client Trusted RPC client for the independently selected deployment.
53
+ * @param deployment Approved chain ID and Settlement proxy.
54
+ * @param slot Slot whose billing is required.
55
+ */
56
+ export declare function readBillingMode(client: PublicClient, deployment: BillingDeployment, slot: Hex): Promise<BillingModeObservation>;
57
+ /** Per-slot cached billing detection for one deployment. */
58
+ export interface BillingModeDetector {
59
+ /** Current mode, from cache when fresh. `unknown` is never cached. */
60
+ mode(slot: Hex): Promise<BillingModeObservation>;
61
+ /** Resolve the mode and return it only when prepaid; otherwise throw {@link BillingModeError}. */
62
+ requirePrepaid(slot: Hex): Promise<BillingModeObservation>;
63
+ /** Forget one slot, or every slot, e.g. after an operator announces a Settlement upgrade. */
64
+ invalidate(slot?: Hex): void;
65
+ }
66
+ /**
67
+ * Cache billing per slot for one deployment. Prepaid is one-way for a slot (`prepaidEnabled` is
68
+ * never cleared), so it is cached until invalidated; legacy can become prepaid at a funding or
69
+ * cutover, so it expires after `legacyTtlMs`. Concurrent lookups for a slot share one read.
70
+ * @param client Trusted RPC client for the deployment.
71
+ * @param deployment Approved chain ID and Settlement proxy.
72
+ * @param options Legacy cache lifetime in ms (default 60000, 0 disables) and a clock for tests.
73
+ */
74
+ export declare function createBillingModeDetector(client: PublicClient, deployment: BillingDeployment, options?: {
75
+ legacyTtlMs?: number;
76
+ now?: () => number;
77
+ }): BillingModeDetector;
78
+ /**
79
+ * One-shot guard for a paid entry point: resolve the slot's mode and throw
80
+ * {@link BillingModeError} unless it is prepaid.
81
+ * @param client Trusted RPC client for the deployment.
82
+ * @param deployment Approved chain ID and Settlement proxy.
83
+ * @param slot Slot about to be charged.
84
+ */
85
+ export declare function requirePrepaidSlot(client: PublicClient, deployment: BillingDeployment, slot: Hex): Promise<BillingModeObservation>;
@@ -0,0 +1,197 @@
1
+ // Which billing a slot uses, read from the chain and never guessed.
2
+ //
3
+ // A legacy deployment (Settlement.version() == "1", e.g. tasra.fuji.v1) bills by usage
4
+ // metering; the keeper accepts unpaid committee operations. A prepaid deployment ("2", or "3"
5
+ // which adds only the payer's timeout escape) bills each operation from a reservation, and a slot is prepaid once `prepaidEnabled`
6
+ // is set: by its first `fund()` on a prepaid-from-genesis deployment, or by a cutover on
7
+ // an upgraded one. Nothing off-chain (keeper /v1/info, the network manifest) reports
8
+ // this, so the only source of truth is the Settlement contract.
9
+ //
10
+ // The detector answers `unknown` whenever it cannot read a consistent answer. Callers
11
+ // must treat `unknown` as "do not start": a paid flow against a legacy slot is refused by
12
+ // every service, and a legacy flow against a prepaid slot is refused by the keepers.
13
+ import { decodeFunctionResult, encodeFunctionData, parseAbi } from 'viem';
14
+ import { TasraError } from '../errors.js';
15
+ import { chainIdOf } from './chainId.js';
16
+ /** A paid entry point was asked to act on a slot that is not (or not knowably) prepaid. */
17
+ export class BillingModeError extends TasraError {
18
+ /** Slot the paid operation was refused for. */
19
+ slotId;
20
+ /** Detected mode: `legacy` (use the unpaid flow) or `unknown` (resolve the chain read first). */
21
+ mode;
22
+ /** Settlement implementation version, when read. */
23
+ settlementVersion;
24
+ constructor(observation) {
25
+ super(observation.mode === 'legacy'
26
+ ? `Slot ${observation.slot} uses legacy (metered) billing on Settlement version ${observation.settlementVersion ?? '?'}; paid operations are unavailable, use the legacy flow`
27
+ : `Billing mode of slot ${observation.slot} is unknown (${observation.reason ?? 'unreadable'}); no paid operation was started`, { retryable: observation.mode === 'unknown' });
28
+ this.slotId = observation.slot;
29
+ this.mode = observation.mode;
30
+ if (observation.settlementVersion !== undefined)
31
+ this.settlementVersion = observation.settlementVersion;
32
+ }
33
+ }
34
+ // Minimal fragments so the probe also reads a legacy (version 1) Settlement, whose ABI has no prepaid getters.
35
+ const probeAbi = parseAbi([
36
+ 'function version() view returns (string)',
37
+ 'function prepaidEnabled(bytes32 slot) view returns (bool)',
38
+ 'function prepaidFromGenesis() view returns (bool)',
39
+ ]);
40
+ /** Settlement versions with prepaid billing. "3" adds only the payer timeout escape; "4" adds only the prepaid
41
+ * allowances beside the unchanged per-request path; "5" adds only allowance range settlement (a
42
+ * range-settled voucher is settled by the allowance's settled seq, read by the backing checks). Any other
43
+ * version is unknown. */
44
+ const PREPAID_SETTLEMENT_VERSIONS = new Set(['2', '3', '4', '5']);
45
+ /** True for a `Settlement.version()` with prepaid billing ("2", "3" or "4"); any other answer is not. */
46
+ export function isPrepaidSettlementVersion(version) {
47
+ return typeof version === 'string' && PREPAID_SETTLEMENT_VERSIONS.has(version);
48
+ }
49
+ const HEX32 = /^0x[0-9a-f]{64}$/i;
50
+ const ADDRESS = /^0x[0-9a-f]{40}$/i;
51
+ function validate(deployment, slot) {
52
+ if (!Number.isSafeInteger(deployment.chainId) || deployment.chainId <= 0
53
+ || typeof deployment.settlement !== 'string' || !ADDRESS.test(deployment.settlement) || /^0x0{40}$/i.test(deployment.settlement))
54
+ throw new TasraError('Invalid billing deployment');
55
+ if (typeof slot !== 'string' || !HEX32.test(slot))
56
+ throw new TasraError('Invalid billing slot');
57
+ }
58
+ function unknown(slot, reason, extra = {}) {
59
+ return { ...extra, slot, mode: 'unknown', reason };
60
+ }
61
+ function reasonOf(error) {
62
+ const text = error instanceof Error ? error.message.split('\n')[0] ?? '' : 'read failed';
63
+ return text.slice(0, 160) || 'read failed';
64
+ }
65
+ /**
66
+ * Read a slot's billing mode at one block: version "1" is legacy; version "2" or "3" (the
67
+ * same prepaid billing plus the payer timeout escape) is prepaid when
68
+ * `prepaidEnabled(slot)` or `prepaidFromGenesis()` holds (an unfunded slot on a prepaid-from-genesis
69
+ * deployment becomes prepaid at its first funding, and legacy settlement refuses it), otherwise
70
+ * legacy until cutover. Any other version, a failed read, a chain mismatch or a reorganized block
71
+ * is `unknown`. Never throws for a chain failure; throws only for invalid arguments.
72
+ * @param client Trusted RPC client for the independently selected deployment.
73
+ * @param deployment Approved chain ID and Settlement proxy.
74
+ * @param slot Slot whose billing is required.
75
+ */
76
+ export async function readBillingMode(client, deployment, slot) {
77
+ const d = { chainId: deployment.chainId, settlement: deployment.settlement };
78
+ validate(d, slot);
79
+ let blockNumber, blockHash;
80
+ try {
81
+ if (await chainIdOf(client) !== d.chainId)
82
+ return unknown(slot, 'RPC chain mismatch');
83
+ const block = await client.getBlock({ blockTag: 'latest' });
84
+ if (block.number === null || block.hash === null || !HEX32.test(block.hash))
85
+ return unknown(slot, 'canonical head unavailable');
86
+ blockNumber = block.number;
87
+ blockHash = block.hash;
88
+ }
89
+ catch (error) {
90
+ return unknown(slot, reasonOf(error));
91
+ }
92
+ // EIP-1898 reads pinned to the observed block hash, like every other prepaid read.
93
+ const read = async (functionName, args = []) => {
94
+ const data = encodeFunctionData({ abi: probeAbi, functionName, args });
95
+ const result = await client.call({ to: d.settlement, data, blockHash, requireCanonical: true, batch: false });
96
+ if (result.data === undefined || result.data === '0x')
97
+ throw new Error(`empty ${functionName} response`);
98
+ return decodeFunctionResult({ abi: probeAbi, functionName, data: result.data });
99
+ };
100
+ const observed = {};
101
+ let mode;
102
+ try {
103
+ const version = await read('version');
104
+ if (typeof version !== 'string' || version.length > 32)
105
+ return unknown(slot, 'invalid Settlement version');
106
+ observed.settlementVersion = version;
107
+ if (version === '1')
108
+ mode = 'legacy';
109
+ else if (isPrepaidSettlementVersion(version)) {
110
+ const enabled = await read('prepaidEnabled', [slot]);
111
+ if (typeof enabled !== 'boolean')
112
+ return unknown(slot, 'invalid prepaidEnabled', observed);
113
+ observed.prepaidEnabled = enabled;
114
+ if (enabled)
115
+ mode = 'prepaid';
116
+ else {
117
+ const genesis = await read('prepaidFromGenesis');
118
+ if (typeof genesis !== 'boolean')
119
+ return unknown(slot, 'invalid prepaidFromGenesis', observed);
120
+ observed.prepaidFromGenesis = genesis;
121
+ mode = genesis ? 'prepaid' : 'legacy';
122
+ }
123
+ }
124
+ else
125
+ return unknown(slot, `unsupported Settlement version ${JSON.stringify(version)}`, observed);
126
+ // Every value above was read at one block; refuse a mixture across a reorganization.
127
+ const canonical = await client.getBlock({ blockNumber });
128
+ if (canonical.hash?.toLowerCase() !== blockHash.toLowerCase())
129
+ return unknown(slot, 'block reorganized during reads', observed);
130
+ }
131
+ catch (error) {
132
+ return unknown(slot, reasonOf(error), observed);
133
+ }
134
+ return { ...observed, slot, mode, blockNumber, blockHash };
135
+ }
136
+ /**
137
+ * Cache billing per slot for one deployment. Prepaid is one-way for a slot (`prepaidEnabled` is
138
+ * never cleared), so it is cached until invalidated; legacy can become prepaid at a funding or
139
+ * cutover, so it expires after `legacyTtlMs`. Concurrent lookups for a slot share one read.
140
+ * @param client Trusted RPC client for the deployment.
141
+ * @param deployment Approved chain ID and Settlement proxy.
142
+ * @param options Legacy cache lifetime in ms (default 60000, 0 disables) and a clock for tests.
143
+ */
144
+ export function createBillingModeDetector(client, deployment, options = {}) {
145
+ const d = { chainId: deployment.chainId, settlement: deployment.settlement };
146
+ validate(d, `0x${'00'.repeat(32)}`);
147
+ const ttl = options.legacyTtlMs ?? 60_000, now = options.now ?? Date.now;
148
+ if (!Number.isSafeInteger(ttl) || ttl < 0 || ttl > 86_400_000)
149
+ throw new TasraError('Invalid billing cache lifetime');
150
+ const cache = new Map();
151
+ const inflight = new Map();
152
+ const mode = (slot) => {
153
+ validate(d, slot);
154
+ const key = slot.toLowerCase(), hit = cache.get(key);
155
+ if (hit && now() < hit.until)
156
+ return Promise.resolve(structuredClone(hit.value));
157
+ const running = inflight.get(key);
158
+ if (running)
159
+ return running.then(v => structuredClone(v));
160
+ const read = readBillingMode(client, d, slot).then(value => {
161
+ if (value.mode === 'prepaid')
162
+ cache.set(key, { value, until: Number.POSITIVE_INFINITY });
163
+ else if (value.mode === 'legacy' && ttl > 0)
164
+ cache.set(key, { value, until: now() + ttl });
165
+ else
166
+ cache.delete(key);
167
+ return value;
168
+ }).finally(() => inflight.delete(key));
169
+ inflight.set(key, read);
170
+ return read.then(v => structuredClone(v));
171
+ };
172
+ return Object.freeze({ mode,
173
+ async requirePrepaid(slot) {
174
+ const observed = await mode(slot);
175
+ if (observed.mode !== 'prepaid')
176
+ throw new BillingModeError({ ...observed, mode: observed.mode });
177
+ return observed;
178
+ },
179
+ invalidate(slot) { if (slot === undefined)
180
+ cache.clear();
181
+ else
182
+ cache.delete(String(slot).toLowerCase()); },
183
+ });
184
+ }
185
+ /**
186
+ * One-shot guard for a paid entry point: resolve the slot's mode and throw
187
+ * {@link BillingModeError} unless it is prepaid.
188
+ * @param client Trusted RPC client for the deployment.
189
+ * @param deployment Approved chain ID and Settlement proxy.
190
+ * @param slot Slot about to be charged.
191
+ */
192
+ export async function requirePrepaidSlot(client, deployment, slot) {
193
+ const observed = await readBillingMode(client, deployment, slot);
194
+ if (observed.mode !== 'prepaid')
195
+ throw new BillingModeError({ ...observed, mode: observed.mode });
196
+ return observed;
197
+ }
@@ -0,0 +1,13 @@
1
+ interface ChainIdSource {
2
+ getChainId(): Promise<number>;
3
+ transport?: {
4
+ type?: string;
5
+ };
6
+ }
7
+ /**
8
+ * The chain ID `client`'s RPC answers: kept per client for an HTTP or WebSocket transport, read
9
+ * afresh for any other. Rejections are not kept.
10
+ * @param client viem public or wallet client.
11
+ */
12
+ export declare function chainIdOf(client: ChainIdSource): Promise<number>;
13
+ export {};
@@ -0,0 +1,26 @@
1
+ // The chain ID behind a client, asked once per client instead of before every paid read.
2
+ //
3
+ // An HTTP or WebSocket transport is bound to one RPC URL for the client's lifetime, and the chain
4
+ // behind it does not change under that client, so its answer is kept with the client (a WeakMap:
5
+ // it lives exactly as long as the client). Every other transport - an injected EIP-1193 wallet can
6
+ // switch chains at any moment - is asked on every call, as before. A failed read is never kept: the
7
+ // next caller asks again. Callers still compare the answer with the expected chain on every use.
8
+ const FIXED_URL_TRANSPORTS = new Set(['http', 'webSocket']);
9
+ const known = new WeakMap();
10
+ /**
11
+ * The chain ID `client`'s RPC answers: kept per client for an HTTP or WebSocket transport, read
12
+ * afresh for any other. Rejections are not kept.
13
+ * @param client viem public or wallet client.
14
+ */
15
+ export function chainIdOf(client) {
16
+ if (!FIXED_URL_TRANSPORTS.has(client.transport?.type ?? ''))
17
+ return client.getChainId();
18
+ const cached = known.get(client);
19
+ if (cached)
20
+ return cached;
21
+ const read = client.getChainId();
22
+ known.set(client, read);
23
+ read.catch(() => { if (known.get(client) === read)
24
+ known.delete(client); });
25
+ return read;
26
+ }
@@ -27,9 +27,23 @@ export interface ChainClientConfig {
27
27
  /** getLogs block-window size; keep <= the RPC's range cap (anvil/besu: large; public: ~2k). */
28
28
  logWindow?: number;
29
29
  /**
30
- * Multicall3 address for batching. Omit to probe the canonical address, supply an explicit address to probe that deployment, or set false to disable batching. Unavailable batching falls back to individual reads.
30
+ * Multicall3 address for batching. Omit to probe the canonical address, supply an explicit address to probe that deployment, or set false to disable batching. Unavailable batching falls back to individual reads. Block-pinned paid-operation reads batch through it only where its code matches the canonical Multicall3.
31
31
  */
32
32
  multicall3?: Address | false;
33
+ /**
34
+ * JSON-RPC batching for small requests (calls, chain ID, blocks, code, nonces): requests issued
35
+ * together share one HTTP request of at most `batchSize` (default 32, at most 1000) after
36
+ * waiting `wait` milliseconds (default 0, at most 100). Each request keeps its own result and
37
+ * error. Log queries and transactions are never batched. Set false for an RPC without batches.
38
+ */
39
+ rpcBatch?: RpcBatchOptions | false;
40
+ }
41
+ /** Bounds of one JSON-RPC batch. */
42
+ export interface RpcBatchOptions {
43
+ /** Most requests in one HTTP request. */
44
+ batchSize?: number;
45
+ /** Milliseconds to collect requests before sending. */
46
+ wait?: number;
33
47
  }
34
48
  /**
35
49
  * Controls whether a failed contract read rejects the batch or leaves a null result.
@@ -6,6 +6,7 @@
6
6
  //
7
7
  // Read-only: no wallet, no signing. The explorer never writes to the chain.
8
8
  import { createPublicClient, http, defineChain, } from 'viem';
9
+ import { configurePinnedReads } from './pinnedReads.js';
9
10
  import { CONTRACT_ABIS } from './abis/index.js';
10
11
  import { createServiceRegistryReaders } from './services.js';
11
12
  import { nodeRegistryAbi } from './abis/nodeRegistry.js';
@@ -34,6 +35,59 @@ import { decodeContractLogs } from './events.js';
34
35
  const MULTICALL_BATCH_BYTES = 32_768;
35
36
  /** Multicall3's canonical, deterministic-deployment address. */
36
37
  export const MULTICALL3_ADDRESS = '0xcA11bde05977b3631167028862bE2a173976CA11';
38
+ /** Methods whose requests and answers are small; everything else goes alone. */
39
+ const BATCHED_METHODS = new Set(['eth_call', 'eth_chainId', 'eth_blockNumber', 'eth_getBlockByNumber', 'eth_getBlockByHash',
40
+ 'eth_getCode', 'eth_getBalance', 'eth_getStorageAt', 'eth_getTransactionCount', 'eth_getTransactionReceipt']);
41
+ /** HTTP transport that sends the small methods in bounded JSON-RPC batches and the rest alone. */
42
+ function rpcTransport(url, batch) {
43
+ const plain = http(url);
44
+ if (batch === false)
45
+ return plain;
46
+ const batchSize = batch?.batchSize ?? 32, wait = batch?.wait ?? 0;
47
+ if (!Number.isSafeInteger(batchSize) || batchSize < 1 || batchSize > 1000)
48
+ throw new Error('rpcBatch.batchSize must be an integer from 1 to 1000');
49
+ if (!Number.isSafeInteger(wait) || wait < 0 || wait > 100)
50
+ throw new Error('rpcBatch.wait must be an integer from 0 to 100 milliseconds');
51
+ // An RPC that does not answer batches (a single object, or a 4xx, for an array) is detected on
52
+ // its first batch: that batch's requests are sent one by one and answered as the batch would
53
+ // have been, and every later request goes alone.
54
+ let batches = true;
55
+ const fetchFn = async (input, init) => {
56
+ const send = globalThis.fetch;
57
+ const entries = typeof init?.body === 'string' && init.body.startsWith('[') ? JSON.parse(init.body) : undefined;
58
+ if (!entries)
59
+ return send(input, init);
60
+ if (batches) {
61
+ const response = await send(input, init);
62
+ const text = await response.text();
63
+ let answer;
64
+ try {
65
+ answer = JSON.parse(text);
66
+ }
67
+ catch {
68
+ answer = undefined;
69
+ }
70
+ if (Array.isArray(answer) || response.status >= 500 || (response.ok && answer === undefined)) {
71
+ return new Response(text, { status: response.status, statusText: response.statusText, headers: response.headers });
72
+ }
73
+ batches = false;
74
+ }
75
+ const answers = [];
76
+ for (const response of await Promise.all(entries.map(entry => send(input, { ...init, body: JSON.stringify(entry) })))) {
77
+ const text = await response.text();
78
+ if (!response.ok)
79
+ return new Response(text, { status: response.status, statusText: response.statusText, headers: response.headers });
80
+ answers.push(JSON.parse(text));
81
+ }
82
+ return new Response(JSON.stringify(answers), { status: 200, headers: { 'Content-Type': 'application/json' } });
83
+ };
84
+ const batched = http(url, { batch: { batchSize, wait }, fetchFn });
85
+ return params => {
86
+ const alone = plain(params), grouped = batched(params);
87
+ const request = (args, options) => (batches && BATCHED_METHODS.has(args.method) ? grouped : alone).request(args, options);
88
+ return { ...alone, request };
89
+ };
90
+ }
37
91
  /**
38
92
  * Create a read-only chain client with typed contract readers and windowed event queries. Configure addresses and the chain ID from a network manifest downloaded from tasra-releases.
39
93
  * @param cfg RPC endpoint, deployed addresses, chain ID and optional batching limits.
@@ -57,8 +111,10 @@ export function createTasraChainClient(cfg) {
57
111
  // probe and with a fallback that can actually run. See `multicallAddress`.
58
112
  const client = createPublicClient({
59
113
  chain,
60
- transport: http(cfg.rpcUrl),
114
+ transport: rpcTransport(cfg.rpcUrl, cfg.rpcBatch),
61
115
  });
116
+ // Block-pinned paid-path reads batch through the same Multicall3 choice, code-hash verified.
117
+ configurePinnedReads(client, cfg.multicall3);
62
118
  const addresses = cfg.addresses;
63
119
  const defaultWindow = cfg.logWindow ?? 2000;
64
120
  /**
@@ -1,5 +1,7 @@
1
1
  import type { Address, Hex } from 'viem';
2
2
  import type { TasraChainClient } from './client.js';
3
+ import type { SlotSeedFailure } from './slotSeed.js';
4
+ import { TasraError } from '../errors.js';
3
5
  /** A creation may keep its slot/rule inputs, but needs a durably saved new commit salt. */
4
6
  export declare class SlotCommitmentExpiredError extends Error {
5
7
  readonly chainId: number;
@@ -13,6 +15,55 @@ export declare class SlotCommitmentExpiredError extends Error {
13
15
  /** Expired commit-reveal commitment hash. */
14
16
  commitment: Hex, /** Account that submitted the original commitment. */ creator: Address, /** Original private commit salt; preserve it until outstanding requests are reconciled. */ salt: Hex);
15
17
  }
18
+ /**
19
+ * No accountant seed could be had for a creation within the bounded window. There is no beacon-epoch
20
+ * fallback: the epoch seed comes from the same accountant set, so waiting for it adds no liveness,
21
+ * only up to two hours. `committed` says whether a commitment is already on chain.
22
+ */
23
+ export declare class SlotSeedUnavailableError extends TasraError {
24
+ readonly detail: {
25
+ /** Slot identifier reserved by the creation intent. */
26
+ slotId: Hex;
27
+ /** `false`: nothing was sent; retrying the call is free. `true`: the commitment stands and the creation must be RESUMED, not restarted. */
28
+ committed: boolean;
29
+ /** Creation commitment the seed was asked for. */
30
+ commitment: Hex;
31
+ /** Commit transaction, when `committed`. */
32
+ commitTx?: Hex;
33
+ /** Last beacon epoch in which the commitment can still be revealed, when `committed`. */
34
+ expiryEpoch?: number;
35
+ /** Each accountant's last answer. */
36
+ failure: SlotSeedFailure;
37
+ };
38
+ constructor(/** Which creation, whether its commitment is on chain, and every accountant's last answer. */ detail: {
39
+ /** Slot identifier reserved by the creation intent. */
40
+ slotId: Hex;
41
+ /** `false`: nothing was sent; retrying the call is free. `true`: the commitment stands and the creation must be RESUMED, not restarted. */
42
+ committed: boolean;
43
+ /** Creation commitment the seed was asked for. */
44
+ commitment: Hex;
45
+ /** Commit transaction, when `committed`. */
46
+ commitTx?: Hex;
47
+ /** Last beacon epoch in which the commitment can still be revealed, when `committed`. */
48
+ expiryEpoch?: number;
49
+ /** Each accountant's last answer. */
50
+ failure: SlotSeedFailure;
51
+ });
52
+ }
53
+ /**
54
+ * An existing beacon-epoch commitment (made by an older SDK) cannot be revealed yet. The check is made
55
+ * once; the SDK never waits for the epoch. Resume the same creation once the beacon reaches `targetEpoch`.
56
+ */
57
+ export declare class SlotRevealNotYetError extends TasraError {
58
+ readonly slotId: Hex;
59
+ readonly commitment: Hex;
60
+ /** First beacon epoch in which it can be revealed. */ readonly targetEpoch: number;
61
+ readonly currentEpoch: number;
62
+ /** Last beacon epoch in which it can be revealed. */ readonly expiryEpoch: number;
63
+ constructor(/** Slot identifier reserved by the creation intent. */ slotId: Hex, /** The epoch-path commitment. */ commitment: Hex,
64
+ /** First beacon epoch in which it can be revealed. */ targetEpoch: number, /** Beacon epoch observed by the check. */ currentEpoch: number,
65
+ /** Last beacon epoch in which it can be revealed. */ expiryEpoch: number);
66
+ }
16
67
  /**
17
68
  * Read-only recovery gate. The caller must also reconcile every outstanding signed request.
18
69
  * @param chain Reader for the deployment owning the expired commitment.
@@ -1,5 +1,6 @@
1
1
  import { keyRegistryAbi } from './abis/keyRegistry.js';
2
2
  import { thresholdRandomBeaconAbi } from './abis/thresholdRandomBeacon.js';
3
+ import { TasraError } from '../errors.js';
3
4
  /** A creation may keep its slot/rule inputs, but needs a durably saved new commit salt. */
4
5
  export class SlotCommitmentExpiredError extends Error {
5
6
  chainId;
@@ -21,6 +22,43 @@ export class SlotCommitmentExpiredError extends Error {
21
22
  this.name = 'SlotCommitmentExpiredError';
22
23
  }
23
24
  }
25
+ /**
26
+ * No accountant seed could be had for a creation within the bounded window. There is no beacon-epoch
27
+ * fallback: the epoch seed comes from the same accountant set, so waiting for it adds no liveness,
28
+ * only up to two hours. `committed` says whether a commitment is already on chain.
29
+ */
30
+ export class SlotSeedUnavailableError extends TasraError {
31
+ detail;
32
+ constructor(/** Which creation, whether its commitment is on chain, and every accountant's last answer. */ detail) {
33
+ super(detail.committed
34
+ ? `No accountant seed for slot ${detail.slotId} (${detail.failure.reason}). The commitment ${detail.commitment} stands` +
35
+ `${detail.commitTx ? ` (commit tx ${detail.commitTx})` : ''}${detail.expiryEpoch !== undefined ? ` and can be revealed until beacon epoch ${detail.expiryEpoch}` : ''}: ` +
36
+ 'resume with the same slotId, salt and ruleSalt and recovery.commitTx (createPreparedSlot resumes from its journal); nothing is committed again'
37
+ : `No accountant seed is available for slot ${detail.slotId} (${detail.failure.reason}); no commitment was sent`, { retryable: true });
38
+ this.detail = detail;
39
+ }
40
+ }
41
+ /**
42
+ * An existing beacon-epoch commitment (made by an older SDK) cannot be revealed yet. The check is made
43
+ * once; the SDK never waits for the epoch. Resume the same creation once the beacon reaches `targetEpoch`.
44
+ */
45
+ export class SlotRevealNotYetError extends TasraError {
46
+ slotId;
47
+ commitment;
48
+ targetEpoch;
49
+ currentEpoch;
50
+ expiryEpoch;
51
+ constructor(/** Slot identifier reserved by the creation intent. */ slotId, /** The epoch-path commitment. */ commitment,
52
+ /** First beacon epoch in which it can be revealed. */ targetEpoch, /** Beacon epoch observed by the check. */ currentEpoch,
53
+ /** Last beacon epoch in which it can be revealed. */ expiryEpoch) {
54
+ super(`Epoch-path commitment ${commitment} for slot ${slotId} is not revealable until beacon epoch ${targetEpoch} (now ${currentEpoch}); resume the creation then, before epoch ${expiryEpoch + 1}`, { retryable: true });
55
+ this.slotId = slotId;
56
+ this.commitment = commitment;
57
+ this.targetEpoch = targetEpoch;
58
+ this.currentEpoch = currentEpoch;
59
+ this.expiryEpoch = expiryEpoch;
60
+ }
61
+ }
24
62
  /**
25
63
  * Read-only recovery gate. The caller must also reconcile every outstanding signed request.
26
64
  * @param chain Reader for the deployment owning the expired commitment.
@@ -1,8 +1,11 @@
1
1
  import type { TasraChainClient } from './client.js';
2
- import { type ClientSigner, type CommitteeVerifier, type HolderProofPerVerifier } from '../committee/index.js';
2
+ import { type CommitteeVerifier, type HolderProofPerVerifier } from '../committee/index.js';
3
3
  import type { FrostSignResult } from '../signing/frost.js';
4
4
  import type { Ciphertext } from '../crypto/kem.js';
5
5
  import type { BlsPeer } from '../decryption/client.js';
6
+ import type { RequestBindingPreimage } from '../committee/client.js';
7
+ import type { PaymentIntentWire } from '../committee/payment.js';
8
+ import { type SealedRequestOpts } from '../decryption/sealed.js';
6
9
  /**
7
10
  * Chain discovery and holder-proof configuration for threshold signing and identity decryption.
8
11
  */
@@ -33,8 +36,6 @@ export interface CommitteeSlotClientConfig {
33
36
  * slotId})` there - it mints a fresh proof per drawn verifier, on every request.
34
37
  */
35
38
  holderProof?: string | HolderProofPerVerifier;
36
- /** sign the request bundle so keeper + audit can verify you authorized it. */
37
- clientSigner?: ClientSigner;
38
39
  /** Compound-token TTL in seconds (default 300). */
39
40
  ttlSecs?: number;
40
41
  }
@@ -49,19 +50,23 @@ export interface SlotCommitteeSignOptions {
49
50
  targetKeykeeper?: string;
50
51
  }
51
52
  /** Everything a committee-authorized threshold decrypt needs beyond the slot id. */
52
- export interface SlotCommitteeDecryptOptions {
53
+ export interface SlotCommitteeDecryptOptions extends Pick<SealedRequestOpts, 'recipient' | 'verifyingShares' | 'threshold' | 'approveExecution' | 'signal' | 'fetchImpl' | 'requestId'> {
54
+ /** Original authorization preimage binding the complete ciphertext, identity, recipient and epoch. */
55
+ binding: RequestBindingPreimage;
56
+ /** Original creator-signed payment intent; required by paid deployments. */
57
+ payment?: PaymentIntentWire;
53
58
  /** Group ciphertext to decrypt through committee authorization. */
54
59
  ciphertext: Ciphertext;
55
60
  /** Original associated data used when encrypting the group ciphertext. */
56
61
  identity: Uint8Array;
57
- /** BLS identifiers (k..n, distinct) to run the ceremony with. */
58
- decryptingSet: number[];
59
- /** The libp2p peers for those identifiers. */
60
- blsPeers: BlsPeer[];
62
+ /** Historical coordinator selection; ignored by client-sealed delivery. */
63
+ decryptingSet?: number[];
64
+ /** Historical coordinator peer map; ignored by client-sealed delivery. */
65
+ blsPeers?: BlsPeer[];
61
66
  /** Optional Ed25519 slot-owner signature required by the keeper policy. */
62
67
  userSignature?: Uint8Array;
63
68
  /** Expected slot key epoch for detecting ciphertext-key rotation. */
64
- ciphertextEpoch?: number;
69
+ ciphertextEpoch: number;
65
70
  /** Pin the keeper this request targets (anti-Sybil); an on-chain assigned operator. */
66
71
  targetKeykeeper?: string;
67
72
  }
@@ -89,7 +94,9 @@ export interface CommitteeSlotClient {
89
94
  identity?: Uint8Array;
90
95
  epoch?: bigint | null;
91
96
  }): Promise<Uint8Array>;
92
- /** Committee-authorized threshold decrypt. */
97
+ /** Discover assigned keepers, validate canonical epoch/quorum and collect client-sealed contributions.
98
+ * Recipient and request binding are required before holder authorization; no custody fallback exists.
99
+ */
93
100
  decrypt(slotId: string, opts: SlotCommitteeDecryptOptions): Promise<Uint8Array>;
94
101
  /** The resolved active verifier directory (discovered once, then cached). */
95
102
  verifierDirectory(): Promise<CommitteeVerifier[]>;