@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,53 @@
1
+ /** Assigned operator and transport identity established independently from NodeRegistry. */
2
+ export interface BlsSharingKeeper {
3
+ /** On-chain operator address; two URLs cannot count as different operators. */
4
+ operator: string;
5
+ /** Independently resolved keeper endpoint, with any caller-approved route mapping applied. */
6
+ nodeUrl: string;
7
+ /** Registered Ed25519 operator identity key, never taken from the HTTP reply. */
8
+ publicKey: Uint8Array;
9
+ }
10
+ /** Canonical slot sharing and assigned identities to authenticate before requesting contributions. */
11
+ export interface BlsSharingOptions {
12
+ /** Deployment chain ID. */
13
+ chainId: number | bigint;
14
+ /** Original 32-byte slot identifier. */
15
+ slotId: string;
16
+ /** Key epoch read independently from the canonical slot or reserved payment. */
17
+ epoch: number;
18
+ /** Sharing version read independently; reshares can change it without changing the epoch. */
19
+ committeeVersion: number;
20
+ /** Required number of distinct assigned operators. */
21
+ threshold: number;
22
+ /** Assigned operators with registry-authenticated identity keys. */
23
+ keepers: readonly BlsSharingKeeper[];
24
+ /** Optional guarded transport, also used by applications with mapped keeper routes. */
25
+ fetchImpl?: typeof fetch;
26
+ /** Allow loopback HTTP for disposable local chain43112 only. Default false. */
27
+ allowLocalHttp?: boolean;
28
+ /** Cancel all pending metadata reads. The complete discovery is bounded to 15 seconds. */
29
+ signal?: AbortSignal;
30
+ }
31
+ /** Authenticated operator self-reports. Final decryption must still verify the chain-anchored group key. */
32
+ export interface BlsSharing {
33
+ /** Public 144-byte G2 || G1 shares indexed by distinct participant identifier. */
34
+ verifyingShares: ReadonlyMap<number, Uint8Array>;
35
+ /** Assigned endpoints whose signed reports verified for the exact sharing. */
36
+ keepers: readonly (BlsSharingKeeper & {
37
+ identifier: number;
38
+ })[];
39
+ /** Metadata refusals, retained without counting them toward the threshold. */
40
+ failures: readonly {
41
+ operator: string;
42
+ message: string;
43
+ }[];
44
+ }
45
+ /**
46
+ * Authenticate each keeper's public BLS share using the existing operator share-report signature.
47
+ * A report authenticates that operator's claim; it is not a chain commitment to a full polynomial.
48
+ * Callers must retain pairing checks and final verification against the anchored group key.
49
+ * No secret share is fetched and no payment or decryption work is started.
50
+ *
51
+ * @param input - Canonical epoch/version, threshold and independently authenticated assigned keepers.
52
+ */
53
+ export declare function discoverBlsSharing(input: BlsSharingOptions): Promise<BlsSharing>;
@@ -0,0 +1,90 @@
1
+ import { ed25519 } from '@noble/curves/ed25519';
2
+ import { bls12_381 } from '@noble/curves/bls12-381';
3
+ import { keccak_256 } from '@noble/hashes/sha3';
4
+ import { concatBytes, utf8ToBytes } from '@noble/hashes/utils';
5
+ import { equalBytes } from '@noble/curves/utils.js';
6
+ import { verifyDecryptShare } from '../crypto/kem.js';
7
+ import { withNetworkDeadline, resolveKeeperMembers } from '../internal/network.js';
8
+ import { readIbeReply } from './client.js';
9
+ import { protocolHex } from './receipts.js';
10
+ function uint(value, bytes) {
11
+ if (typeof value === 'number' && !Number.isSafeInteger(value))
12
+ throw new Error('Invalid share-report integer');
13
+ let n = BigInt(value);
14
+ if (n < 0n || n >= 1n << BigInt(bytes * 8))
15
+ throw new Error('Share-report integer out of range');
16
+ const out = new Uint8Array(bytes);
17
+ for (let i = bytes - 1; i >= 0; i--) {
18
+ out[i] = Number(n & 255n);
19
+ n >>= 8n;
20
+ }
21
+ return out;
22
+ }
23
+ /**
24
+ * Authenticate each keeper's public BLS share using the existing operator share-report signature.
25
+ * A report authenticates that operator's claim; it is not a chain commitment to a full polynomial.
26
+ * Callers must retain pairing checks and final verification against the anchored group key.
27
+ * No secret share is fetched and no payment or decryption work is started.
28
+ *
29
+ * @param input - Canonical epoch/version, threshold and independently authenticated assigned keepers.
30
+ */
31
+ export async function discoverBlsSharing(input) {
32
+ input = { ...input };
33
+ input.signal?.throwIfAborted();
34
+ const slot = protocolHex(input.slotId, 32, 'BLS sharing slot');
35
+ uint(input.chainId, 8);
36
+ uint(input.epoch, 8);
37
+ uint(input.committeeVersion, 8);
38
+ if (!input.keepers.length || input.keepers.length > 4096 || !Number.isSafeInteger(input.threshold) || input.threshold < 1 || input.threshold > input.keepers.length)
39
+ throw new Error('Invalid BLS sharing threshold or keeper roster');
40
+ const keepers = input.keepers.map(k => ({ ...k, operator: k.operator.toLowerCase(), publicKey: k.publicKey.slice(), nodeUrl: k.nodeUrl.replace(/\/$/, '') }));
41
+ if (new Set(keepers.map(k => k.operator)).size !== keepers.length || new Set(keepers.map(k => k.nodeUrl)).size !== keepers.length)
42
+ throw new Error('Duplicate BLS sharing operator or endpoint');
43
+ for (const k of keepers) {
44
+ protocolHex(k.operator, 20, 'BLS operator');
45
+ if (k.publicKey.length !== 32)
46
+ throw new Error('Invalid registered BLS keeper identity');
47
+ const url = new URL(k.nodeUrl);
48
+ if (url.username || url.password || url.search || url.hash || (url.protocol !== 'https:' && !(url.protocol === 'http:' && input.allowLocalHttp && BigInt(input.chainId) === 43112n && ['localhost', '127.0.0.1', '[::1]'].includes(url.hostname))))
49
+ throw new Error('BLS sharing endpoint violates transport policy');
50
+ }
51
+ const fetchImpl = input.fetchImpl ?? fetch;
52
+ return withNetworkDeadline(async (signal) => {
53
+ const results = await resolveKeeperMembers(keepers, async (keeper) => {
54
+ try {
55
+ const url = `${keeper.nodeUrl}/v1/keys/${input.slotId}/bls-share-report`;
56
+ const response = await fetchImpl(url, { signal, redirect: 'error', credentials: 'omit' });
57
+ const text = await readIbeReply(response, signal);
58
+ if (!response.ok)
59
+ throw new Error(`BLS share report HTTP ${response.status}`);
60
+ const r = JSON.parse(text);
61
+ if (!equalBytes(protocolHex(r.slot_id, 32, 'report slot'), slot) || r.epoch !== input.epoch || r.committee_version !== input.committeeVersion || !Number.isSafeInteger(r.identifier) || r.identifier < 1 || r.identifier > 65535 ||
62
+ !equalBytes(protocolHex(r.operator, 20, 'report operator'), protocolHex(keeper.operator, 20, 'assigned operator')) || !equalBytes(protocolHex(r.pubkey, 32, 'report identity'), keeper.publicKey))
63
+ throw new Error('BLS report differs from assigned operator or canonical sharing');
64
+ const share = protocolHex(r.verifying_share, 144, 'BLS public share');
65
+ const digest = keccak_256(concatBytes(utf8ToBytes('keykeeper-committee/keeper-share-report/v1'), uint(input.chainId, 8), slot, uint(input.epoch, 8), uint(input.committeeVersion, 8), uint(r.identifier, 4), protocolHex(keeper.operator, 20, 'operator'), share));
66
+ if (!ed25519.verify(protocolHex(r.signature, 64, 'share-report signature'), digest, keeper.publicKey, { zip215: false }))
67
+ throw new Error('Invalid BLS operator share-report signature');
68
+ // Reuse the contribution pairing check at U = g2 to validate G2 || G1 consistency.
69
+ if (!verifyDecryptShare({ id: r.identifier, verifyingShare: share, decryptionShare: share.slice(0, 96) }, bls12_381.G2.ProjectivePoint.BASE.toRawBytes(true)))
70
+ throw new Error('Invalid dual-group BLS public share');
71
+ return { keeper: { ...keeper, identifier: r.identifier }, share };
72
+ }
73
+ catch (error) {
74
+ signal.throwIfAborted();
75
+ return { failure: { operator: keeper.operator, message: String(error) } };
76
+ }
77
+ }, signal);
78
+ signal.throwIfAborted();
79
+ const verified = results.flatMap(r => r.keeper ? [r] : []);
80
+ const verifyingShares = new Map();
81
+ for (const r of verified) {
82
+ if (verifyingShares.has(r.keeper.identifier))
83
+ throw new Error('Duplicate identifier in signed BLS share reports');
84
+ verifyingShares.set(r.keeper.identifier, r.share);
85
+ }
86
+ if (verified.length < input.threshold)
87
+ throw new Error(`Authenticated BLS sharing threshold not met: ${verified.length}/${input.threshold}; ${results.flatMap(r => r.failure ? [r.failure.message] : []).join('; ')}`);
88
+ return { verifyingShares, keepers: verified.map(r => r.keeper), failures: results.flatMap(r => r.failure ? [r.failure] : []) };
89
+ }, input.signal);
90
+ }
@@ -1,9 +1,12 @@
1
+ import { type ClientRecipient } from '../crypto/recipient.js';
2
+ import { type PaymentIntentWire } from './payment.js';
1
3
  import { TasraHttpError } from '../errors.js';
2
4
  import { type CompoundTokenWire, type TokenType } from './token.js';
3
5
  import type { Ciphertext } from '../crypto/kem.js';
4
6
  import type { FrostSignResult } from '../signing/frost.js';
5
7
  import type { BlsPeer } from '../decryption/client.js';
6
8
  import { type OperationReceipt } from './receipts.js';
9
+ import { type KeeperExecutionApprover } from './keeperExecution.js';
7
10
  /** Trustless verifier-set inclusion proof, passed to the keeper. */
8
11
  export interface VerifierProof {
9
12
  /** Zero-based verifier registry index. */
@@ -32,6 +35,8 @@ export declare class CommitteeAuthorizeError extends TasraHttpError {
32
35
  }
33
36
  /** Credential presentation and request context sent to one verifier for committee authorization. */
34
37
  export interface CommitteeAuthorizeBody {
38
+ /** Creator intent for the already mined reservation. */
39
+ payment?: PaymentIntentWire;
35
40
  /** Holder DID (the credentials' subject). */
36
41
  holder: string;
37
42
  /** Compact-JWS verifiable credentials. */
@@ -85,6 +90,13 @@ export interface RequestBindingPreimage {
85
90
  }
86
91
  /** Verifier signature, token hashes and committee metadata for an authorization request. */
87
92
  export interface CommitteeAuthorizeReply {
93
+ /** Complete sealed evidence returned and independently signed by this verifier. */
94
+ sealedEvidence?: {
95
+ hash: string;
96
+ keyId: string;
97
+ signature: string;
98
+ ciphertext: string;
99
+ };
88
100
  /** Zero-based verifier registry index. */
89
101
  verifierIndex: number;
90
102
  /** 32-byte compound token hash. */
@@ -117,8 +129,19 @@ export interface CommitteeAuthorizeReply {
117
129
  ruleVersion?: number;
118
130
  /** present when the request carried a binding preimage; inside the signed bytes. */
119
131
  requestHash?: Uint8Array;
132
+ /** Payment commitment attested by this verifier. */
133
+ paymentHash?: Uint8Array;
120
134
  /** binding strength byte (`bindingFromWire`); `0x00` when the verifier declared none. */
121
135
  binding: number;
136
+ /**
137
+ * This verifier's revocation-status freshness attestation (`status_until` + `status_signature`
138
+ * on the wire), when it sent one. Not authenticated here: {@link gatherCommitteeToken} verifies
139
+ * it under the verifier's committee key before relaying it.
140
+ */
141
+ statusAttestation?: {
142
+ statusUntil: number;
143
+ signature: Uint8Array;
144
+ };
122
145
  }
123
146
  /**
124
147
  * Ask one verifier to authorize the request. Throws CommitteeAuthorizeError
@@ -130,11 +153,14 @@ export interface CommitteeAuthorizeReply {
130
153
  export declare function committeeAuthorize(verifierUrl: string, body: CommitteeAuthorizeBody): Promise<CommitteeAuthorizeReply>;
131
154
  /** Verifier requests and quorum configuration for assembling a compound token. */
132
155
  export interface GatherCommitteeTokenOpts {
156
+ /** Required for sealed replies: retain this ciphertext beside the returned token. */
157
+ onEvidence?: (ciphertext: string) => void;
133
158
  /** Candidate verifiers to ask (index to base URL). Asking the whole registry is
134
159
  * fine - non-drawn verifiers reply 403 and are skipped. */
135
160
  verifiers: Array<{
136
161
  index: number;
137
162
  url: string;
163
+ pubkey?: string | Uint8Array;
138
164
  }>;
139
165
  /** Authorization input shared across requests to the selected verifiers. */
140
166
  authorize: CommitteeAuthorizeBody;
@@ -159,6 +185,10 @@ export interface GatherCommitteeTokenOpts {
159
185
  export declare function gatherCommitteeToken(opts: GatherCommitteeTokenOpts): Promise<CompoundTokenWire>;
160
186
  /** Committee-authorized FROST signing request and optional verifier membership proofs. */
161
187
  export interface CommitteeSignOpts {
188
+ /** Exact sealed presentation ciphertext returned with this authorization. */
189
+ evidenceCt?: string;
190
+ /** Required for a paid token: client-only exact-body stage approval capability. */
191
+ approveExecution?: KeeperExecutionApprover;
162
192
  /** Optional signal that cancels the request. */
163
193
  signal?: AbortSignal;
164
194
  /** HTTP transport override; defaults to the global fetch implementation. */
@@ -177,22 +207,25 @@ export interface CommitteeSignOpts {
177
207
  targetKeykeeper?: string;
178
208
  /** Verifier membership proofs for the selected snapshot. */
179
209
  verifierProofs?: VerifierProof[];
180
- /** 32-byte Ed25519 client public key used to verify clientSignature over the slot and token hash; supply both fields together. */
181
- clientPubkey?: Uint8Array;
182
- /** Client signature over the slot and compound token binding. */
183
- clientSignature?: Uint8Array;
184
- /** the sealed presentation beside the token (`VerifierAgentResult.evidenceCt`),
185
- * posted as `evidence_ct`. Required by a keeper with `require_committee_evidence`. */
186
- evidenceCt?: string;
187
210
  }
188
211
  /**
189
212
  * Sign via committee authorization. The slot id is taken from the token.
213
+ * Approvals, HTTP and response decoding share a 15-second deadline. A timeout
214
+ * is an uncertain outcome; reconcile the original paid operation before resubmitting.
190
215
  *
191
216
  * @param opts - Keeper endpoint, compound authorization and message to sign.
192
217
  */
193
218
  export declare function committeeSign(opts: CommitteeSignOpts): Promise<FrostSignResult>;
194
219
  /** Committee-authorized group decryption request and optional verifier membership proofs. */
195
220
  export interface CommitteeDecryptOpts {
221
+ /** Exact sealed presentation ciphertext returned with this authorization. */
222
+ evidenceCt?: string;
223
+ /** Required for a paid token: client-only exact-body stage approval capability. */
224
+ approveExecution?: KeeperExecutionApprover;
225
+ /** Caller cancellation for canonical approval and keeper work. */
226
+ signal?: AbortSignal;
227
+ /** Caller-approved HTTP implementation. */
228
+ fetchImpl?: typeof fetch;
196
229
  /** Keeper HTTP base URL. */
197
230
  nodeUrl: string;
198
231
  /** Compound token authorizing this operation. */
@@ -213,18 +246,11 @@ export interface CommitteeDecryptOpts {
213
246
  targetKeykeeper?: string;
214
247
  /** Verifier membership proofs for the selected snapshot. */
215
248
  verifierProofs?: VerifierProof[];
216
- /** 32-byte Ed25519 client public key used to verify clientSignature; supply both fields together. */
217
- clientPubkey?: Uint8Array;
218
- /** Client signature over the slot and compound token binding. */
219
- clientSignature?: Uint8Array;
220
- /** the sealed presentation beside the token (`VerifierAgentResult.evidenceCt`),
221
- * posted as `evidence_ct`. Required by a keeper with `require_committee_evidence`. */
222
- evidenceCt?: string;
223
- /** HTTP transport override; defaults to the global fetch implementation. */
224
- fetchImpl?: typeof fetch;
225
249
  }
226
250
  /**
227
251
  * Decrypt via committee authorization. The slot id is taken from the token.
252
+ * Approvals, HTTP and response decoding share a 15-second deadline. A timeout
253
+ * does not prove that the keeper performed no work and never triggers a retry.
228
254
  *
229
255
  * @param opts - Keeper endpoint, compound authorization, ciphertext and associated data.
230
256
  */
@@ -248,6 +274,23 @@ export interface IbeExtractionPartial {
248
274
  }
249
275
  /** Committee authorization and keeper endpoints for extracting shares of one IBE identity key. */
250
276
  export interface IbeExtractOpts {
277
+ /** Original client-held recipient bound before authorization; required at runtime. */
278
+ recipient?: ClientRecipient;
279
+ /** Deployment chain identifier used to validate the signed recipient-bound request hash. */
280
+ chainId?: number | bigint;
281
+ /** Independently authenticated 144-byte G2 || G1 public shares; reply-supplied keys alone are insufficient. */
282
+ verifyingShares?: ReadonlyMap<number, Uint8Array>;
283
+ /** Exact sealed presentation ciphertext returned with this authorization. */
284
+ evidenceCt?: string;
285
+ /** Stop after this many distinct, pairing-verified shares. Without this option,
286
+ * collect every successful reply. The low-level check uses returned verifying
287
+ * shares; use extractIdentityStrict for independently pinned keeper provenance. */
288
+ threshold?: number;
289
+ /** Deadline for the complete fan-out, including approvals and response bodies.
290
+ * Default 10000 ms. Cancellation cannot undo work a keeper already started. */
291
+ timeoutMs?: number;
292
+ /** Required for paid extraction: approve only the exact targeted assigned contributor. */
293
+ approveExecution?: KeeperExecutionApprover;
251
294
  /** Optional signal that cancels the request. */
252
295
  signal?: AbortSignal;
253
296
  /** HTTP transport override; defaults to the global fetch implementation. */
@@ -265,14 +308,8 @@ export interface IbeExtractOpts {
265
308
  ciphertextEpoch?: number;
266
309
  /** Verifier membership proofs for the selected snapshot. */
267
310
  verifierProofs?: VerifierProof[];
268
- /** 32-byte Ed25519 client public key used to verify clientSignature; supply both fields together. */
269
- clientPubkey?: Uint8Array;
270
- /** Client signature over the slot and compound token binding. */
271
- clientSignature?: Uint8Array;
272
- /** the sealed presentation beside the token (`VerifierAgentResult.evidenceCt`),
273
- * posted as `evidence_ct`. Required by a keeper with `require_committee_evidence`. */
274
- evidenceCt?: string;
275
311
  }
312
+ export declare function readIbeReply(response: Response, signal?: AbortSignal): Promise<string>;
276
313
  /**
277
314
  * Fan out to the keeper nodes and collect extraction partials. Nodes that refuse or are
278
315
  * down are skipped; throws - naming every node and its reason - only when NONE served.
@@ -282,3 +319,5 @@ export interface IbeExtractOpts {
282
319
  * @param opts - Compound token, identity, keepers and optional expected epoch.
283
320
  */
284
321
  export declare function requestIbeExtractionPartials(opts: IbeExtractOpts): Promise<IbeExtractionPartial[]>;
322
+ /** @internal The strict helper supplies its independent keeper/receipt admission check. */
323
+ export declare function collectIbeExtractionPartials(opts: IbeExtractOpts, validate?: (partial: IbeExtractionPartial) => void): Promise<IbeExtractionPartial[]>;