@bcts/frost-hubert 1.0.0-beta.0 → 1.0.0-beta.1

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 (149) hide show
  1. package/README.md +1 -1
  2. package/dist/bin/frost.cjs +17 -19
  3. package/dist/bin/frost.cjs.map +1 -1
  4. package/dist/bin/frost.mjs +16 -17
  5. package/dist/bin/frost.mjs.map +1 -1
  6. package/dist/{busy-EZU7EKr6.cjs → busy-B_h0bNAJ.cjs} +1 -1
  7. package/dist/{busy-DkM2jAIZ.mjs.map → busy-B_h0bNAJ.cjs.map} +1 -1
  8. package/dist/{busy-DkM2jAIZ.mjs → busy-BlU8_pS2.mjs} +1 -1
  9. package/dist/{busy-EZU7EKr6.cjs.map → busy-BlU8_pS2.mjs.map} +1 -1
  10. package/dist/cmd/index.cjs +6 -7
  11. package/dist/cmd/index.d.cts +1 -1
  12. package/dist/cmd/index.d.mts +1 -1
  13. package/dist/cmd/index.mjs +5 -6
  14. package/dist/{cmd-Bw9_i2_f.cjs → cmd-CCVhHzG7.cjs} +20 -21
  15. package/dist/{cmd-Bw9_i2_f.cjs.map → cmd-CCVhHzG7.cjs.map} +1 -1
  16. package/dist/{cmd-CS1uJtuD.mjs → cmd-DNsHd19v.mjs} +20 -21
  17. package/dist/{cmd-CS1uJtuD.mjs.map → cmd-DNsHd19v.mjs.map} +1 -1
  18. package/dist/{common-lThIvJmZ.cjs → common-7-BOgaTt.cjs} +2 -3
  19. package/dist/{common-lThIvJmZ.cjs.map → common-7-BOgaTt.cjs.map} +1 -1
  20. package/dist/{common-CvH6dFvQ.mjs → common-Cf1UvJaP.mjs} +3 -3
  21. package/dist/{common-CvH6dFvQ.mjs.map → common-Cf1UvJaP.mjs.map} +1 -1
  22. package/dist/{common-lKP5EzHy.cjs → common-CnvAUC2b.cjs} +3 -3
  23. package/dist/{common-lKP5EzHy.cjs.map → common-CnvAUC2b.cjs.map} +1 -1
  24. package/dist/{common-DUWvtc08.mjs → common-DNrD_-EI.mjs} +2 -2
  25. package/dist/{common-DUWvtc08.mjs.map → common-DNrD_-EI.mjs.map} +1 -1
  26. package/dist/dkg/index.cjs +1 -2
  27. package/dist/dkg/index.cjs.map +1 -1
  28. package/dist/dkg/index.d.cts +1 -1
  29. package/dist/dkg/index.d.mts +1 -1
  30. package/dist/dkg/index.mjs +1 -1
  31. package/dist/dkg/index.mjs.map +1 -1
  32. package/dist/{finalize-CNTDj6aS.mjs → finalize-BpC0rz93.mjs} +6 -6
  33. package/dist/{finalize-CNTDj6aS.mjs.map → finalize-BpC0rz93.mjs.map} +1 -1
  34. package/dist/{finalize-BRgJK-Xv.cjs → finalize-Cb0obTSo.cjs} +6 -6
  35. package/dist/{finalize-BRgJK-Xv.cjs.map → finalize-Cb0obTSo.cjs.map} +1 -1
  36. package/dist/{finalize-BfLgzn8f.cjs → finalize-DHEnKobp.cjs} +5 -5
  37. package/dist/{finalize-BfLgzn8f.cjs.map → finalize-DHEnKobp.cjs.map} +1 -1
  38. package/dist/{finalize-UPyI1yb1.cjs → finalize-DQ0VGUHO.cjs} +7 -7
  39. package/dist/{finalize-UPyI1yb1.cjs.map → finalize-DQ0VGUHO.cjs.map} +1 -1
  40. package/dist/{finalize-IA01t_Qq.mjs → finalize-DtRxHZ7H.mjs} +5 -5
  41. package/dist/{finalize-IA01t_Qq.mjs.map → finalize-DtRxHZ7H.mjs.map} +1 -1
  42. package/dist/{finalize-EC3ikHQq.mjs → finalize-T83Ko8nG.mjs} +6 -6
  43. package/dist/{finalize-EC3ikHQq.mjs.map → finalize-T83Ko8nG.mjs.map} +1 -1
  44. package/dist/frost/index.cjs +1 -1
  45. package/dist/frost/index.cjs.map +1 -1
  46. package/dist/frost/index.d.cts.map +1 -1
  47. package/dist/frost/index.d.mts.map +1 -1
  48. package/dist/frost/index.mjs +1 -1
  49. package/dist/frost/index.mjs.map +1 -1
  50. package/dist/{index-F1iNEAJR.d.cts → index-BErX9AZF.d.cts} +3 -3
  51. package/dist/index-BErX9AZF.d.cts.map +1 -0
  52. package/dist/{index-B3c-80VS.d.cts → index-BaUVw4b1.d.mts} +2 -2
  53. package/dist/index-BaUVw4b1.d.mts.map +1 -0
  54. package/dist/{index-C8QeHNwa.d.cts → index-CD50Qtgw.d.cts} +1 -1
  55. package/dist/index-CD50Qtgw.d.cts.map +1 -0
  56. package/dist/{index-DVbWyOs7.d.mts → index-CD50Qtgw.d.mts} +1 -1
  57. package/dist/index-CD50Qtgw.d.mts.map +1 -0
  58. package/dist/{index-BgbSGpxn.d.mts → index-Drklne-Y.d.mts} +3 -3
  59. package/dist/index-Drklne-Y.d.mts.map +1 -0
  60. package/dist/{index-D3QTWkEm.d.mts → index-gkmZzEuD.d.cts} +2 -2
  61. package/dist/index-gkmZzEuD.d.cts.map +1 -0
  62. package/dist/index.cjs +7 -8
  63. package/dist/index.cjs.map +1 -1
  64. package/dist/index.d.cts +3 -3
  65. package/dist/index.d.cts.map +1 -1
  66. package/dist/index.d.mts +3 -3
  67. package/dist/index.d.mts.map +1 -1
  68. package/dist/index.mjs +6 -7
  69. package/dist/index.mjs.map +1 -1
  70. package/dist/{invite-5277FQVT.cjs → invite-1tzg0B0P.cjs} +5 -5
  71. package/dist/{invite-5277FQVT.cjs.map → invite-1tzg0B0P.cjs.map} +1 -1
  72. package/dist/{invite-DUTcfTgX.cjs → invite-BLwtexAu.cjs} +4 -4
  73. package/dist/{invite-DUTcfTgX.cjs.map → invite-BLwtexAu.cjs.map} +1 -1
  74. package/dist/{invite-IU4n0dq2.mjs → invite-Be2v2SVc.mjs} +4 -4
  75. package/dist/{invite-IU4n0dq2.mjs.map → invite-Be2v2SVc.mjs.map} +1 -1
  76. package/dist/{invite-RU-OXTNS.mjs → invite-D8mQSnFz.mjs} +5 -5
  77. package/dist/{invite-RU-OXTNS.mjs.map → invite-D8mQSnFz.mjs.map} +1 -1
  78. package/dist/{parallel-D6zc6VW4.mjs → parallel-PZiwHZT8.mjs} +1 -1
  79. package/dist/{parallel-D1R6ZGlY.cjs.map → parallel-PZiwHZT8.mjs.map} +1 -1
  80. package/dist/{parallel-D1R6ZGlY.cjs → parallel-szwYx-bi.cjs} +1 -1
  81. package/dist/{parallel-D6zc6VW4.mjs.map → parallel-szwYx-bi.cjs.map} +1 -1
  82. package/dist/{proposed-participant-Dm1Eq6mX.cjs → proposed-participant-BvHNnpcZ.cjs} +1 -2
  83. package/dist/{proposed-participant-Dm1Eq6mX.cjs.map → proposed-participant-BvHNnpcZ.cjs.map} +1 -1
  84. package/dist/{proposed-participant-cWM7iUrO.mjs → proposed-participant-Detb823_.mjs} +1 -1
  85. package/dist/{proposed-participant-cWM7iUrO.mjs.map → proposed-participant-Detb823_.mjs.map} +1 -1
  86. package/dist/{receive-CAI-x4II.cjs → receive-BR-knnGv.cjs} +6 -6
  87. package/dist/{receive-CAI-x4II.cjs.map → receive-BR-knnGv.cjs.map} +1 -1
  88. package/dist/{receive-kZMsXhbK.cjs → receive-D_r4Mryr.cjs} +6 -6
  89. package/dist/{receive-kZMsXhbK.cjs.map → receive-D_r4Mryr.cjs.map} +1 -1
  90. package/dist/{receive-D2Nn68L7.mjs → receive-dkSCSGpl.mjs} +5 -5
  91. package/dist/{receive-D2Nn68L7.mjs.map → receive-dkSCSGpl.mjs.map} +1 -1
  92. package/dist/{receive-DA_KQEgk.mjs → receive-g8EhZF2Y.mjs} +6 -6
  93. package/dist/{receive-DA_KQEgk.mjs.map → receive-g8EhZF2Y.mjs.map} +1 -1
  94. package/dist/registry/index.cjs +1 -1
  95. package/dist/registry/index.cjs.map +1 -1
  96. package/dist/registry/index.d.cts +1 -1
  97. package/dist/registry/index.d.mts +1 -1
  98. package/dist/registry/index.mjs.map +1 -1
  99. package/dist/{registry-9puTaRrD.cjs → registry-CkIbA7nt.cjs} +79 -2
  100. package/dist/registry-CkIbA7nt.cjs.map +1 -0
  101. package/dist/{registry-BpCwtrRt.mjs → registry-DGjs4qDK.mjs} +74 -3
  102. package/dist/registry-DGjs4qDK.mjs.map +1 -0
  103. package/dist/{round1-BHBjru1m.cjs → round1-9FAqFvL5.cjs} +5 -5
  104. package/dist/{round1-BHBjru1m.cjs.map → round1-9FAqFvL5.cjs.map} +1 -1
  105. package/dist/{round1-CcQCGlIT.mjs → round1-B8haiMM8.mjs} +6 -6
  106. package/dist/{round1-CcQCGlIT.mjs.map → round1-B8haiMM8.mjs.map} +1 -1
  107. package/dist/{round1-Cgm7j1kI.mjs → round1-BOIE1E4O.mjs} +5 -5
  108. package/dist/{round1-Cgm7j1kI.mjs.map → round1-BOIE1E4O.mjs.map} +1 -1
  109. package/dist/{round1-4Hyx8w0x.cjs → round1-Bq0vweyQ.cjs} +5 -5
  110. package/dist/{round1-4Hyx8w0x.cjs.map → round1-Bq0vweyQ.cjs.map} +1 -1
  111. package/dist/{round1-CWSXZx5R.cjs → round1-CXkXoVQU.cjs} +9 -9
  112. package/dist/{round1-CWSXZx5R.cjs.map → round1-CXkXoVQU.cjs.map} +1 -1
  113. package/dist/{round1-7v9LlE11.mjs → round1-D8t7EzIo.mjs} +5 -5
  114. package/dist/{round1-7v9LlE11.mjs.map → round1-D8t7EzIo.mjs.map} +1 -1
  115. package/dist/{round1-DQ0fnc1H.cjs → round1-DriPu15x.cjs} +7 -7
  116. package/dist/{round1-DQ0fnc1H.cjs.map → round1-DriPu15x.cjs.map} +1 -1
  117. package/dist/{round1-CMLKN2RR.mjs → round1-Y2kcVwnR.mjs} +7 -7
  118. package/dist/{round1-CMLKN2RR.mjs.map → round1-Y2kcVwnR.mjs.map} +1 -1
  119. package/dist/{round2-BWz9SQIi.cjs → round2-AMDYMUIg.cjs} +5 -5
  120. package/dist/{round2-BWz9SQIi.cjs.map → round2-AMDYMUIg.cjs.map} +1 -1
  121. package/dist/{round2-o2Q-GMbX.cjs → round2-BHQKVJFo.cjs} +7 -7
  122. package/dist/{round2-o2Q-GMbX.cjs.map → round2-BHQKVJFo.cjs.map} +1 -1
  123. package/dist/{round2-Bl2uK93U.mjs → round2-BfetYacV.mjs} +5 -5
  124. package/dist/{round2-Bl2uK93U.mjs.map → round2-BfetYacV.mjs.map} +1 -1
  125. package/dist/{round2-Dg24w-TU.mjs → round2-Cf5CJc_8.mjs} +7 -7
  126. package/dist/{round2-Dg24w-TU.mjs.map → round2-Cf5CJc_8.mjs.map} +1 -1
  127. package/dist/{round2-LylCa84n.cjs → round2-CvrmylN1.cjs} +7 -7
  128. package/dist/{round2-LylCa84n.cjs.map → round2-CvrmylN1.cjs.map} +1 -1
  129. package/dist/{round2-CdUT-AhH.cjs → round2-Dk_w97nl.cjs} +5 -5
  130. package/dist/{round2-CdUT-AhH.cjs.map → round2-Dk_w97nl.cjs.map} +1 -1
  131. package/dist/{round2-BkNRCXgS.mjs → round2-Z2JhMwxc.mjs} +5 -5
  132. package/dist/{round2-BkNRCXgS.mjs.map → round2-Z2JhMwxc.mjs.map} +1 -1
  133. package/dist/{round2-DOA3rnV-.mjs → round2-mF6UlkT-.mjs} +6 -6
  134. package/dist/{round2-DOA3rnV-.mjs.map → round2-mF6UlkT-.mjs.map} +1 -1
  135. package/package.json +14 -14
  136. package/dist/index-B3c-80VS.d.cts.map +0 -1
  137. package/dist/index-BgbSGpxn.d.mts.map +0 -1
  138. package/dist/index-C8QeHNwa.d.cts.map +0 -1
  139. package/dist/index-D3QTWkEm.d.mts.map +0 -1
  140. package/dist/index-DVbWyOs7.d.mts.map +0 -1
  141. package/dist/index-F1iNEAJR.d.cts.map +0 -1
  142. package/dist/registry-9puTaRrD.cjs.map +0 -1
  143. package/dist/registry-BpCwtrRt.mjs.map +0 -1
  144. package/dist/storage-B-Gu68-O.cjs +0 -79
  145. package/dist/storage-B-Gu68-O.cjs.map +0 -1
  146. package/dist/storage-Bkkliz0K.mjs +0 -74
  147. package/dist/storage-Bkkliz0K.mjs.map +0 -1
  148. /package/dist/{chunk-CZWwpsFl.cjs → chunk-DakpK96I.cjs} +0 -0
  149. /package/dist/{chunk-CjcI7cDX.mjs → chunk-z9aeyW2b.mjs} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"round1-BHBjru1m.cjs","names":["getWithIndicator","isVerbose","CborDate","SealedResponse","ARID","JSONWrapper","serde","parallelFetch","SealedRequest","Envelope","parallelSend","PendingRequests","groupStateDir","path","putWithIndicator","resolveRegistryPath","Registry","parseAridUr"],"sources":["../src/cmd/dkg/coordinator/round1.ts"],"sourcesContent":["/**\n * Copyright © 2023-2026 Blockchain Commons, LLC\n * Copyright © 2025-2026 Parity Technologies\n *\n *\n * DKG coordinator round 1 command.\n *\n * Port of cmd/dkg/coordinator/round1.rs from frost-hubert-rust.\n *\n * @module\n */\n\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\n\nimport { ARID, JSON as JSONWrapper, type PrivateKeys, type XID } from \"@bcts/components\";\nimport { CborDate } from \"@bcts/dcbor\";\nimport { Envelope } from \"@bcts/envelope\";\nimport { SealedRequest, SealedResponse } from \"@bcts/gstp\";\nimport type { XIDDocument } from \"@bcts/xid\";\n\nimport {\n type GroupRecord,\n type OwnerRecord,\n PendingRequests,\n Registry,\n resolveRegistryPath,\n} from \"../../../registry/index.js\";\nimport { getWithIndicator, putWithIndicator } from \"../../busy.js\";\nimport { groupStateDir, isVerbose } from \"../../common.js\";\nimport {\n type CollectionResult,\n parallelFetch,\n parallelSend,\n type ParallelFetchConfig,\n} from \"../../parallel.js\";\nimport { type StorageClient } from \"../../storage.js\";\nimport { parseAridUr } from \"../common.js\";\nimport { type DkgRound1Package } from \"../../../frost/index.js\";\nimport { serde } from \"@frosts/ed25519\";\n\n/**\n * Options for the DKG round1 command.\n */\nexport interface DkgRound1Options {\n registryPath?: string;\n groupId: string;\n parallel?: boolean;\n timeoutSeconds?: number;\n preview?: boolean;\n verbose?: boolean;\n}\n\n/**\n * Result of the DKG round1 command.\n */\nexport interface DkgRound1Result {\n accepted: number;\n rejected: number;\n errors: number;\n timeouts: number;\n}\n\n// -----------------------------------------------------------------------------\n// Context and result types\n// -----------------------------------------------------------------------------\n\n/**\n * Context for round 1 collection operations.\n */\ninterface Round1Context {\n client: StorageClient;\n registryPath: string;\n registry: Registry;\n ownerDoc: XIDDocument;\n groupId: ARID;\n}\n\n/**\n * Type alias for a round 1 package entry.\n */\ntype Round1Package = [XID, DkgRound1Package];\n\n/**\n * Type alias for next response ARID entry.\n */\ntype NextResponseArid = [XID, ARID];\n\n/**\n * Result of collecting round 1 responses.\n */\ninterface Round1Collection {\n packages: Round1Package[];\n nextResponseArids: NextResponseArid[];\n displayPath: string;\n}\n\n/**\n * Data extracted from a successful Round 1 response.\n */\ninterface Round1ResponseData {\n package: DkgRound1Package;\n nextResponseArid: ARID;\n}\n\n// -----------------------------------------------------------------------------\n// Validation\n// -----------------------------------------------------------------------------\n\n/**\n * Validate that the owner is the coordinator for this group.\n *\n * Port of `validate_coordinator()` from cmd/dkg/coordinator/round1.rs lines 201-214.\n */\nfunction validateCoordinator(groupRecord: GroupRecord, owner: OwnerRecord): void {\n if (groupRecord.coordinator().xid().urString() !== owner.xid().urString()) {\n throw new Error(\n `Only the coordinator can collect and send Round 2 requests. ` +\n `Coordinator: ${groupRecord.coordinator().xid().urString()}, ` +\n `Owner: ${owner.xid().urString()}`,\n );\n }\n}\n\n// -----------------------------------------------------------------------------\n// Sequential fetch implementation\n// -----------------------------------------------------------------------------\n\n/**\n * Fetch a single round 1 response from storage.\n *\n * Port of `fetch_and_validate_response()` from cmd/dkg/coordinator/round1.rs lines 512-566.\n */\nasync function fetchRound1Response(\n client: StorageClient,\n responseArid: ARID,\n timeout: number | undefined,\n coordinator: XIDDocument,\n expectedGroupId: ARID,\n participantName: string,\n): Promise<[DkgRound1Package, ARID]> {\n const envelope = await getWithIndicator(\n client,\n responseArid,\n participantName,\n timeout,\n isVerbose(),\n );\n\n if (envelope === undefined) {\n throw new Error(\"Response not found in Hubert storage\");\n }\n\n const coordinatorPrivateKeys = coordinator.inceptionPrivateKeys();\n if (coordinatorPrivateKeys === undefined) {\n throw new Error(\"Coordinator XID document has no inception private keys\");\n }\n\n const now = CborDate.now().datetime();\n const sealedResponse = SealedResponse.tryFromEncryptedEnvelope(\n envelope,\n undefined,\n now,\n coordinatorPrivateKeys,\n );\n\n if (sealedResponse.isErr()) {\n const error = sealedResponse.error();\n const reasonEnvelope = error.objectForPredicate(\"reason\");\n const reason =\n reasonEnvelope !== undefined\n ? reasonEnvelope.extractSubject((cbor) => cbor.toText())\n : \"unknown reason\";\n throw new Error(`Participant rejected invite: ${reason}`);\n }\n\n const result = sealedResponse.result();\n validateRound1Response(result, expectedGroupId);\n\n const nextResponseArid = result.tryObjectForPredicate<ARID>(\"response_arid\", (cbor) => {\n return ARID.fromTaggedCbor(cbor);\n });\n\n const round1Package = extractRound1Package(result);\n\n return [round1Package, nextResponseArid];\n}\n\n/**\n * Validate a round 1 response envelope.\n *\n * Port of `validate_round1_response()` from cmd/dkg/coordinator/round1.rs lines 568-586.\n */\nfunction validateRound1Response(result: Envelope, expectedGroupId: ARID): void {\n result.checkSubjectUnit();\n result.checkType(\"dkgRound1Response\");\n\n const groupId = result.tryObjectForPredicate<ARID>(\"group\", (cbor) => {\n return ARID.fromTaggedCbor(cbor);\n });\n\n if (groupId.urString() !== expectedGroupId.urString()) {\n throw new Error(\n `Response group ID ${groupId.urString()} does not match expected ${expectedGroupId.urString()}`,\n );\n }\n}\n\n/**\n * Extract a round 1 package from a response envelope.\n *\n * Port of `extract_round1_package()` from cmd/dkg/coordinator/round1.rs lines 588-598.\n */\nfunction extractRound1Package(result: Envelope): DkgRound1Package {\n const round1Envelope = result.objectForPredicate(\"round1_package\");\n if (round1Envelope === undefined) {\n throw new Error(\"round1_package missing from response\");\n }\n\n const round1Json = round1Envelope.extractSubject<JSONWrapper>((cbor) => {\n return JSONWrapper.fromTaggedCbor(cbor);\n });\n\n const jsonStr = new TextDecoder().decode(round1Json.asBytes());\n const jsonObj = globalThis.JSON.parse(jsonStr) as Record<string, unknown>;\n return serde.round1PackageFromJson(jsonObj);\n}\n\n/**\n * Validate and extract data from a round 1 response (for parallel fetch).\n *\n * Port of `validate_and_extract_round1_response()` from cmd/dkg/coordinator/round1.rs lines 674-707.\n */\nfunction validateAndExtractRound1Response(\n envelope: Envelope,\n coordinatorKeys: PrivateKeys,\n expectedGroupId: ARID,\n): Round1ResponseData | { rejected: string } {\n const now = CborDate.now().datetime();\n const sealedResponse = SealedResponse.tryFromEncryptedEnvelope(\n envelope,\n undefined,\n now,\n coordinatorKeys,\n );\n\n if (sealedResponse.isErr()) {\n const error = sealedResponse.error();\n const reasonEnvelope = error.objectForPredicate(\"reason\");\n const reason =\n reasonEnvelope !== undefined\n ? reasonEnvelope.extractSubject((cbor) => cbor.toText())\n : \"unknown reason\";\n return { rejected: `Participant rejected invite: ${reason}` };\n }\n\n const result = sealedResponse.result();\n validateRound1Response(result, expectedGroupId);\n\n const nextResponseArid = result.tryObjectForPredicate<ARID>(\"response_arid\", (cbor) => {\n return ARID.fromTaggedCbor(cbor);\n });\n\n const pkg = extractRound1Package(result);\n\n return { package: pkg, nextResponseArid };\n}\n\n// -----------------------------------------------------------------------------\n// Parallel collection\n// -----------------------------------------------------------------------------\n\n/**\n * Collect Round 1 responses in parallel with progress display.\n *\n * Port of `collect_round1_responses_parallel()` from cmd/dkg/coordinator/round1.rs lines 636-671.\n */\nasync function collectRound1Parallel(\n client: StorageClient,\n registry: Registry,\n pendingRequests: PendingRequests,\n coordinator: XIDDocument,\n expectedGroupId: ARID,\n timeout: number | undefined,\n): Promise<CollectionResult<Round1ResponseData>> {\n const requests: [XID, ARID, string][] = [];\n for (const [xid, arid] of pendingRequests.iterCollect()) {\n const participant = registry.participant(xid);\n const name = participant?.petName() ?? xid.urString();\n requests.push([xid, arid, name]);\n }\n\n const coordinatorKeys = coordinator.inceptionPrivateKeys();\n if (coordinatorKeys === undefined) {\n throw new Error(\"Missing coordinator private keys\");\n }\n\n const config: ParallelFetchConfig = { timeoutSeconds: timeout };\n const groupId = expectedGroupId;\n\n return parallelFetch(\n client,\n requests,\n (envelope: Envelope, _xid: XID) => {\n return validateAndExtractRound1Response(envelope, coordinatorKeys, groupId);\n },\n config,\n );\n}\n\n// -----------------------------------------------------------------------------\n// Round 2 request building\n// -----------------------------------------------------------------------------\n\n/**\n * Build a Round 2 request for a single participant.\n *\n * Port of `build_round2_request_for_participant()` from cmd/dkg/coordinator/round1.rs lines 604-623.\n */\nfunction buildRound2RequestForParticipant(\n sender: XIDDocument,\n groupId: ARID,\n round1Packages: Round1Package[],\n responseArid: ARID,\n): SealedRequest {\n let request = SealedRequest.new(\"dkgRound2\", ARID.new(), sender)\n .withParameter(\"group\", groupId)\n .withParameter(\"responseArid\", responseArid);\n\n for (const [xid, pkg] of round1Packages) {\n const packageJson = serde.round1PackageToJson(pkg);\n const jsonStr = globalThis.JSON.stringify(packageJson);\n const jsonBytes = new TextEncoder().encode(jsonStr);\n const jsonWrapper = JSONWrapper.fromData(jsonBytes);\n const packageEnvelope = Envelope.new(jsonWrapper).addAssertion(\"participant\", xid);\n request = request.withParameter(\"round1Package\", packageEnvelope);\n }\n\n return request;\n}\n\n/**\n * Dispatch Round 2 requests in parallel.\n *\n * Port of `dispatch_round2_requests_parallel()` from cmd/dkg/coordinator/round1.rs lines 729-844.\n */\nasync function dispatchRound2RequestsParallel(\n client: StorageClient,\n registry: Registry,\n registryPath: string,\n coordinator: XIDDocument,\n groupId: ARID,\n successes: [XID, Round1ResponseData][],\n preview: boolean,\n): Promise<[string, string] | undefined> {\n const signerPrivateKeys = coordinator.inceptionPrivateKeys();\n if (signerPrivateKeys === undefined) {\n throw new Error(\"Coordinator XID document has no signing keys\");\n }\n\n const validUntil = new Date(Date.now() + 60 * 60 * 1000); // 1 hour from now\n\n // Build round1 packages list for request building\n const round1Packages: Round1Package[] = successes.map(([xid, data]) => [xid, data.package]);\n\n // Build participant info and messages\n const messages: [XID, ARID, Envelope, string][] = [];\n const collectArids: [XID, ARID][] = [];\n let previewOutput: [string, string] | undefined;\n\n for (const [xid, data] of successes) {\n const participant = registry.participant(xid);\n if (participant === undefined) {\n throw new Error(`Participant ${xid.urString()} not found in registry`);\n }\n const recipientDoc = participant.xidDocument();\n const participantName = participant.petName() ?? xid.urString();\n\n const collectFromArid = ARID.new();\n collectArids.push([xid, collectFromArid]);\n\n const request = buildRound2RequestForParticipant(\n coordinator,\n groupId,\n round1Packages,\n collectFromArid,\n );\n\n if (preview && previewOutput === undefined) {\n const unsealedEnvelope = request.toEnvelope(validUntil, signerPrivateKeys, undefined);\n previewOutput = [participantName, unsealedEnvelope.urString()];\n }\n\n const sealedEnvelope = request.toEnvelope(validUntil, signerPrivateKeys, recipientDoc);\n\n messages.push([xid, data.nextResponseArid, sealedEnvelope, participantName]);\n }\n\n // Blank line to separate get phase from put phase\n console.error();\n\n // Send all messages in parallel\n const sendResults = await parallelSend(client, messages, isVerbose());\n\n // Check for send failures\n const failures: [XID, string][] = [];\n for (const [xid, err] of sendResults) {\n if (err !== null) {\n failures.push([xid, err.message]);\n }\n }\n\n if (failures.length > 0) {\n for (const [xid, error] of failures) {\n console.error(`Failed to send to ${xid.urString()}: ${error}`);\n }\n throw new Error(`Failed to send Round 2 requests to ${failures.length} participants`);\n }\n\n // Update pending requests for Round 2 collection\n const newPendingRequests = new PendingRequests();\n for (const [xid, collectFromArid] of collectArids) {\n newPendingRequests.addCollectOnly(xid, collectFromArid);\n }\n const groupRecord = registry.groupMut(groupId);\n if (groupRecord === undefined) {\n throw new Error(\"Group not found in registry\");\n }\n groupRecord.setPendingRequests(newPendingRequests);\n registry.save(registryPath);\n\n return previewOutput;\n}\n\n// -----------------------------------------------------------------------------\n// Pending request updates\n// -----------------------------------------------------------------------------\n\n/**\n * Update pending requests from parallel collection results.\n *\n * Port of `update_pending_for_round2_from_collection()` from cmd/dkg/coordinator/round1.rs lines 710-726.\n */\nfunction updatePendingForRound2FromCollection(\n registry: Registry,\n registryPath: string,\n groupId: ARID,\n successes: [XID, Round1ResponseData][],\n): void {\n const newPending = new PendingRequests();\n for (const [xid, data] of successes) {\n newPending.addSendOnly(xid, data.nextResponseArid);\n }\n const groupRecord = registry.groupMut(groupId);\n if (groupRecord === undefined) {\n throw new Error(\"Group not found in registry\");\n }\n groupRecord.setPendingRequests(newPending);\n registry.save(registryPath);\n}\n\n// -----------------------------------------------------------------------------\n// Persistence\n// -----------------------------------------------------------------------------\n\n/**\n * Persist collected round 1 packages to disk.\n *\n * Port of `persist_round1_packages()` from cmd/dkg/coordinator/round1.rs lines 301-340.\n */\nfunction persistRound1Packages(\n registryPath: string,\n groupId: ARID,\n packages: Round1Package[],\n): string {\n const packagesDir = groupStateDir(registryPath, groupId.hex());\n fs.mkdirSync(packagesDir, { recursive: true });\n\n const round1PackagesPath = path.join(packagesDir, \"collected_round1.json\");\n const packagesJson: Record<string, unknown> = {};\n\n for (const [xid, pkg] of packages) {\n packagesJson[xid.urString()] = serde.round1PackageToJson(pkg);\n }\n\n fs.writeFileSync(round1PackagesPath, globalThis.JSON.stringify(packagesJson, null, 2));\n\n // Return display path (relative to cwd if possible)\n const cwd = process.cwd();\n if (round1PackagesPath.startsWith(cwd)) {\n return round1PackagesPath.slice(cwd.length + 1);\n }\n return round1PackagesPath;\n}\n\n// -----------------------------------------------------------------------------\n// Sequential collection\n// -----------------------------------------------------------------------------\n\n/**\n * Fetch all round 1 packages sequentially.\n *\n * Port of `fetch_all_round1_packages()` from cmd/dkg/coordinator/round1.rs lines 243-299.\n */\nasync function fetchAllRound1Packages(\n ctx: Round1Context,\n pendingRequests: PendingRequests,\n timeout: number | undefined,\n): Promise<[Round1Package[], NextResponseArid[]]> {\n const round1Packages: Round1Package[] = [];\n const nextResponseArids: NextResponseArid[] = [];\n const errors: [XID, string][] = [];\n\n for (const [participantXid, collectFromArid] of pendingRequests.iterCollect()) {\n const participant = ctx.registry.participant(participantXid);\n const participantName = participant?.petName() ?? participantXid.urString();\n\n try {\n const [pkg, nextArid] = await fetchRound1Response(\n ctx.client,\n collectFromArid,\n timeout,\n ctx.ownerDoc,\n ctx.groupId,\n participantName,\n );\n round1Packages.push([participantXid, pkg]);\n nextResponseArids.push([participantXid, nextArid]);\n } catch (e) {\n errors.push([participantXid, e instanceof Error ? e.message : String(e)]);\n }\n }\n\n if (errors.length > 0) {\n if (isVerbose()) {\n console.error();\n console.error(`Failed to collect from ${errors.length} participants:`);\n }\n for (const [xid, error] of errors) {\n console.error(` ${xid.urString()}: ${error}`);\n }\n throw new Error(\n `Round 1 collection incomplete: ${errors.length} of ${pendingRequests.len()} responses failed`,\n );\n }\n\n return [round1Packages, nextResponseArids];\n}\n\n/**\n * Collect round 1 responses sequentially.\n *\n * Port of `collect_round1_responses()` from cmd/dkg/coordinator/round1.rs lines 220-241.\n */\nasync function collectRound1Responses(\n ctx: Round1Context,\n pendingRequests: PendingRequests,\n timeout: number | undefined,\n): Promise<Round1Collection> {\n if (isVerbose()) {\n console.error(`Collecting Round 1 responses from ${pendingRequests.len()} participants...`);\n }\n\n const [packages, nextResponseArids] = await fetchAllRound1Packages(ctx, pendingRequests, timeout);\n\n const displayPath = persistRound1Packages(ctx.registryPath, ctx.groupId, packages);\n\n updatePendingForRound2(ctx, nextResponseArids);\n\n return { packages, nextResponseArids, displayPath };\n}\n\n/**\n * Update pending requests for round 2 (sequential path).\n *\n * Port of `update_pending_for_round2()` from cmd/dkg/coordinator/round1.rs lines 342-357.\n */\nfunction updatePendingForRound2(ctx: Round1Context, nextResponseArids: NextResponseArid[]): void {\n const newPending = new PendingRequests();\n for (const [xid, sendToArid] of nextResponseArids) {\n newPending.addSendOnly(xid, sendToArid);\n }\n const groupRecord = ctx.registry.groupMut(ctx.groupId);\n if (groupRecord === undefined) {\n throw new Error(\"Group not found in registry\");\n }\n groupRecord.setPendingRequests(newPending);\n ctx.registry.save(ctx.registryPath);\n}\n\n// -----------------------------------------------------------------------------\n// Round 2 dispatch (sequential)\n// -----------------------------------------------------------------------------\n\n/**\n * Build participant info for round 2 dispatch.\n *\n * Port of `build_round2_participant_info()` from cmd/dkg/coordinator/round1.rs lines 438-458.\n */\nfunction buildRound2ParticipantInfo(\n registry: Registry,\n nextResponseArids: NextResponseArid[],\n): [XID, XIDDocument, ARID, ARID][] {\n return nextResponseArids.map(([xid, sendToArid]) => {\n const participant = registry.participant(xid);\n if (participant === undefined) {\n throw new Error(`Participant ${xid.urString()} not found in registry`);\n }\n const doc = participant.xidDocument();\n const collectFromArid = ARID.new();\n return [xid, doc, sendToArid, collectFromArid];\n });\n}\n\n/**\n * Update pending for round 2 collection (sequential path).\n *\n * Port of `update_pending_for_round2_collection()` from cmd/dkg/coordinator/round1.rs lines 460-475.\n */\nfunction updatePendingForRound2Collection(\n ctx: Round1Context,\n participantInfo: [XID, XIDDocument, ARID, ARID][],\n): void {\n const newPendingRequests = new PendingRequests();\n for (const [xid, , , collectFromArid] of participantInfo) {\n newPendingRequests.addCollectOnly(xid, collectFromArid);\n }\n const groupRecord = ctx.registry.groupMut(ctx.groupId);\n if (groupRecord === undefined) {\n throw new Error(\"Group not found in registry\");\n }\n groupRecord.setPendingRequests(newPendingRequests);\n ctx.registry.save(ctx.registryPath);\n}\n\n/**\n * Dispatch Round 2 requests sequentially.\n *\n * Port of `dispatch_round2_requests()` from cmd/dkg/coordinator/round1.rs lines 363-436.\n */\nasync function dispatchRound2Requests(\n ctx: Round1Context,\n collection: Round1Collection,\n preview: boolean,\n): Promise<[string, string] | undefined> {\n const signerPrivateKeys = ctx.ownerDoc.inceptionPrivateKeys();\n if (signerPrivateKeys === undefined) {\n throw new Error(\"Coordinator XID document has no signing keys\");\n }\n\n const validUntil = new Date(Date.now() + 60 * 60 * 1000); // 1 hour from now\n\n const participantInfo = buildRound2ParticipantInfo(ctx.registry, collection.nextResponseArids);\n\n if (isVerbose()) {\n console.error(`Sending Round 2 requests to ${participantInfo.length} participants...`);\n } else {\n // Blank line to separate get phase from put phase\n console.error();\n }\n\n let previewOutput: [string, string] | undefined;\n\n for (const [xid, recipientDoc, sendToArid, collectFromArid] of participantInfo) {\n const participant = ctx.registry.participant(xid);\n const participantName = participant?.petName() ?? xid.urString();\n\n const request = buildRound2RequestForParticipant(\n ctx.ownerDoc,\n ctx.groupId,\n collection.packages,\n collectFromArid,\n );\n\n if (preview && previewOutput === undefined) {\n const unsealedEnvelope = request.toEnvelope(validUntil, signerPrivateKeys, undefined);\n previewOutput = [participantName, unsealedEnvelope.urString()];\n }\n\n const sealedEnvelope = request.toEnvelope(validUntil, signerPrivateKeys, recipientDoc);\n\n await putWithIndicator(ctx.client, sendToArid, sealedEnvelope, participantName, isVerbose());\n }\n\n updatePendingForRound2Collection(ctx, participantInfo);\n\n return previewOutput;\n}\n\n// -----------------------------------------------------------------------------\n// Output\n// -----------------------------------------------------------------------------\n\n/**\n * Print summary for sequential collection.\n *\n * Port of `print_summary()` from cmd/dkg/coordinator/round1.rs lines 481-506.\n */\nfunction printSummary(collection: Round1Collection, preview: [string, string] | undefined): void {\n if (preview !== undefined) {\n const [participantName, ur] = preview;\n if (isVerbose()) {\n console.error(`# Round 2 preview for ${participantName}`);\n console.error();\n }\n console.error(\n `Collected ${collection.packages.length} Round 1 packages to ${collection.displayPath} ` +\n `and sent ${collection.nextResponseArids.length} Round 2 requests.`,\n );\n console.log(ur);\n } else if (isVerbose()) {\n console.error();\n console.error(\n `Collected ${collection.packages.length} Round 1 packages to ${collection.displayPath} ` +\n `and sent ${collection.nextResponseArids.length} Round 2 requests.`,\n );\n }\n}\n\n/**\n * Print summary for parallel collection.\n *\n * Port of `print_summary_parallel()` from cmd/dkg/coordinator/round1.rs lines 847-901.\n */\nfunction printSummaryParallel(\n collection: CollectionResult<Round1ResponseData>,\n displayPath: string,\n preview: [string, string] | undefined,\n): void {\n // Report any failures\n if (collection.rejections.length > 0) {\n console.error();\n console.error(\"Rejections:\");\n for (const [xid, reason] of collection.rejections) {\n console.error(` ${xid.urString()}: ${reason}`);\n }\n }\n if (collection.errors.length > 0) {\n console.error();\n console.error(\"Errors:\");\n for (const [xid, error] of collection.errors) {\n console.error(` ${xid.urString()}: ${error}`);\n }\n }\n if (collection.timeouts.length > 0) {\n console.error();\n console.error(\"Timeouts:\");\n for (const xid of collection.timeouts) {\n console.error(` ${xid.urString()}`);\n }\n }\n\n if (!collection.allSucceeded()) {\n console.error();\n bailWithCollectionSummary(collection);\n }\n\n if (preview !== undefined) {\n const [participantName, ur] = preview;\n if (isVerbose()) {\n console.error(`# Round 2 preview for ${participantName}`);\n console.error();\n }\n console.error(\n `Collected ${collection.successes.length} Round 1 packages to ${displayPath} ` +\n `and sent ${collection.successes.length} Round 2 requests.`,\n );\n console.log(ur);\n } else if (isVerbose()) {\n console.error();\n console.error(\n `Collected ${collection.successes.length} Round 1 packages to ${displayPath} ` +\n `and sent ${collection.successes.length} Round 2 requests.`,\n );\n }\n}\n\n/**\n * Print collection summary and throw error.\n *\n * Port of `bail_with_collection_summary()` from cmd/dkg/coordinator/round1.rs lines 903-913.\n */\nfunction bailWithCollectionSummary(collection: CollectionResult<Round1ResponseData>): never {\n const msg =\n `Round 1 collection incomplete: ${collection.successes.length} succeeded, ` +\n `${collection.rejections.length} rejected, ${collection.errors.length} errors, ` +\n `${collection.timeouts.length} timeouts`;\n console.error(msg);\n throw new Error(msg);\n}\n\n// -----------------------------------------------------------------------------\n// Main entry point\n// -----------------------------------------------------------------------------\n\n/**\n * Execute the DKG coordinator round 1 command.\n *\n * Collects commitment packages from participants.\n *\n * Port of `CommandArgs::exec()` from cmd/dkg/coordinator/round1.rs lines 59-173.\n */\nexport async function round1(\n client: StorageClient,\n options: DkgRound1Options,\n cwd: string,\n): Promise<DkgRound1Result> {\n const registryPath = resolveRegistryPath(options.registryPath, cwd);\n const registry = Registry.load(registryPath);\n\n const owner = registry.owner();\n if (owner === undefined) {\n throw new Error(\"Registry owner is required\");\n }\n const ownerDoc = owner.xidDocument();\n\n const groupId = parseAridUr(options.groupId);\n const groupRecord = registry.group(groupId);\n\n if (groupRecord === undefined) {\n throw new Error(`Group ${options.groupId} not found in registry`);\n }\n\n validateCoordinator(groupRecord, owner);\n\n const pendingRequests = groupRecord.pendingRequests();\n if (pendingRequests.isEmpty()) {\n throw new Error(\"No pending requests for this group. Round 1 may already be collected.\");\n }\n\n if (options.parallel === true) {\n // Parallel path with progress display\n const collection = await collectRound1Parallel(\n client,\n registry,\n pendingRequests,\n ownerDoc,\n groupId,\n options.timeoutSeconds,\n );\n\n // Extract packages for persistence\n const packages: Round1Package[] = collection.successes.map(([xid, data]) => [\n xid,\n data.package,\n ]);\n\n const displayPath = persistRound1Packages(registryPath, groupId, packages);\n\n updatePendingForRound2FromCollection(registry, registryPath, groupId, collection.successes);\n\n const preview = await dispatchRound2RequestsParallel(\n client,\n registry,\n registryPath,\n ownerDoc,\n groupId,\n collection.successes,\n options.preview ?? false,\n );\n\n printSummaryParallel(collection, displayPath, preview);\n\n return {\n accepted: collection.successes.length,\n rejected: collection.rejections.length,\n errors: collection.errors.length,\n timeouts: collection.timeouts.length,\n };\n } else {\n // Sequential path (original behavior)\n const ctx: Round1Context = {\n client,\n registryPath,\n registry,\n ownerDoc,\n groupId,\n };\n\n const collection = await collectRound1Responses(ctx, pendingRequests, options.timeoutSeconds);\n\n const preview = await dispatchRound2Requests(ctx, collection, options.preview ?? false);\n\n printSummary(collection, preview);\n\n return {\n accepted: collection.packages.length,\n rejected: 0,\n errors: 0,\n timeouts: 0,\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkHA,SAAS,oBAAoB,aAA0B,OAA0B;AAC/E,KAAI,YAAY,aAAa,CAAC,KAAK,CAAC,UAAU,KAAK,MAAM,KAAK,CAAC,UAAU,CACvE,OAAM,IAAI,MACR,4EACkB,YAAY,aAAa,CAAC,KAAK,CAAC,UAAU,CAAC,WACjD,MAAM,KAAK,CAAC,UAAU,GACnC;;;;;;;AAaL,eAAe,oBACb,QACA,cACA,SACA,aACA,iBACA,iBACmC;CACnC,MAAM,WAAW,MAAMA,aAAAA,iBACrB,QACA,cACA,iBACA,SACAC,eAAAA,WAAW,CACZ;AAED,KAAI,aAAa,KAAA,EACf,O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,QAAQ,WAAW,MACpB,CAEqD;AAEtD,SAAO;GACL,UAAU,WAAW,UAAU;GAC/B,UAAU,WAAW,WAAW;GAChC,QAAQ,WAAW,OAAO;GAC1B,UAAU,WAAW,SAAS;GAC/B;QACI;EAEL,MAAM,MAAqB;GACzB;GACA;GACA;GACA;GACA;GACD;EAED,MAAM,aAAa,MAAM,uBAAuB,KAAK,iBAAiB,QAAQ,eAAe;AAI7F,eAAa,YAAY,MAFH,uBAAuB,KAAK,YAAY,QAAQ,WAAW,MAAM,CAEtD;AAEjC,SAAO;GACL,UAAU,WAAW,SAAS;GAC9B,UAAU;GACV,QAAQ;GACR,UAAU;GACX"}
1
+ {"version":3,"file":"round1-9FAqFvL5.cjs","names":["getWithIndicator","isVerbose","CborDate","SealedResponse","ARID","JSONWrapper","serde","parallelFetch","SealedRequest","Envelope","parallelSend","PendingRequests","groupStateDir","path","putWithIndicator","resolveRegistryPath","Registry","parseAridUr"],"sources":["../src/cmd/dkg/coordinator/round1.ts"],"sourcesContent":["/**\n * Copyright © 2023-2026 Blockchain Commons, LLC\n * Copyright © 2025-2026 Parity Technologies\n *\n *\n * DKG coordinator round 1 command.\n *\n * Port of cmd/dkg/coordinator/round1.rs from frost-hubert-rust.\n *\n * @module\n */\n\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\n\nimport { ARID, JSON as JSONWrapper, type PrivateKeys, type XID } from \"@bcts/components\";\nimport { CborDate } from \"@bcts/dcbor\";\nimport { Envelope } from \"@bcts/envelope\";\nimport { SealedRequest, SealedResponse } from \"@bcts/gstp\";\nimport type { XIDDocument } from \"@bcts/xid\";\n\nimport {\n type GroupRecord,\n type OwnerRecord,\n PendingRequests,\n Registry,\n resolveRegistryPath,\n} from \"../../../registry/index.js\";\nimport { getWithIndicator, putWithIndicator } from \"../../busy.js\";\nimport { groupStateDir, isVerbose } from \"../../common.js\";\nimport {\n type CollectionResult,\n parallelFetch,\n parallelSend,\n type ParallelFetchConfig,\n} from \"../../parallel.js\";\nimport { type StorageClient } from \"../../storage.js\";\nimport { parseAridUr } from \"../common.js\";\nimport { type DkgRound1Package } from \"../../../frost/index.js\";\nimport { serde } from \"@frosts/ed25519\";\n\n/**\n * Options for the DKG round1 command.\n */\nexport interface DkgRound1Options {\n registryPath?: string;\n groupId: string;\n parallel?: boolean;\n timeoutSeconds?: number;\n preview?: boolean;\n verbose?: boolean;\n}\n\n/**\n * Result of the DKG round1 command.\n */\nexport interface DkgRound1Result {\n accepted: number;\n rejected: number;\n errors: number;\n timeouts: number;\n}\n\n// -----------------------------------------------------------------------------\n// Context and result types\n// -----------------------------------------------------------------------------\n\n/**\n * Context for round 1 collection operations.\n */\ninterface Round1Context {\n client: StorageClient;\n registryPath: string;\n registry: Registry;\n ownerDoc: XIDDocument;\n groupId: ARID;\n}\n\n/**\n * Type alias for a round 1 package entry.\n */\ntype Round1Package = [XID, DkgRound1Package];\n\n/**\n * Type alias for next response ARID entry.\n */\ntype NextResponseArid = [XID, ARID];\n\n/**\n * Result of collecting round 1 responses.\n */\ninterface Round1Collection {\n packages: Round1Package[];\n nextResponseArids: NextResponseArid[];\n displayPath: string;\n}\n\n/**\n * Data extracted from a successful Round 1 response.\n */\ninterface Round1ResponseData {\n package: DkgRound1Package;\n nextResponseArid: ARID;\n}\n\n// -----------------------------------------------------------------------------\n// Validation\n// -----------------------------------------------------------------------------\n\n/**\n * Validate that the owner is the coordinator for this group.\n *\n * Port of `validate_coordinator()` from cmd/dkg/coordinator/round1.rs lines 201-214.\n */\nfunction validateCoordinator(groupRecord: GroupRecord, owner: OwnerRecord): void {\n if (groupRecord.coordinator().xid().urString() !== owner.xid().urString()) {\n throw new Error(\n `Only the coordinator can collect and send Round 2 requests. ` +\n `Coordinator: ${groupRecord.coordinator().xid().urString()}, ` +\n `Owner: ${owner.xid().urString()}`,\n );\n }\n}\n\n// -----------------------------------------------------------------------------\n// Sequential fetch implementation\n// -----------------------------------------------------------------------------\n\n/**\n * Fetch a single round 1 response from storage.\n *\n * Port of `fetch_and_validate_response()` from cmd/dkg/coordinator/round1.rs lines 512-566.\n */\nasync function fetchRound1Response(\n client: StorageClient,\n responseArid: ARID,\n timeout: number | undefined,\n coordinator: XIDDocument,\n expectedGroupId: ARID,\n participantName: string,\n): Promise<[DkgRound1Package, ARID]> {\n const envelope = await getWithIndicator(\n client,\n responseArid,\n participantName,\n timeout,\n isVerbose(),\n );\n\n if (envelope === undefined) {\n throw new Error(\"Response not found in Hubert storage\");\n }\n\n const coordinatorPrivateKeys = coordinator.inceptionPrivateKeys();\n if (coordinatorPrivateKeys === undefined) {\n throw new Error(\"Coordinator XID document has no inception private keys\");\n }\n\n const now = CborDate.now().datetime();\n const sealedResponse = SealedResponse.tryFromEncryptedEnvelope(\n envelope,\n undefined,\n now,\n coordinatorPrivateKeys,\n );\n\n if (sealedResponse.isErr()) {\n const error = sealedResponse.error();\n const reasonEnvelope = error.objectForPredicate(\"reason\");\n const reason =\n reasonEnvelope !== undefined\n ? reasonEnvelope.extractSubject((cbor) => cbor.toText())\n : \"unknown reason\";\n throw new Error(`Participant rejected invite: ${reason}`);\n }\n\n const result = sealedResponse.result();\n validateRound1Response(result, expectedGroupId);\n\n const nextResponseArid = result.tryObjectForPredicate<ARID>(\"response_arid\", (cbor) => {\n return ARID.fromTaggedCbor(cbor);\n });\n\n const round1Package = extractRound1Package(result);\n\n return [round1Package, nextResponseArid];\n}\n\n/**\n * Validate a round 1 response envelope.\n *\n * Port of `validate_round1_response()` from cmd/dkg/coordinator/round1.rs lines 568-586.\n */\nfunction validateRound1Response(result: Envelope, expectedGroupId: ARID): void {\n result.checkSubjectUnit();\n result.checkType(\"dkgRound1Response\");\n\n const groupId = result.tryObjectForPredicate<ARID>(\"group\", (cbor) => {\n return ARID.fromTaggedCbor(cbor);\n });\n\n if (groupId.urString() !== expectedGroupId.urString()) {\n throw new Error(\n `Response group ID ${groupId.urString()} does not match expected ${expectedGroupId.urString()}`,\n );\n }\n}\n\n/**\n * Extract a round 1 package from a response envelope.\n *\n * Port of `extract_round1_package()` from cmd/dkg/coordinator/round1.rs lines 588-598.\n */\nfunction extractRound1Package(result: Envelope): DkgRound1Package {\n const round1Envelope = result.objectForPredicate(\"round1_package\");\n if (round1Envelope === undefined) {\n throw new Error(\"round1_package missing from response\");\n }\n\n const round1Json = round1Envelope.extractSubject<JSONWrapper>((cbor) => {\n return JSONWrapper.fromTaggedCbor(cbor);\n });\n\n const jsonStr = new TextDecoder().decode(round1Json.asBytes());\n const jsonObj = globalThis.JSON.parse(jsonStr) as Record<string, unknown>;\n return serde.round1PackageFromJson(jsonObj);\n}\n\n/**\n * Validate and extract data from a round 1 response (for parallel fetch).\n *\n * Port of `validate_and_extract_round1_response()` from cmd/dkg/coordinator/round1.rs lines 674-707.\n */\nfunction validateAndExtractRound1Response(\n envelope: Envelope,\n coordinatorKeys: PrivateKeys,\n expectedGroupId: ARID,\n): Round1ResponseData | { rejected: string } {\n const now = CborDate.now().datetime();\n const sealedResponse = SealedResponse.tryFromEncryptedEnvelope(\n envelope,\n undefined,\n now,\n coordinatorKeys,\n );\n\n if (sealedResponse.isErr()) {\n const error = sealedResponse.error();\n const reasonEnvelope = error.objectForPredicate(\"reason\");\n const reason =\n reasonEnvelope !== undefined\n ? reasonEnvelope.extractSubject((cbor) => cbor.toText())\n : \"unknown reason\";\n return { rejected: `Participant rejected invite: ${reason}` };\n }\n\n const result = sealedResponse.result();\n validateRound1Response(result, expectedGroupId);\n\n const nextResponseArid = result.tryObjectForPredicate<ARID>(\"response_arid\", (cbor) => {\n return ARID.fromTaggedCbor(cbor);\n });\n\n const pkg = extractRound1Package(result);\n\n return { package: pkg, nextResponseArid };\n}\n\n// -----------------------------------------------------------------------------\n// Parallel collection\n// -----------------------------------------------------------------------------\n\n/**\n * Collect Round 1 responses in parallel with progress display.\n *\n * Port of `collect_round1_responses_parallel()` from cmd/dkg/coordinator/round1.rs lines 636-671.\n */\nasync function collectRound1Parallel(\n client: StorageClient,\n registry: Registry,\n pendingRequests: PendingRequests,\n coordinator: XIDDocument,\n expectedGroupId: ARID,\n timeout: number | undefined,\n): Promise<CollectionResult<Round1ResponseData>> {\n const requests: [XID, ARID, string][] = [];\n for (const [xid, arid] of pendingRequests.iterCollect()) {\n const participant = registry.participant(xid);\n const name = participant?.petName() ?? xid.urString();\n requests.push([xid, arid, name]);\n }\n\n const coordinatorKeys = coordinator.inceptionPrivateKeys();\n if (coordinatorKeys === undefined) {\n throw new Error(\"Missing coordinator private keys\");\n }\n\n const config: ParallelFetchConfig = { timeoutSeconds: timeout };\n const groupId = expectedGroupId;\n\n return parallelFetch(\n client,\n requests,\n (envelope: Envelope, _xid: XID) => {\n return validateAndExtractRound1Response(envelope, coordinatorKeys, groupId);\n },\n config,\n );\n}\n\n// -----------------------------------------------------------------------------\n// Round 2 request building\n// -----------------------------------------------------------------------------\n\n/**\n * Build a Round 2 request for a single participant.\n *\n * Port of `build_round2_request_for_participant()` from cmd/dkg/coordinator/round1.rs lines 604-623.\n */\nfunction buildRound2RequestForParticipant(\n sender: XIDDocument,\n groupId: ARID,\n round1Packages: Round1Package[],\n responseArid: ARID,\n): SealedRequest {\n let request = SealedRequest.new(\"dkgRound2\", ARID.new(), sender)\n .withParameter(\"group\", groupId)\n .withParameter(\"responseArid\", responseArid);\n\n for (const [xid, pkg] of round1Packages) {\n const packageJson = serde.round1PackageToJson(pkg);\n const jsonStr = globalThis.JSON.stringify(packageJson);\n const jsonBytes = new TextEncoder().encode(jsonStr);\n const jsonWrapper = JSONWrapper.fromData(jsonBytes);\n const packageEnvelope = Envelope.new(jsonWrapper).addAssertion(\"participant\", xid);\n request = request.withParameter(\"round1Package\", packageEnvelope);\n }\n\n return request;\n}\n\n/**\n * Dispatch Round 2 requests in parallel.\n *\n * Port of `dispatch_round2_requests_parallel()` from cmd/dkg/coordinator/round1.rs lines 729-844.\n */\nasync function dispatchRound2RequestsParallel(\n client: StorageClient,\n registry: Registry,\n registryPath: string,\n coordinator: XIDDocument,\n groupId: ARID,\n successes: [XID, Round1ResponseData][],\n preview: boolean,\n): Promise<[string, string] | undefined> {\n const signerPrivateKeys = coordinator.inceptionPrivateKeys();\n if (signerPrivateKeys === undefined) {\n throw new Error(\"Coordinator XID document has no signing keys\");\n }\n\n const validUntil = new Date(Date.now() + 60 * 60 * 1000); // 1 hour from now\n\n // Build round1 packages list for request building\n const round1Packages: Round1Package[] = successes.map(([xid, data]) => [xid, data.package]);\n\n // Build participant info and messages\n const messages: [XID, ARID, Envelope, string][] = [];\n const collectArids: [XID, ARID][] = [];\n let previewOutput: [string, string] | undefined;\n\n for (const [xid, data] of successes) {\n const participant = registry.participant(xid);\n if (participant === undefined) {\n throw new Error(`Participant ${xid.urString()} not found in registry`);\n }\n const recipientDoc = participant.xidDocument();\n const participantName = participant.petName() ?? xid.urString();\n\n const collectFromArid = ARID.new();\n collectArids.push([xid, collectFromArid]);\n\n const request = buildRound2RequestForParticipant(\n coordinator,\n groupId,\n round1Packages,\n collectFromArid,\n );\n\n if (preview && previewOutput === undefined) {\n const unsealedEnvelope = request.toEnvelope(validUntil, signerPrivateKeys, undefined);\n previewOutput = [participantName, unsealedEnvelope.urString()];\n }\n\n const sealedEnvelope = request.toEnvelope(validUntil, signerPrivateKeys, recipientDoc);\n\n messages.push([xid, data.nextResponseArid, sealedEnvelope, participantName]);\n }\n\n // Blank line to separate get phase from put phase\n console.error();\n\n // Send all messages in parallel\n const sendResults = await parallelSend(client, messages, isVerbose());\n\n // Check for send failures\n const failures: [XID, string][] = [];\n for (const [xid, err] of sendResults) {\n if (err !== null) {\n failures.push([xid, err.message]);\n }\n }\n\n if (failures.length > 0) {\n for (const [xid, error] of failures) {\n console.error(`Failed to send to ${xid.urString()}: ${error}`);\n }\n throw new Error(`Failed to send Round 2 requests to ${failures.length} participants`);\n }\n\n // Update pending requests for Round 2 collection\n const newPendingRequests = new PendingRequests();\n for (const [xid, collectFromArid] of collectArids) {\n newPendingRequests.addCollectOnly(xid, collectFromArid);\n }\n const groupRecord = registry.groupMut(groupId);\n if (groupRecord === undefined) {\n throw new Error(\"Group not found in registry\");\n }\n groupRecord.setPendingRequests(newPendingRequests);\n registry.save(registryPath);\n\n return previewOutput;\n}\n\n// -----------------------------------------------------------------------------\n// Pending request updates\n// -----------------------------------------------------------------------------\n\n/**\n * Update pending requests from parallel collection results.\n *\n * Port of `update_pending_for_round2_from_collection()` from cmd/dkg/coordinator/round1.rs lines 710-726.\n */\nfunction updatePendingForRound2FromCollection(\n registry: Registry,\n registryPath: string,\n groupId: ARID,\n successes: [XID, Round1ResponseData][],\n): void {\n const newPending = new PendingRequests();\n for (const [xid, data] of successes) {\n newPending.addSendOnly(xid, data.nextResponseArid);\n }\n const groupRecord = registry.groupMut(groupId);\n if (groupRecord === undefined) {\n throw new Error(\"Group not found in registry\");\n }\n groupRecord.setPendingRequests(newPending);\n registry.save(registryPath);\n}\n\n// -----------------------------------------------------------------------------\n// Persistence\n// -----------------------------------------------------------------------------\n\n/**\n * Persist collected round 1 packages to disk.\n *\n * Port of `persist_round1_packages()` from cmd/dkg/coordinator/round1.rs lines 301-340.\n */\nfunction persistRound1Packages(\n registryPath: string,\n groupId: ARID,\n packages: Round1Package[],\n): string {\n const packagesDir = groupStateDir(registryPath, groupId.hex());\n fs.mkdirSync(packagesDir, { recursive: true });\n\n const round1PackagesPath = path.join(packagesDir, \"collected_round1.json\");\n const packagesJson: Record<string, unknown> = {};\n\n for (const [xid, pkg] of packages) {\n packagesJson[xid.urString()] = serde.round1PackageToJson(pkg);\n }\n\n fs.writeFileSync(round1PackagesPath, globalThis.JSON.stringify(packagesJson, null, 2));\n\n // Return display path (relative to cwd if possible)\n const cwd = process.cwd();\n if (round1PackagesPath.startsWith(cwd)) {\n return round1PackagesPath.slice(cwd.length + 1);\n }\n return round1PackagesPath;\n}\n\n// -----------------------------------------------------------------------------\n// Sequential collection\n// -----------------------------------------------------------------------------\n\n/**\n * Fetch all round 1 packages sequentially.\n *\n * Port of `fetch_all_round1_packages()` from cmd/dkg/coordinator/round1.rs lines 243-299.\n */\nasync function fetchAllRound1Packages(\n ctx: Round1Context,\n pendingRequests: PendingRequests,\n timeout: number | undefined,\n): Promise<[Round1Package[], NextResponseArid[]]> {\n const round1Packages: Round1Package[] = [];\n const nextResponseArids: NextResponseArid[] = [];\n const errors: [XID, string][] = [];\n\n for (const [participantXid, collectFromArid] of pendingRequests.iterCollect()) {\n const participant = ctx.registry.participant(participantXid);\n const participantName = participant?.petName() ?? participantXid.urString();\n\n try {\n const [pkg, nextArid] = await fetchRound1Response(\n ctx.client,\n collectFromArid,\n timeout,\n ctx.ownerDoc,\n ctx.groupId,\n participantName,\n );\n round1Packages.push([participantXid, pkg]);\n nextResponseArids.push([participantXid, nextArid]);\n } catch (e) {\n errors.push([participantXid, e instanceof Error ? e.message : String(e)]);\n }\n }\n\n if (errors.length > 0) {\n if (isVerbose()) {\n console.error();\n console.error(`Failed to collect from ${errors.length} participants:`);\n }\n for (const [xid, error] of errors) {\n console.error(` ${xid.urString()}: ${error}`);\n }\n throw new Error(\n `Round 1 collection incomplete: ${errors.length} of ${pendingRequests.len()} responses failed`,\n );\n }\n\n return [round1Packages, nextResponseArids];\n}\n\n/**\n * Collect round 1 responses sequentially.\n *\n * Port of `collect_round1_responses()` from cmd/dkg/coordinator/round1.rs lines 220-241.\n */\nasync function collectRound1Responses(\n ctx: Round1Context,\n pendingRequests: PendingRequests,\n timeout: number | undefined,\n): Promise<Round1Collection> {\n if (isVerbose()) {\n console.error(`Collecting Round 1 responses from ${pendingRequests.len()} participants...`);\n }\n\n const [packages, nextResponseArids] = await fetchAllRound1Packages(ctx, pendingRequests, timeout);\n\n const displayPath = persistRound1Packages(ctx.registryPath, ctx.groupId, packages);\n\n updatePendingForRound2(ctx, nextResponseArids);\n\n return { packages, nextResponseArids, displayPath };\n}\n\n/**\n * Update pending requests for round 2 (sequential path).\n *\n * Port of `update_pending_for_round2()` from cmd/dkg/coordinator/round1.rs lines 342-357.\n */\nfunction updatePendingForRound2(ctx: Round1Context, nextResponseArids: NextResponseArid[]): void {\n const newPending = new PendingRequests();\n for (const [xid, sendToArid] of nextResponseArids) {\n newPending.addSendOnly(xid, sendToArid);\n }\n const groupRecord = ctx.registry.groupMut(ctx.groupId);\n if (groupRecord === undefined) {\n throw new Error(\"Group not found in registry\");\n }\n groupRecord.setPendingRequests(newPending);\n ctx.registry.save(ctx.registryPath);\n}\n\n// -----------------------------------------------------------------------------\n// Round 2 dispatch (sequential)\n// -----------------------------------------------------------------------------\n\n/**\n * Build participant info for round 2 dispatch.\n *\n * Port of `build_round2_participant_info()` from cmd/dkg/coordinator/round1.rs lines 438-458.\n */\nfunction buildRound2ParticipantInfo(\n registry: Registry,\n nextResponseArids: NextResponseArid[],\n): [XID, XIDDocument, ARID, ARID][] {\n return nextResponseArids.map(([xid, sendToArid]) => {\n const participant = registry.participant(xid);\n if (participant === undefined) {\n throw new Error(`Participant ${xid.urString()} not found in registry`);\n }\n const doc = participant.xidDocument();\n const collectFromArid = ARID.new();\n return [xid, doc, sendToArid, collectFromArid];\n });\n}\n\n/**\n * Update pending for round 2 collection (sequential path).\n *\n * Port of `update_pending_for_round2_collection()` from cmd/dkg/coordinator/round1.rs lines 460-475.\n */\nfunction updatePendingForRound2Collection(\n ctx: Round1Context,\n participantInfo: [XID, XIDDocument, ARID, ARID][],\n): void {\n const newPendingRequests = new PendingRequests();\n for (const [xid, , , collectFromArid] of participantInfo) {\n newPendingRequests.addCollectOnly(xid, collectFromArid);\n }\n const groupRecord = ctx.registry.groupMut(ctx.groupId);\n if (groupRecord === undefined) {\n throw new Error(\"Group not found in registry\");\n }\n groupRecord.setPendingRequests(newPendingRequests);\n ctx.registry.save(ctx.registryPath);\n}\n\n/**\n * Dispatch Round 2 requests sequentially.\n *\n * Port of `dispatch_round2_requests()` from cmd/dkg/coordinator/round1.rs lines 363-436.\n */\nasync function dispatchRound2Requests(\n ctx: Round1Context,\n collection: Round1Collection,\n preview: boolean,\n): Promise<[string, string] | undefined> {\n const signerPrivateKeys = ctx.ownerDoc.inceptionPrivateKeys();\n if (signerPrivateKeys === undefined) {\n throw new Error(\"Coordinator XID document has no signing keys\");\n }\n\n const validUntil = new Date(Date.now() + 60 * 60 * 1000); // 1 hour from now\n\n const participantInfo = buildRound2ParticipantInfo(ctx.registry, collection.nextResponseArids);\n\n if (isVerbose()) {\n console.error(`Sending Round 2 requests to ${participantInfo.length} participants...`);\n } else {\n // Blank line to separate get phase from put phase\n console.error();\n }\n\n let previewOutput: [string, string] | undefined;\n\n for (const [xid, recipientDoc, sendToArid, collectFromArid] of participantInfo) {\n const participant = ctx.registry.participant(xid);\n const participantName = participant?.petName() ?? xid.urString();\n\n const request = buildRound2RequestForParticipant(\n ctx.ownerDoc,\n ctx.groupId,\n collection.packages,\n collectFromArid,\n );\n\n if (preview && previewOutput === undefined) {\n const unsealedEnvelope = request.toEnvelope(validUntil, signerPrivateKeys, undefined);\n previewOutput = [participantName, unsealedEnvelope.urString()];\n }\n\n const sealedEnvelope = request.toEnvelope(validUntil, signerPrivateKeys, recipientDoc);\n\n await putWithIndicator(ctx.client, sendToArid, sealedEnvelope, participantName, isVerbose());\n }\n\n updatePendingForRound2Collection(ctx, participantInfo);\n\n return previewOutput;\n}\n\n// -----------------------------------------------------------------------------\n// Output\n// -----------------------------------------------------------------------------\n\n/**\n * Print summary for sequential collection.\n *\n * Port of `print_summary()` from cmd/dkg/coordinator/round1.rs lines 481-506.\n */\nfunction printSummary(collection: Round1Collection, preview: [string, string] | undefined): void {\n if (preview !== undefined) {\n const [participantName, ur] = preview;\n if (isVerbose()) {\n console.error(`# Round 2 preview for ${participantName}`);\n console.error();\n }\n console.error(\n `Collected ${collection.packages.length} Round 1 packages to ${collection.displayPath} ` +\n `and sent ${collection.nextResponseArids.length} Round 2 requests.`,\n );\n console.log(ur);\n } else if (isVerbose()) {\n console.error();\n console.error(\n `Collected ${collection.packages.length} Round 1 packages to ${collection.displayPath} ` +\n `and sent ${collection.nextResponseArids.length} Round 2 requests.`,\n );\n }\n}\n\n/**\n * Print summary for parallel collection.\n *\n * Port of `print_summary_parallel()` from cmd/dkg/coordinator/round1.rs lines 847-901.\n */\nfunction printSummaryParallel(\n collection: CollectionResult<Round1ResponseData>,\n displayPath: string,\n preview: [string, string] | undefined,\n): void {\n // Report any failures\n if (collection.rejections.length > 0) {\n console.error();\n console.error(\"Rejections:\");\n for (const [xid, reason] of collection.rejections) {\n console.error(` ${xid.urString()}: ${reason}`);\n }\n }\n if (collection.errors.length > 0) {\n console.error();\n console.error(\"Errors:\");\n for (const [xid, error] of collection.errors) {\n console.error(` ${xid.urString()}: ${error}`);\n }\n }\n if (collection.timeouts.length > 0) {\n console.error();\n console.error(\"Timeouts:\");\n for (const xid of collection.timeouts) {\n console.error(` ${xid.urString()}`);\n }\n }\n\n if (!collection.allSucceeded()) {\n console.error();\n bailWithCollectionSummary(collection);\n }\n\n if (preview !== undefined) {\n const [participantName, ur] = preview;\n if (isVerbose()) {\n console.error(`# Round 2 preview for ${participantName}`);\n console.error();\n }\n console.error(\n `Collected ${collection.successes.length} Round 1 packages to ${displayPath} ` +\n `and sent ${collection.successes.length} Round 2 requests.`,\n );\n console.log(ur);\n } else if (isVerbose()) {\n console.error();\n console.error(\n `Collected ${collection.successes.length} Round 1 packages to ${displayPath} ` +\n `and sent ${collection.successes.length} Round 2 requests.`,\n );\n }\n}\n\n/**\n * Print collection summary and throw error.\n *\n * Port of `bail_with_collection_summary()` from cmd/dkg/coordinator/round1.rs lines 903-913.\n */\nfunction bailWithCollectionSummary(collection: CollectionResult<Round1ResponseData>): never {\n const msg =\n `Round 1 collection incomplete: ${collection.successes.length} succeeded, ` +\n `${collection.rejections.length} rejected, ${collection.errors.length} errors, ` +\n `${collection.timeouts.length} timeouts`;\n console.error(msg);\n throw new Error(msg);\n}\n\n// -----------------------------------------------------------------------------\n// Main entry point\n// -----------------------------------------------------------------------------\n\n/**\n * Execute the DKG coordinator round 1 command.\n *\n * Collects commitment packages from participants.\n *\n * Port of `CommandArgs::exec()` from cmd/dkg/coordinator/round1.rs lines 59-173.\n */\nexport async function round1(\n client: StorageClient,\n options: DkgRound1Options,\n cwd: string,\n): Promise<DkgRound1Result> {\n const registryPath = resolveRegistryPath(options.registryPath, cwd);\n const registry = Registry.load(registryPath);\n\n const owner = registry.owner();\n if (owner === undefined) {\n throw new Error(\"Registry owner is required\");\n }\n const ownerDoc = owner.xidDocument();\n\n const groupId = parseAridUr(options.groupId);\n const groupRecord = registry.group(groupId);\n\n if (groupRecord === undefined) {\n throw new Error(`Group ${options.groupId} not found in registry`);\n }\n\n validateCoordinator(groupRecord, owner);\n\n const pendingRequests = groupRecord.pendingRequests();\n if (pendingRequests.isEmpty()) {\n throw new Error(\"No pending requests for this group. Round 1 may already be collected.\");\n }\n\n if (options.parallel === true) {\n // Parallel path with progress display\n const collection = await collectRound1Parallel(\n client,\n registry,\n pendingRequests,\n ownerDoc,\n groupId,\n options.timeoutSeconds,\n );\n\n // Extract packages for persistence\n const packages: Round1Package[] = collection.successes.map(([xid, data]) => [\n xid,\n data.package,\n ]);\n\n const displayPath = persistRound1Packages(registryPath, groupId, packages);\n\n updatePendingForRound2FromCollection(registry, registryPath, groupId, collection.successes);\n\n const preview = await dispatchRound2RequestsParallel(\n client,\n registry,\n registryPath,\n ownerDoc,\n groupId,\n collection.successes,\n options.preview ?? false,\n );\n\n printSummaryParallel(collection, displayPath, preview);\n\n return {\n accepted: collection.successes.length,\n rejected: collection.rejections.length,\n errors: collection.errors.length,\n timeouts: collection.timeouts.length,\n };\n } else {\n // Sequential path (original behavior)\n const ctx: Round1Context = {\n client,\n registryPath,\n registry,\n ownerDoc,\n groupId,\n };\n\n const collection = await collectRound1Responses(ctx, pendingRequests, options.timeoutSeconds);\n\n const preview = await dispatchRound2Requests(ctx, collection, options.preview ?? false);\n\n printSummary(collection, preview);\n\n return {\n accepted: collection.packages.length,\n rejected: 0,\n errors: 0,\n timeouts: 0,\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAM,cAAc,SAAS,MAAM,OAAO;CAE1C,IAAI,gBAAgB,KAAA,GAClB,MAAM,IAAI,MAAM,SAAS,QAAQ,QAAQ,uBAAuB;CAGlE,oBAAoB,aAAa,KAAK;CAEtC,MAAM,kBAAkB,YAAY,gBAAgB;CACpD,IAAI,gBAAgB,QAAQ,GAC1B,MAAM,IAAI,MAAM,uEAAuE;CAGzF,IAAI,QAAQ,aAAa,MAAM;EAE7B,MAAM,aAAa,MAAM,sBACvB,QACA,UACA,iBACA,UACA,SACA,QAAQ,cACV;EAQA,MAAM,cAAc,sBAAsB,cAAc,SALtB,WAAW,UAAU,KAAK,CAAC,KAAK,UAAU,CAC1E,KACA,KAAK,OACP,CAEwE,CAAC;EAEzE,qCAAqC,UAAU,cAAc,SAAS,WAAW,SAAS;EAY1F,qBAAqB,YAAY,aAAa,MAVxB,+BACpB,QACA,UACA,cACA,UACA,SACA,WAAW,WACX,QAAQ,WAAW,KACrB,CAEqD;EAErD,OAAO;GACL,UAAU,WAAW,UAAU;GAC/B,UAAU,WAAW,WAAW;GAChC,QAAQ,WAAW,OAAO;GAC1B,UAAU,WAAW,SAAS;EAChC;CACF,OAAO;EAEL,MAAM,MAAqB;GACzB;GACA;GACA;GACA;GACA;EACF;EAEA,MAAM,aAAa,MAAM,uBAAuB,KAAK,iBAAiB,QAAQ,cAAc;EAI5F,aAAa,YAAY,MAFH,uBAAuB,KAAK,YAAY,QAAQ,WAAW,KAAK,CAEtD;EAEhC,OAAO;GACL,UAAU,WAAW,SAAS;GAC9B,UAAU;GACV,QAAQ;GACR,UAAU;EACZ;CACF;AACF"}
@@ -1,10 +1,10 @@
1
- import { t as __exportAll } from "./chunk-CjcI7cDX.mjs";
1
+ import { t as __exportAll } from "./chunk-z9aeyW2b.mjs";
2
2
  import { Registry, resolveRegistryPath } from "./registry/index.mjs";
3
- import { c as parseAridUr } from "./common-CvH6dFvQ.mjs";
4
- import { n as putWithIndicator } from "./busy-DkM2jAIZ.mjs";
5
- import { t as createStorageClient } from "./storage-Bkkliz0K.mjs";
3
+ import { c as parseAridUr } from "./common-Cf1UvJaP.mjs";
4
+ import { n as putWithIndicator } from "./busy-BlU8_pS2.mjs";
5
+ import { i as createStorageClient } from "./registry-DGjs4qDK.mjs";
6
6
  import { createRng, deserializeKeyPackage, serializeSigningCommitments, serializeSigningNonces, signingRound1 } from "./frost/index.mjs";
7
- import { n as signingStateDir } from "./common-DUWvtc08.mjs";
7
+ import { n as signingStateDir } from "./common-DNrD_-EI.mjs";
8
8
  import { ARID, JSON as JSON$1, XID } from "@bcts/components";
9
9
  import { CborDate } from "@bcts/dcbor";
10
10
  import { Envelope, Function } from "@bcts/envelope";
@@ -205,4 +205,4 @@ async function round1(_client, options, cwd) {
205
205
  //#endregion
206
206
  export { round1_exports as n, round1 as t };
207
207
 
208
- //# sourceMappingURL=round1-CcQCGlIT.mjs.map
208
+ //# sourceMappingURL=round1-B8haiMM8.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"round1-CcQCGlIT.mjs","names":["EnvelopeFunction","JSONWrapper"],"sources":["../src/cmd/sign/participant/round1.ts"],"sourcesContent":["/**\n * Copyright © 2023-2026 Blockchain Commons, LLC\n * Copyright © 2025-2026 Parity Technologies\n *\n *\n * Sign participant round 1 command.\n *\n * Port of cmd/sign/participant/round1.rs from frost-hubert-rust.\n *\n * @module\n */\n\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\n\nimport { ARID, JSON as JSONWrapper, type PrivateKeys, XID } from \"@bcts/components\";\nimport { CborDate } from \"@bcts/dcbor\";\nimport { Envelope, Function as EnvelopeFunction } from \"@bcts/envelope\";\nimport { SealedRequest, SealedResponse } from \"@bcts/gstp\";\nimport type { XIDDocument } from \"@bcts/xid\";\n\nimport { Registry, resolveRegistryPath } from \"../../../registry/index.js\";\nimport { putWithIndicator } from \"../../busy.js\";\nimport { createStorageClient, type StorageClient, type StorageSelection } from \"../../storage.js\";\nimport { parseAridUr } from \"../../dkg/common.js\";\nimport { signingStateDir } from \"../common.js\";\nimport {\n signingRound1,\n deserializeKeyPackage,\n serializeSigningNonces,\n serializeSigningCommitments,\n createRng,\n type SerializedKeyPackage,\n type SerializedSigningNonces,\n type SerializedSigningCommitments,\n type Ed25519SigningNonces,\n type Ed25519SigningCommitments,\n} from \"../../../frost/index.js\";\n\n/**\n * Options for the sign round1 command.\n */\nexport interface SignRound1Options {\n registryPath?: string;\n sessionId: string;\n groupId?: string;\n preview?: boolean;\n rejectReason?: string;\n storageSelection?: StorageSelection;\n verbose?: boolean;\n}\n\n/**\n * Result of the sign round1 command.\n */\nexport interface SignRound1Result {\n accepted: boolean;\n listeningArid?: string;\n envelopeUr?: string;\n}\n\n/**\n * Persisted receive state from sign_receive.json.\n *\n * Port of `struct ReceiveState` from cmd/sign/participant/round1.rs.\n */\ninterface ReceiveState {\n groupId: ARID;\n coordinatorDoc: XIDDocument;\n responseArid: ARID;\n targetUr: string;\n participants: XID[];\n requestEnvelope: Envelope;\n}\n\n/**\n * Load receive state from persisted sign_receive.json.\n *\n * Port of `load_receive_state()` from cmd/sign/participant/round1.rs lines 285-411.\n */\nfunction loadReceiveState(\n registryPath: string,\n sessionId: ARID,\n groupHint: ARID | undefined,\n registry: Registry,\n): ReceiveState {\n const base = path.dirname(registryPath);\n const groupStateDir = path.join(base, \"group-state\");\n\n // Collect candidate directories\n let groupDirs: [ARID, string][];\n if (groupHint !== undefined) {\n groupDirs = [[groupHint, path.join(groupStateDir, groupHint.hex())]];\n } else {\n groupDirs = [];\n if (fs.existsSync(groupStateDir)) {\n for (const entry of fs.readdirSync(groupStateDir, { withFileTypes: true })) {\n if (entry.isDirectory()) {\n const dirName = entry.name;\n // Check if it's a 64-character hex string (ARID hex)\n if (dirName.length === 64 && /^[0-9a-fA-F]+$/.test(dirName)) {\n const groupId = ARID.fromHex(dirName);\n groupDirs.push([groupId, path.join(groupStateDir, dirName)]);\n }\n }\n }\n }\n }\n\n // Search for sign_receive.json\n const candidates: [ARID, string][] = [];\n for (const [groupId, groupDir] of groupDirs) {\n const candidate = path.join(groupDir, \"signing\", sessionId.hex(), \"sign_receive.json\");\n if (fs.existsSync(candidate)) {\n candidates.push([groupId, candidate]);\n }\n }\n\n if (candidates.length === 0) {\n throw new Error(\n \"No sign_receive.json found for this session; run `frost sign participant receive` first\",\n );\n }\n if (candidates.length > 1) {\n throw new Error(\"Multiple groups contain this session; use --group to disambiguate\");\n }\n\n const [groupId, filePath] = candidates[0];\n\n // Parse the JSON file\n interface SignReceiveJson {\n session: string;\n group: string;\n response_arid: string;\n target: string;\n coordinator: string;\n participants: string[];\n request_envelope: string;\n }\n\n const raw = JSON.parse(fs.readFileSync(filePath, \"utf-8\")) as SignReceiveJson;\n\n // Validate session matches\n const sessionInState = parseAridUr(raw.session);\n if (sessionInState.urString() !== sessionId.urString()) {\n throw new Error(\n `Session ${sessionInState.urString()} in sign_receive.json does not match requested session ${sessionId.urString()}`,\n );\n }\n\n const responseArid = parseAridUr(raw.response_arid);\n const targetUr = raw.target;\n const coordinatorUr = raw.coordinator;\n const coordinatorXid = XID.fromURString(coordinatorUr);\n\n // Resolve coordinator document from registry\n let coordinatorDoc: XIDDocument;\n const participantRecord = registry.participant(coordinatorXid);\n if (participantRecord !== null && participantRecord !== undefined) {\n coordinatorDoc = participantRecord.xidDocument();\n } else {\n const owner = registry.owner();\n if (owner?.xid().urString() === coordinatorXid.urString()) {\n coordinatorDoc = owner.xidDocument();\n } else {\n throw new Error(\n `Coordinator ${coordinatorXid.urString()} not found in registry and cannot resolve encryption key`,\n );\n }\n }\n\n // Parse request envelope\n const requestEnvelope = Envelope.fromURString(raw.request_envelope);\n\n // Parse participants\n const participants: XID[] = raw.participants.map((s: string) => XID.fromURString(s));\n\n return {\n groupId,\n coordinatorDoc,\n responseArid,\n targetUr,\n participants,\n requestEnvelope,\n };\n}\n\n/**\n * Validate the commit request from persisted state.\n *\n * Port of request validation in `CommandArgs::exec()` from cmd/sign/participant/round1.rs lines 100-138.\n */\nfunction validateCommitRequest(\n receiveState: ReceiveState,\n sessionId: ARID,\n ownerXid: XID,\n ownerPrivateKeys: PrivateKeys,\n): SealedRequest {\n const now = CborDate.now();\n\n // Decrypt and parse the request\n const sealedRequest = SealedRequest.tryFromEnvelope(\n receiveState.requestEnvelope,\n undefined,\n now.datetime(),\n ownerPrivateKeys,\n );\n\n // Validate function\n if (!sealedRequest.request().function().equals(EnvelopeFunction.fromString(\"signInvite\"))) {\n throw new Error(`Unexpected request function: ${String(sealedRequest.request().function())}`);\n }\n\n // Validate session ID\n if (sealedRequest.request().id().urString() !== sessionId.urString()) {\n throw new Error(\n `Session ID mismatch (state ${sessionId.urString()}, request ${sealedRequest.request().id().urString()})`,\n );\n }\n\n // Validate group ID\n const requestGroup = sealedRequest.extractObjectForParameter<ARID>(\"group\");\n if (requestGroup.urString() !== receiveState.groupId.urString()) {\n throw new Error(\n `Group ID mismatch (state ${receiveState.groupId.urString()}, request ${requestGroup.urString()})`,\n );\n }\n\n // Validate participant is included\n const participantUrStrings = receiveState.participants.map((p) => p.urString());\n if (!participantUrStrings.includes(ownerXid.urString())) {\n throw new Error(\"Persisted signInvite request does not include this participant\");\n }\n\n return sealedRequest;\n}\n\n/**\n * Build the response body envelope.\n *\n * Port of response body building from cmd/sign/participant/round1.rs lines 191-195.\n */\nfunction buildResponseBody(\n sessionId: ARID,\n commitments: Ed25519SigningCommitments,\n responseArid: ARID,\n): Envelope {\n // Serialize commitments to JSON and wrap as CBOR JSON\n const serializedCommitments = serializeSigningCommitments(commitments);\n const jsonStr = JSON.stringify(serializedCommitments);\n const jsonBytes = new TextEncoder().encode(jsonStr);\n const commitmentsJson = JSONWrapper.fromData(jsonBytes);\n\n // Build response body: unit subject with type and assertions\n return Envelope.unit()\n .addType(\"signRound1Response\")\n .addAssertion(\"session\", sessionId)\n .addAssertion(\"commitments\", commitmentsJson.taggedCborData())\n .addAssertion(\"response_arid\", responseArid);\n}\n\n/**\n * Persist commit state (nonces and commitments) to disk.\n *\n * Port of `persist_commit_state()` from cmd/sign/participant/round1.rs lines 413-461.\n */\nfunction persistCommitState(\n registryPath: string,\n groupId: ARID,\n sessionId: ARID,\n receiveState: ReceiveState,\n signingNonces: Ed25519SigningNonces,\n signingCommitments: Ed25519SigningCommitments,\n targetEnvelope: Envelope,\n nextShareArid: ARID,\n): void {\n const dir = signingStateDir(registryPath, groupId.hex(), sessionId.hex());\n fs.mkdirSync(dir, { recursive: true });\n\n // Serialize nonces and commitments\n const serializedNonces = serializeSigningNonces(signingNonces);\n const serializedCommitments = serializeSigningCommitments(signingCommitments);\n\n // Build commit state JSON\n const commitState: {\n session: string;\n response_arid: string;\n next_share_arid: string;\n target: string;\n signing_nonces: SerializedSigningNonces;\n signing_commitments: SerializedSigningCommitments;\n } = {\n session: sessionId.urString(),\n response_arid: receiveState.responseArid.urString(),\n next_share_arid: nextShareArid.urString(),\n target: targetEnvelope.urString(),\n signing_nonces: serializedNonces,\n signing_commitments: serializedCommitments,\n };\n\n fs.writeFileSync(path.join(dir, \"commit.json\"), JSON.stringify(commitState, null, 2));\n}\n\n/**\n * Execute the sign participant round 1 command.\n *\n * Responds to the sign invite with signing commitments.\n *\n * Port of `CommandArgs::exec()` from cmd/sign/participant/round1.rs lines 58-273.\n */\nexport async function round1(\n _client: StorageClient | undefined,\n options: SignRound1Options,\n cwd: string,\n): Promise<SignRound1Result> {\n // Validate options\n if (options.storageSelection === undefined && options.preview !== true) {\n throw new Error(\"Hubert storage is required for sign commit\");\n }\n if (options.storageSelection !== undefined && options.preview === true) {\n throw new Error(\"--preview cannot be used with Hubert storage options\");\n }\n\n const registryPath = resolveRegistryPath(options.registryPath, cwd);\n const registry = Registry.load(registryPath);\n\n const owner = registry.owner();\n if (!owner) {\n throw new Error(\"Registry owner is required\");\n }\n\n const sessionId = parseAridUr(options.sessionId);\n const groupHint = options.groupId !== undefined ? parseAridUr(options.groupId) : undefined;\n\n // Load receive state\n const receiveState = loadReceiveState(registryPath, sessionId, groupHint, registry);\n const groupId = receiveState.groupId;\n\n // Get group record\n const groupRecord = registry.group(groupId);\n if (groupRecord === null || groupRecord === undefined) {\n throw new Error(\"Group not found in registry\");\n }\n\n // Get owner private keys\n const ownerKeys = owner.xidDocument().inceptionPrivateKeys();\n if (ownerKeys === undefined) {\n throw new Error(\"Owner XID document has no private keys\");\n }\n\n // Validate the commit request\n const sealedRequest = validateCommitRequest(receiveState, sessionId, owner.xid(), ownerKeys);\n\n // Load key package\n const contributions = groupRecord.contributions();\n if (contributions === null || contributions === undefined) {\n throw new Error(\"Key package path not found; did you finish DKG?\");\n }\n const keyPackagePath = contributions.keyPackage;\n if (keyPackagePath === undefined) {\n throw new Error(\"Key package path not found; did you finish DKG?\");\n }\n\n interface KeyPackageFile {\n group: string;\n key_package: SerializedKeyPackage;\n }\n\n const keyPackageFile = JSON.parse(fs.readFileSync(keyPackagePath, \"utf-8\")) as KeyPackageFile;\n const keyPackage = deserializeKeyPackage(keyPackageFile.key_package);\n\n // Parse target envelope\n const targetEnvelope = Envelope.fromURString(receiveState.targetUr);\n\n const signerPrivateKeys = owner.xidDocument().inceptionPrivateKeys();\n if (signerPrivateKeys === undefined) {\n throw new Error(\"Owner XID document has no signing keys\");\n }\n\n let sealedResponse: SealedResponse;\n let nextShareArid: ARID | undefined;\n\n if (options.rejectReason !== undefined) {\n // Build rejection response\n const errorBody = Envelope.new(\"signCommitReject\")\n .addAssertion(\"group\", groupId)\n .addAssertion(\"session\", sessionId)\n .addAssertion(\"reason\", options.rejectReason);\n\n sealedResponse = SealedResponse.newFailure(sealedRequest.request().id(), owner.xidDocument())\n .withError(errorBody)\n .withPeerContinuation(sealedRequest.peerContinuation());\n } else {\n // Run signing round 1 - generate nonces and commitments\n const rng = createRng();\n const [signingNonces, signingCommitments] = signingRound1(keyPackage, rng);\n\n const nextShare = ARID.new();\n nextShareArid = nextShare;\n\n // Build response body\n const responseBody = buildResponseBody(sessionId, signingCommitments, nextShare);\n\n // Persist commit state (unless preview mode)\n if (options.preview !== true) {\n persistCommitState(\n registryPath,\n groupId,\n sessionId,\n receiveState,\n signingNonces,\n signingCommitments,\n targetEnvelope,\n nextShare,\n );\n\n // Update listening ARID for next request\n const groupRecordMut = registry.group(groupId);\n if (groupRecordMut !== null && groupRecordMut !== undefined) {\n groupRecordMut.setListeningAtArid(nextShare);\n registry.save(registryPath);\n }\n }\n\n sealedResponse = SealedResponse.newSuccess(sealedRequest.request().id(), owner.xidDocument())\n .withResult(responseBody)\n .withPeerContinuation(sealedRequest.peerContinuation());\n }\n\n // Handle preview mode\n if (options.preview === true) {\n const unsealed = sealedResponse.toEnvelope(undefined, signerPrivateKeys, undefined);\n const envelopeUr = unsealed.urString();\n console.log(envelopeUr);\n return {\n accepted: options.rejectReason === undefined,\n envelopeUr,\n };\n }\n\n // Build encrypted response envelope\n const validUntil = new Date(Date.now() + 60 * 60 * 1000); // 1 hour from now\n const responseEnvelope = sealedResponse.toEnvelope(\n validUntil,\n signerPrivateKeys,\n receiveState.coordinatorDoc,\n );\n\n // Post response to Hubert storage\n if (options.storageSelection === undefined) {\n throw new Error(\"Storage selection is required to post response\");\n }\n const client = await createStorageClient(options.storageSelection);\n\n if (options.verbose === true) {\n console.error(`Posting signInvite response to ${receiveState.responseArid.urString()}`);\n }\n\n await putWithIndicator(\n client,\n receiveState.responseArid,\n responseEnvelope,\n \"Commitments\",\n options.verbose ?? false,\n );\n\n // On reject, clear listening ARID\n if (options.rejectReason !== undefined) {\n const groupRecordMut = registry.group(groupId);\n if (groupRecordMut !== null && groupRecordMut !== undefined) {\n groupRecordMut.clearListeningAtArid();\n registry.save(registryPath);\n }\n }\n\n const result: SignRound1Result = {\n accepted: options.rejectReason === undefined,\n };\n if (nextShareArid !== undefined) {\n result.listeningArid = nextShareArid.urString();\n }\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgFA,SAAS,iBACP,cACA,WACA,WACA,UACc;CACd,MAAM,OAAO,KAAK,QAAQ,aAAa;CACvC,MAAM,gBAAgB,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,SAA2B,EAC/B,UAAU,QAAQ,iBAAiB,KAAA,GACpC;AACD,KAAI,kBAAkB,KAAA,EACpB,QAAO,gBAAgB,cAAc,UAAU;AAEjD,QAAO"}
1
+ {"version":3,"file":"round1-B8haiMM8.mjs","names":["EnvelopeFunction","JSONWrapper"],"sources":["../src/cmd/sign/participant/round1.ts"],"sourcesContent":["/**\n * Copyright © 2023-2026 Blockchain Commons, LLC\n * Copyright © 2025-2026 Parity Technologies\n *\n *\n * Sign participant round 1 command.\n *\n * Port of cmd/sign/participant/round1.rs from frost-hubert-rust.\n *\n * @module\n */\n\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\n\nimport { ARID, JSON as JSONWrapper, type PrivateKeys, XID } from \"@bcts/components\";\nimport { CborDate } from \"@bcts/dcbor\";\nimport { Envelope, Function as EnvelopeFunction } from \"@bcts/envelope\";\nimport { SealedRequest, SealedResponse } from \"@bcts/gstp\";\nimport type { XIDDocument } from \"@bcts/xid\";\n\nimport { Registry, resolveRegistryPath } from \"../../../registry/index.js\";\nimport { putWithIndicator } from \"../../busy.js\";\nimport { createStorageClient, type StorageClient, type StorageSelection } from \"../../storage.js\";\nimport { parseAridUr } from \"../../dkg/common.js\";\nimport { signingStateDir } from \"../common.js\";\nimport {\n signingRound1,\n deserializeKeyPackage,\n serializeSigningNonces,\n serializeSigningCommitments,\n createRng,\n type SerializedKeyPackage,\n type SerializedSigningNonces,\n type SerializedSigningCommitments,\n type Ed25519SigningNonces,\n type Ed25519SigningCommitments,\n} from \"../../../frost/index.js\";\n\n/**\n * Options for the sign round1 command.\n */\nexport interface SignRound1Options {\n registryPath?: string;\n sessionId: string;\n groupId?: string;\n preview?: boolean;\n rejectReason?: string;\n storageSelection?: StorageSelection;\n verbose?: boolean;\n}\n\n/**\n * Result of the sign round1 command.\n */\nexport interface SignRound1Result {\n accepted: boolean;\n listeningArid?: string;\n envelopeUr?: string;\n}\n\n/**\n * Persisted receive state from sign_receive.json.\n *\n * Port of `struct ReceiveState` from cmd/sign/participant/round1.rs.\n */\ninterface ReceiveState {\n groupId: ARID;\n coordinatorDoc: XIDDocument;\n responseArid: ARID;\n targetUr: string;\n participants: XID[];\n requestEnvelope: Envelope;\n}\n\n/**\n * Load receive state from persisted sign_receive.json.\n *\n * Port of `load_receive_state()` from cmd/sign/participant/round1.rs lines 285-411.\n */\nfunction loadReceiveState(\n registryPath: string,\n sessionId: ARID,\n groupHint: ARID | undefined,\n registry: Registry,\n): ReceiveState {\n const base = path.dirname(registryPath);\n const groupStateDir = path.join(base, \"group-state\");\n\n // Collect candidate directories\n let groupDirs: [ARID, string][];\n if (groupHint !== undefined) {\n groupDirs = [[groupHint, path.join(groupStateDir, groupHint.hex())]];\n } else {\n groupDirs = [];\n if (fs.existsSync(groupStateDir)) {\n for (const entry of fs.readdirSync(groupStateDir, { withFileTypes: true })) {\n if (entry.isDirectory()) {\n const dirName = entry.name;\n // Check if it's a 64-character hex string (ARID hex)\n if (dirName.length === 64 && /^[0-9a-fA-F]+$/.test(dirName)) {\n const groupId = ARID.fromHex(dirName);\n groupDirs.push([groupId, path.join(groupStateDir, dirName)]);\n }\n }\n }\n }\n }\n\n // Search for sign_receive.json\n const candidates: [ARID, string][] = [];\n for (const [groupId, groupDir] of groupDirs) {\n const candidate = path.join(groupDir, \"signing\", sessionId.hex(), \"sign_receive.json\");\n if (fs.existsSync(candidate)) {\n candidates.push([groupId, candidate]);\n }\n }\n\n if (candidates.length === 0) {\n throw new Error(\n \"No sign_receive.json found for this session; run `frost sign participant receive` first\",\n );\n }\n if (candidates.length > 1) {\n throw new Error(\"Multiple groups contain this session; use --group to disambiguate\");\n }\n\n const [groupId, filePath] = candidates[0];\n\n // Parse the JSON file\n interface SignReceiveJson {\n session: string;\n group: string;\n response_arid: string;\n target: string;\n coordinator: string;\n participants: string[];\n request_envelope: string;\n }\n\n const raw = JSON.parse(fs.readFileSync(filePath, \"utf-8\")) as SignReceiveJson;\n\n // Validate session matches\n const sessionInState = parseAridUr(raw.session);\n if (sessionInState.urString() !== sessionId.urString()) {\n throw new Error(\n `Session ${sessionInState.urString()} in sign_receive.json does not match requested session ${sessionId.urString()}`,\n );\n }\n\n const responseArid = parseAridUr(raw.response_arid);\n const targetUr = raw.target;\n const coordinatorUr = raw.coordinator;\n const coordinatorXid = XID.fromURString(coordinatorUr);\n\n // Resolve coordinator document from registry\n let coordinatorDoc: XIDDocument;\n const participantRecord = registry.participant(coordinatorXid);\n if (participantRecord !== null && participantRecord !== undefined) {\n coordinatorDoc = participantRecord.xidDocument();\n } else {\n const owner = registry.owner();\n if (owner?.xid().urString() === coordinatorXid.urString()) {\n coordinatorDoc = owner.xidDocument();\n } else {\n throw new Error(\n `Coordinator ${coordinatorXid.urString()} not found in registry and cannot resolve encryption key`,\n );\n }\n }\n\n // Parse request envelope\n const requestEnvelope = Envelope.fromURString(raw.request_envelope);\n\n // Parse participants\n const participants: XID[] = raw.participants.map((s: string) => XID.fromURString(s));\n\n return {\n groupId,\n coordinatorDoc,\n responseArid,\n targetUr,\n participants,\n requestEnvelope,\n };\n}\n\n/**\n * Validate the commit request from persisted state.\n *\n * Port of request validation in `CommandArgs::exec()` from cmd/sign/participant/round1.rs lines 100-138.\n */\nfunction validateCommitRequest(\n receiveState: ReceiveState,\n sessionId: ARID,\n ownerXid: XID,\n ownerPrivateKeys: PrivateKeys,\n): SealedRequest {\n const now = CborDate.now();\n\n // Decrypt and parse the request\n const sealedRequest = SealedRequest.tryFromEnvelope(\n receiveState.requestEnvelope,\n undefined,\n now.datetime(),\n ownerPrivateKeys,\n );\n\n // Validate function\n if (!sealedRequest.request().function().equals(EnvelopeFunction.fromString(\"signInvite\"))) {\n throw new Error(`Unexpected request function: ${String(sealedRequest.request().function())}`);\n }\n\n // Validate session ID\n if (sealedRequest.request().id().urString() !== sessionId.urString()) {\n throw new Error(\n `Session ID mismatch (state ${sessionId.urString()}, request ${sealedRequest.request().id().urString()})`,\n );\n }\n\n // Validate group ID\n const requestGroup = sealedRequest.extractObjectForParameter<ARID>(\"group\");\n if (requestGroup.urString() !== receiveState.groupId.urString()) {\n throw new Error(\n `Group ID mismatch (state ${receiveState.groupId.urString()}, request ${requestGroup.urString()})`,\n );\n }\n\n // Validate participant is included\n const participantUrStrings = receiveState.participants.map((p) => p.urString());\n if (!participantUrStrings.includes(ownerXid.urString())) {\n throw new Error(\"Persisted signInvite request does not include this participant\");\n }\n\n return sealedRequest;\n}\n\n/**\n * Build the response body envelope.\n *\n * Port of response body building from cmd/sign/participant/round1.rs lines 191-195.\n */\nfunction buildResponseBody(\n sessionId: ARID,\n commitments: Ed25519SigningCommitments,\n responseArid: ARID,\n): Envelope {\n // Serialize commitments to JSON and wrap as CBOR JSON\n const serializedCommitments = serializeSigningCommitments(commitments);\n const jsonStr = JSON.stringify(serializedCommitments);\n const jsonBytes = new TextEncoder().encode(jsonStr);\n const commitmentsJson = JSONWrapper.fromData(jsonBytes);\n\n // Build response body: unit subject with type and assertions\n return Envelope.unit()\n .addType(\"signRound1Response\")\n .addAssertion(\"session\", sessionId)\n .addAssertion(\"commitments\", commitmentsJson.taggedCborData())\n .addAssertion(\"response_arid\", responseArid);\n}\n\n/**\n * Persist commit state (nonces and commitments) to disk.\n *\n * Port of `persist_commit_state()` from cmd/sign/participant/round1.rs lines 413-461.\n */\nfunction persistCommitState(\n registryPath: string,\n groupId: ARID,\n sessionId: ARID,\n receiveState: ReceiveState,\n signingNonces: Ed25519SigningNonces,\n signingCommitments: Ed25519SigningCommitments,\n targetEnvelope: Envelope,\n nextShareArid: ARID,\n): void {\n const dir = signingStateDir(registryPath, groupId.hex(), sessionId.hex());\n fs.mkdirSync(dir, { recursive: true });\n\n // Serialize nonces and commitments\n const serializedNonces = serializeSigningNonces(signingNonces);\n const serializedCommitments = serializeSigningCommitments(signingCommitments);\n\n // Build commit state JSON\n const commitState: {\n session: string;\n response_arid: string;\n next_share_arid: string;\n target: string;\n signing_nonces: SerializedSigningNonces;\n signing_commitments: SerializedSigningCommitments;\n } = {\n session: sessionId.urString(),\n response_arid: receiveState.responseArid.urString(),\n next_share_arid: nextShareArid.urString(),\n target: targetEnvelope.urString(),\n signing_nonces: serializedNonces,\n signing_commitments: serializedCommitments,\n };\n\n fs.writeFileSync(path.join(dir, \"commit.json\"), JSON.stringify(commitState, null, 2));\n}\n\n/**\n * Execute the sign participant round 1 command.\n *\n * Responds to the sign invite with signing commitments.\n *\n * Port of `CommandArgs::exec()` from cmd/sign/participant/round1.rs lines 58-273.\n */\nexport async function round1(\n _client: StorageClient | undefined,\n options: SignRound1Options,\n cwd: string,\n): Promise<SignRound1Result> {\n // Validate options\n if (options.storageSelection === undefined && options.preview !== true) {\n throw new Error(\"Hubert storage is required for sign commit\");\n }\n if (options.storageSelection !== undefined && options.preview === true) {\n throw new Error(\"--preview cannot be used with Hubert storage options\");\n }\n\n const registryPath = resolveRegistryPath(options.registryPath, cwd);\n const registry = Registry.load(registryPath);\n\n const owner = registry.owner();\n if (!owner) {\n throw new Error(\"Registry owner is required\");\n }\n\n const sessionId = parseAridUr(options.sessionId);\n const groupHint = options.groupId !== undefined ? parseAridUr(options.groupId) : undefined;\n\n // Load receive state\n const receiveState = loadReceiveState(registryPath, sessionId, groupHint, registry);\n const groupId = receiveState.groupId;\n\n // Get group record\n const groupRecord = registry.group(groupId);\n if (groupRecord === null || groupRecord === undefined) {\n throw new Error(\"Group not found in registry\");\n }\n\n // Get owner private keys\n const ownerKeys = owner.xidDocument().inceptionPrivateKeys();\n if (ownerKeys === undefined) {\n throw new Error(\"Owner XID document has no private keys\");\n }\n\n // Validate the commit request\n const sealedRequest = validateCommitRequest(receiveState, sessionId, owner.xid(), ownerKeys);\n\n // Load key package\n const contributions = groupRecord.contributions();\n if (contributions === null || contributions === undefined) {\n throw new Error(\"Key package path not found; did you finish DKG?\");\n }\n const keyPackagePath = contributions.keyPackage;\n if (keyPackagePath === undefined) {\n throw new Error(\"Key package path not found; did you finish DKG?\");\n }\n\n interface KeyPackageFile {\n group: string;\n key_package: SerializedKeyPackage;\n }\n\n const keyPackageFile = JSON.parse(fs.readFileSync(keyPackagePath, \"utf-8\")) as KeyPackageFile;\n const keyPackage = deserializeKeyPackage(keyPackageFile.key_package);\n\n // Parse target envelope\n const targetEnvelope = Envelope.fromURString(receiveState.targetUr);\n\n const signerPrivateKeys = owner.xidDocument().inceptionPrivateKeys();\n if (signerPrivateKeys === undefined) {\n throw new Error(\"Owner XID document has no signing keys\");\n }\n\n let sealedResponse: SealedResponse;\n let nextShareArid: ARID | undefined;\n\n if (options.rejectReason !== undefined) {\n // Build rejection response\n const errorBody = Envelope.new(\"signCommitReject\")\n .addAssertion(\"group\", groupId)\n .addAssertion(\"session\", sessionId)\n .addAssertion(\"reason\", options.rejectReason);\n\n sealedResponse = SealedResponse.newFailure(sealedRequest.request().id(), owner.xidDocument())\n .withError(errorBody)\n .withPeerContinuation(sealedRequest.peerContinuation());\n } else {\n // Run signing round 1 - generate nonces and commitments\n const rng = createRng();\n const [signingNonces, signingCommitments] = signingRound1(keyPackage, rng);\n\n const nextShare = ARID.new();\n nextShareArid = nextShare;\n\n // Build response body\n const responseBody = buildResponseBody(sessionId, signingCommitments, nextShare);\n\n // Persist commit state (unless preview mode)\n if (options.preview !== true) {\n persistCommitState(\n registryPath,\n groupId,\n sessionId,\n receiveState,\n signingNonces,\n signingCommitments,\n targetEnvelope,\n nextShare,\n );\n\n // Update listening ARID for next request\n const groupRecordMut = registry.group(groupId);\n if (groupRecordMut !== null && groupRecordMut !== undefined) {\n groupRecordMut.setListeningAtArid(nextShare);\n registry.save(registryPath);\n }\n }\n\n sealedResponse = SealedResponse.newSuccess(sealedRequest.request().id(), owner.xidDocument())\n .withResult(responseBody)\n .withPeerContinuation(sealedRequest.peerContinuation());\n }\n\n // Handle preview mode\n if (options.preview === true) {\n const unsealed = sealedResponse.toEnvelope(undefined, signerPrivateKeys, undefined);\n const envelopeUr = unsealed.urString();\n console.log(envelopeUr);\n return {\n accepted: options.rejectReason === undefined,\n envelopeUr,\n };\n }\n\n // Build encrypted response envelope\n const validUntil = new Date(Date.now() + 60 * 60 * 1000); // 1 hour from now\n const responseEnvelope = sealedResponse.toEnvelope(\n validUntil,\n signerPrivateKeys,\n receiveState.coordinatorDoc,\n );\n\n // Post response to Hubert storage\n if (options.storageSelection === undefined) {\n throw new Error(\"Storage selection is required to post response\");\n }\n const client = await createStorageClient(options.storageSelection);\n\n if (options.verbose === true) {\n console.error(`Posting signInvite response to ${receiveState.responseArid.urString()}`);\n }\n\n await putWithIndicator(\n client,\n receiveState.responseArid,\n responseEnvelope,\n \"Commitments\",\n options.verbose ?? false,\n );\n\n // On reject, clear listening ARID\n if (options.rejectReason !== undefined) {\n const groupRecordMut = registry.group(groupId);\n if (groupRecordMut !== null && groupRecordMut !== undefined) {\n groupRecordMut.clearListeningAtArid();\n registry.save(registryPath);\n }\n }\n\n const result: SignRound1Result = {\n accepted: options.rejectReason === undefined,\n };\n if (nextShareArid !== undefined) {\n result.listeningArid = nextShareArid.urString();\n }\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgFA,SAAS,iBACP,cACA,WACA,WACA,UACc;CACd,MAAM,OAAO,KAAK,QAAQ,YAAY;CACtC,MAAM,gBAAgB,KAAK,KAAK,MAAM,aAAa;CAGnD,IAAI;CACJ,IAAI,cAAc,KAAA,GAChB,YAAY,CAAC,CAAC,WAAW,KAAK,KAAK,eAAe,UAAU,IAAI,CAAC,CAAC,CAAC;MAC9D;EACL,YAAY,CAAC;EACb,IAAI,GAAG,WAAW,aAAa;QACxB,MAAM,SAAS,GAAG,YAAY,eAAe,EAAE,eAAe,KAAK,CAAC,GACvE,IAAI,MAAM,YAAY,GAAG;IACvB,MAAM,UAAU,MAAM;IAEtB,IAAI,QAAQ,WAAW,MAAM,iBAAiB,KAAK,OAAO,GAAG;KAC3D,MAAM,UAAU,KAAK,QAAQ,OAAO;KACpC,UAAU,KAAK,CAAC,SAAS,KAAK,KAAK,eAAe,OAAO,CAAC,CAAC;IA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AW,YAAY,EACvB,qBAAqB,cAAc,iBAAiB,CAAC;CAC1D;CAGA,IAAI,QAAQ,YAAY,MAAM;EAE5B,MAAM,aADW,eAAe,WAAW,KAAA,GAAW,mBAAmB,KAAA,CAC/C,EAAE,SAAS;EACrC,QAAQ,IAAI,UAAU;EACtB,OAAO;GACL,UAAU,QAAQ,iBAAiB,KAAA;GACnC;EACF;CACF;CAGA,MAAM,aAAa,IAAI,KAAK,KAAK,IAAI,IAAI,OAAU,GAAI;CACvD,MAAM,mBAAmB,eAAe,WACtC,YACA,mBACA,aAAa,cACf;CAGA,IAAI,QAAQ,qBAAqB,KAAA,GAC/B,MAAM,IAAI,MAAM,gDAAgD;CAElE,MAAM,SAAS,MAAM,oBAAoB,QAAQ,gBAAgB;CAEjE,IAAI,QAAQ,YAAY,MACtB,QAAQ,MAAM,kCAAkC,aAAa,aAAa,SAAS,GAAG;CAGxF,MAAM,iBACJ,QACA,aAAa,cACb,kBACA,eACA,QAAQ,WAAW,KACrB;CAGA,IAAI,QAAQ,iBAAiB,KAAA,GAAW;EACtC,MAAM,iBAAiB,SAAS,MAAM,OAAO;EAC7C,IAAI,mBAAmB,QAAQ,mBAAmB,KAAA,GAAW;GAC3D,eAAe,qBAAqB;GACpC,SAAS,KAAK,YAAY;EAC5B;CACF;CAEA,MAAM,SAA2B,EAC/B,UAAU,QAAQ,iBAAiB,KAAA,EACrC;CACA,IAAI,kBAAkB,KAAA,GACpB,OAAO,gBAAgB,cAAc,SAAS;CAEhD,OAAO;AACT"}
@@ -1,8 +1,8 @@
1
- import { t as __exportAll } from "./chunk-CjcI7cDX.mjs";
1
+ import { t as __exportAll } from "./chunk-z9aeyW2b.mjs";
2
2
  import { PendingRequests, Registry, resolveRegistryPath } from "./registry/index.mjs";
3
- import { c as parseAridUr, n as isVerbose, t as groupStateDir } from "./common-CvH6dFvQ.mjs";
4
- import { n as putWithIndicator, t as getWithIndicator } from "./busy-DkM2jAIZ.mjs";
5
- import { f as parallelFetch, m as parallelSend } from "./parallel-D6zc6VW4.mjs";
3
+ import { c as parseAridUr, n as isVerbose, t as groupStateDir } from "./common-Cf1UvJaP.mjs";
4
+ import { n as putWithIndicator, t as getWithIndicator } from "./busy-BlU8_pS2.mjs";
5
+ import { f as parallelFetch, m as parallelSend } from "./parallel-PZiwHZT8.mjs";
6
6
  import { ARID, JSON } from "@bcts/components";
7
7
  import { CborDate } from "@bcts/dcbor";
8
8
  import { Envelope } from "@bcts/envelope";
@@ -449,4 +449,4 @@ async function round1(client, options, cwd) {
449
449
  //#endregion
450
450
  export { round1_exports as n, round1 as t };
451
451
 
452
- //# sourceMappingURL=round1-Cgm7j1kI.mjs.map
452
+ //# sourceMappingURL=round1-BOIE1E4O.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"round1-Cgm7j1kI.mjs","names":["JSONWrapper"],"sources":["../src/cmd/dkg/coordinator/round1.ts"],"sourcesContent":["/**\n * Copyright © 2023-2026 Blockchain Commons, LLC\n * Copyright © 2025-2026 Parity Technologies\n *\n *\n * DKG coordinator round 1 command.\n *\n * Port of cmd/dkg/coordinator/round1.rs from frost-hubert-rust.\n *\n * @module\n */\n\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\n\nimport { ARID, JSON as JSONWrapper, type PrivateKeys, type XID } from \"@bcts/components\";\nimport { CborDate } from \"@bcts/dcbor\";\nimport { Envelope } from \"@bcts/envelope\";\nimport { SealedRequest, SealedResponse } from \"@bcts/gstp\";\nimport type { XIDDocument } from \"@bcts/xid\";\n\nimport {\n type GroupRecord,\n type OwnerRecord,\n PendingRequests,\n Registry,\n resolveRegistryPath,\n} from \"../../../registry/index.js\";\nimport { getWithIndicator, putWithIndicator } from \"../../busy.js\";\nimport { groupStateDir, isVerbose } from \"../../common.js\";\nimport {\n type CollectionResult,\n parallelFetch,\n parallelSend,\n type ParallelFetchConfig,\n} from \"../../parallel.js\";\nimport { type StorageClient } from \"../../storage.js\";\nimport { parseAridUr } from \"../common.js\";\nimport { type DkgRound1Package } from \"../../../frost/index.js\";\nimport { serde } from \"@frosts/ed25519\";\n\n/**\n * Options for the DKG round1 command.\n */\nexport interface DkgRound1Options {\n registryPath?: string;\n groupId: string;\n parallel?: boolean;\n timeoutSeconds?: number;\n preview?: boolean;\n verbose?: boolean;\n}\n\n/**\n * Result of the DKG round1 command.\n */\nexport interface DkgRound1Result {\n accepted: number;\n rejected: number;\n errors: number;\n timeouts: number;\n}\n\n// -----------------------------------------------------------------------------\n// Context and result types\n// -----------------------------------------------------------------------------\n\n/**\n * Context for round 1 collection operations.\n */\ninterface Round1Context {\n client: StorageClient;\n registryPath: string;\n registry: Registry;\n ownerDoc: XIDDocument;\n groupId: ARID;\n}\n\n/**\n * Type alias for a round 1 package entry.\n */\ntype Round1Package = [XID, DkgRound1Package];\n\n/**\n * Type alias for next response ARID entry.\n */\ntype NextResponseArid = [XID, ARID];\n\n/**\n * Result of collecting round 1 responses.\n */\ninterface Round1Collection {\n packages: Round1Package[];\n nextResponseArids: NextResponseArid[];\n displayPath: string;\n}\n\n/**\n * Data extracted from a successful Round 1 response.\n */\ninterface Round1ResponseData {\n package: DkgRound1Package;\n nextResponseArid: ARID;\n}\n\n// -----------------------------------------------------------------------------\n// Validation\n// -----------------------------------------------------------------------------\n\n/**\n * Validate that the owner is the coordinator for this group.\n *\n * Port of `validate_coordinator()` from cmd/dkg/coordinator/round1.rs lines 201-214.\n */\nfunction validateCoordinator(groupRecord: GroupRecord, owner: OwnerRecord): void {\n if (groupRecord.coordinator().xid().urString() !== owner.xid().urString()) {\n throw new Error(\n `Only the coordinator can collect and send Round 2 requests. ` +\n `Coordinator: ${groupRecord.coordinator().xid().urString()}, ` +\n `Owner: ${owner.xid().urString()}`,\n );\n }\n}\n\n// -----------------------------------------------------------------------------\n// Sequential fetch implementation\n// -----------------------------------------------------------------------------\n\n/**\n * Fetch a single round 1 response from storage.\n *\n * Port of `fetch_and_validate_response()` from cmd/dkg/coordinator/round1.rs lines 512-566.\n */\nasync function fetchRound1Response(\n client: StorageClient,\n responseArid: ARID,\n timeout: number | undefined,\n coordinator: XIDDocument,\n expectedGroupId: ARID,\n participantName: string,\n): Promise<[DkgRound1Package, ARID]> {\n const envelope = await getWithIndicator(\n client,\n responseArid,\n participantName,\n timeout,\n isVerbose(),\n );\n\n if (envelope === undefined) {\n throw new Error(\"Response not found in Hubert storage\");\n }\n\n const coordinatorPrivateKeys = coordinator.inceptionPrivateKeys();\n if (coordinatorPrivateKeys === undefined) {\n throw new Error(\"Coordinator XID document has no inception private keys\");\n }\n\n const now = CborDate.now().datetime();\n const sealedResponse = SealedResponse.tryFromEncryptedEnvelope(\n envelope,\n undefined,\n now,\n coordinatorPrivateKeys,\n );\n\n if (sealedResponse.isErr()) {\n const error = sealedResponse.error();\n const reasonEnvelope = error.objectForPredicate(\"reason\");\n const reason =\n reasonEnvelope !== undefined\n ? reasonEnvelope.extractSubject((cbor) => cbor.toText())\n : \"unknown reason\";\n throw new Error(`Participant rejected invite: ${reason}`);\n }\n\n const result = sealedResponse.result();\n validateRound1Response(result, expectedGroupId);\n\n const nextResponseArid = result.tryObjectForPredicate<ARID>(\"response_arid\", (cbor) => {\n return ARID.fromTaggedCbor(cbor);\n });\n\n const round1Package = extractRound1Package(result);\n\n return [round1Package, nextResponseArid];\n}\n\n/**\n * Validate a round 1 response envelope.\n *\n * Port of `validate_round1_response()` from cmd/dkg/coordinator/round1.rs lines 568-586.\n */\nfunction validateRound1Response(result: Envelope, expectedGroupId: ARID): void {\n result.checkSubjectUnit();\n result.checkType(\"dkgRound1Response\");\n\n const groupId = result.tryObjectForPredicate<ARID>(\"group\", (cbor) => {\n return ARID.fromTaggedCbor(cbor);\n });\n\n if (groupId.urString() !== expectedGroupId.urString()) {\n throw new Error(\n `Response group ID ${groupId.urString()} does not match expected ${expectedGroupId.urString()}`,\n );\n }\n}\n\n/**\n * Extract a round 1 package from a response envelope.\n *\n * Port of `extract_round1_package()` from cmd/dkg/coordinator/round1.rs lines 588-598.\n */\nfunction extractRound1Package(result: Envelope): DkgRound1Package {\n const round1Envelope = result.objectForPredicate(\"round1_package\");\n if (round1Envelope === undefined) {\n throw new Error(\"round1_package missing from response\");\n }\n\n const round1Json = round1Envelope.extractSubject<JSONWrapper>((cbor) => {\n return JSONWrapper.fromTaggedCbor(cbor);\n });\n\n const jsonStr = new TextDecoder().decode(round1Json.asBytes());\n const jsonObj = globalThis.JSON.parse(jsonStr) as Record<string, unknown>;\n return serde.round1PackageFromJson(jsonObj);\n}\n\n/**\n * Validate and extract data from a round 1 response (for parallel fetch).\n *\n * Port of `validate_and_extract_round1_response()` from cmd/dkg/coordinator/round1.rs lines 674-707.\n */\nfunction validateAndExtractRound1Response(\n envelope: Envelope,\n coordinatorKeys: PrivateKeys,\n expectedGroupId: ARID,\n): Round1ResponseData | { rejected: string } {\n const now = CborDate.now().datetime();\n const sealedResponse = SealedResponse.tryFromEncryptedEnvelope(\n envelope,\n undefined,\n now,\n coordinatorKeys,\n );\n\n if (sealedResponse.isErr()) {\n const error = sealedResponse.error();\n const reasonEnvelope = error.objectForPredicate(\"reason\");\n const reason =\n reasonEnvelope !== undefined\n ? reasonEnvelope.extractSubject((cbor) => cbor.toText())\n : \"unknown reason\";\n return { rejected: `Participant rejected invite: ${reason}` };\n }\n\n const result = sealedResponse.result();\n validateRound1Response(result, expectedGroupId);\n\n const nextResponseArid = result.tryObjectForPredicate<ARID>(\"response_arid\", (cbor) => {\n return ARID.fromTaggedCbor(cbor);\n });\n\n const pkg = extractRound1Package(result);\n\n return { package: pkg, nextResponseArid };\n}\n\n// -----------------------------------------------------------------------------\n// Parallel collection\n// -----------------------------------------------------------------------------\n\n/**\n * Collect Round 1 responses in parallel with progress display.\n *\n * Port of `collect_round1_responses_parallel()` from cmd/dkg/coordinator/round1.rs lines 636-671.\n */\nasync function collectRound1Parallel(\n client: StorageClient,\n registry: Registry,\n pendingRequests: PendingRequests,\n coordinator: XIDDocument,\n expectedGroupId: ARID,\n timeout: number | undefined,\n): Promise<CollectionResult<Round1ResponseData>> {\n const requests: [XID, ARID, string][] = [];\n for (const [xid, arid] of pendingRequests.iterCollect()) {\n const participant = registry.participant(xid);\n const name = participant?.petName() ?? xid.urString();\n requests.push([xid, arid, name]);\n }\n\n const coordinatorKeys = coordinator.inceptionPrivateKeys();\n if (coordinatorKeys === undefined) {\n throw new Error(\"Missing coordinator private keys\");\n }\n\n const config: ParallelFetchConfig = { timeoutSeconds: timeout };\n const groupId = expectedGroupId;\n\n return parallelFetch(\n client,\n requests,\n (envelope: Envelope, _xid: XID) => {\n return validateAndExtractRound1Response(envelope, coordinatorKeys, groupId);\n },\n config,\n );\n}\n\n// -----------------------------------------------------------------------------\n// Round 2 request building\n// -----------------------------------------------------------------------------\n\n/**\n * Build a Round 2 request for a single participant.\n *\n * Port of `build_round2_request_for_participant()` from cmd/dkg/coordinator/round1.rs lines 604-623.\n */\nfunction buildRound2RequestForParticipant(\n sender: XIDDocument,\n groupId: ARID,\n round1Packages: Round1Package[],\n responseArid: ARID,\n): SealedRequest {\n let request = SealedRequest.new(\"dkgRound2\", ARID.new(), sender)\n .withParameter(\"group\", groupId)\n .withParameter(\"responseArid\", responseArid);\n\n for (const [xid, pkg] of round1Packages) {\n const packageJson = serde.round1PackageToJson(pkg);\n const jsonStr = globalThis.JSON.stringify(packageJson);\n const jsonBytes = new TextEncoder().encode(jsonStr);\n const jsonWrapper = JSONWrapper.fromData(jsonBytes);\n const packageEnvelope = Envelope.new(jsonWrapper).addAssertion(\"participant\", xid);\n request = request.withParameter(\"round1Package\", packageEnvelope);\n }\n\n return request;\n}\n\n/**\n * Dispatch Round 2 requests in parallel.\n *\n * Port of `dispatch_round2_requests_parallel()` from cmd/dkg/coordinator/round1.rs lines 729-844.\n */\nasync function dispatchRound2RequestsParallel(\n client: StorageClient,\n registry: Registry,\n registryPath: string,\n coordinator: XIDDocument,\n groupId: ARID,\n successes: [XID, Round1ResponseData][],\n preview: boolean,\n): Promise<[string, string] | undefined> {\n const signerPrivateKeys = coordinator.inceptionPrivateKeys();\n if (signerPrivateKeys === undefined) {\n throw new Error(\"Coordinator XID document has no signing keys\");\n }\n\n const validUntil = new Date(Date.now() + 60 * 60 * 1000); // 1 hour from now\n\n // Build round1 packages list for request building\n const round1Packages: Round1Package[] = successes.map(([xid, data]) => [xid, data.package]);\n\n // Build participant info and messages\n const messages: [XID, ARID, Envelope, string][] = [];\n const collectArids: [XID, ARID][] = [];\n let previewOutput: [string, string] | undefined;\n\n for (const [xid, data] of successes) {\n const participant = registry.participant(xid);\n if (participant === undefined) {\n throw new Error(`Participant ${xid.urString()} not found in registry`);\n }\n const recipientDoc = participant.xidDocument();\n const participantName = participant.petName() ?? xid.urString();\n\n const collectFromArid = ARID.new();\n collectArids.push([xid, collectFromArid]);\n\n const request = buildRound2RequestForParticipant(\n coordinator,\n groupId,\n round1Packages,\n collectFromArid,\n );\n\n if (preview && previewOutput === undefined) {\n const unsealedEnvelope = request.toEnvelope(validUntil, signerPrivateKeys, undefined);\n previewOutput = [participantName, unsealedEnvelope.urString()];\n }\n\n const sealedEnvelope = request.toEnvelope(validUntil, signerPrivateKeys, recipientDoc);\n\n messages.push([xid, data.nextResponseArid, sealedEnvelope, participantName]);\n }\n\n // Blank line to separate get phase from put phase\n console.error();\n\n // Send all messages in parallel\n const sendResults = await parallelSend(client, messages, isVerbose());\n\n // Check for send failures\n const failures: [XID, string][] = [];\n for (const [xid, err] of sendResults) {\n if (err !== null) {\n failures.push([xid, err.message]);\n }\n }\n\n if (failures.length > 0) {\n for (const [xid, error] of failures) {\n console.error(`Failed to send to ${xid.urString()}: ${error}`);\n }\n throw new Error(`Failed to send Round 2 requests to ${failures.length} participants`);\n }\n\n // Update pending requests for Round 2 collection\n const newPendingRequests = new PendingRequests();\n for (const [xid, collectFromArid] of collectArids) {\n newPendingRequests.addCollectOnly(xid, collectFromArid);\n }\n const groupRecord = registry.groupMut(groupId);\n if (groupRecord === undefined) {\n throw new Error(\"Group not found in registry\");\n }\n groupRecord.setPendingRequests(newPendingRequests);\n registry.save(registryPath);\n\n return previewOutput;\n}\n\n// -----------------------------------------------------------------------------\n// Pending request updates\n// -----------------------------------------------------------------------------\n\n/**\n * Update pending requests from parallel collection results.\n *\n * Port of `update_pending_for_round2_from_collection()` from cmd/dkg/coordinator/round1.rs lines 710-726.\n */\nfunction updatePendingForRound2FromCollection(\n registry: Registry,\n registryPath: string,\n groupId: ARID,\n successes: [XID, Round1ResponseData][],\n): void {\n const newPending = new PendingRequests();\n for (const [xid, data] of successes) {\n newPending.addSendOnly(xid, data.nextResponseArid);\n }\n const groupRecord = registry.groupMut(groupId);\n if (groupRecord === undefined) {\n throw new Error(\"Group not found in registry\");\n }\n groupRecord.setPendingRequests(newPending);\n registry.save(registryPath);\n}\n\n// -----------------------------------------------------------------------------\n// Persistence\n// -----------------------------------------------------------------------------\n\n/**\n * Persist collected round 1 packages to disk.\n *\n * Port of `persist_round1_packages()` from cmd/dkg/coordinator/round1.rs lines 301-340.\n */\nfunction persistRound1Packages(\n registryPath: string,\n groupId: ARID,\n packages: Round1Package[],\n): string {\n const packagesDir = groupStateDir(registryPath, groupId.hex());\n fs.mkdirSync(packagesDir, { recursive: true });\n\n const round1PackagesPath = path.join(packagesDir, \"collected_round1.json\");\n const packagesJson: Record<string, unknown> = {};\n\n for (const [xid, pkg] of packages) {\n packagesJson[xid.urString()] = serde.round1PackageToJson(pkg);\n }\n\n fs.writeFileSync(round1PackagesPath, globalThis.JSON.stringify(packagesJson, null, 2));\n\n // Return display path (relative to cwd if possible)\n const cwd = process.cwd();\n if (round1PackagesPath.startsWith(cwd)) {\n return round1PackagesPath.slice(cwd.length + 1);\n }\n return round1PackagesPath;\n}\n\n// -----------------------------------------------------------------------------\n// Sequential collection\n// -----------------------------------------------------------------------------\n\n/**\n * Fetch all round 1 packages sequentially.\n *\n * Port of `fetch_all_round1_packages()` from cmd/dkg/coordinator/round1.rs lines 243-299.\n */\nasync function fetchAllRound1Packages(\n ctx: Round1Context,\n pendingRequests: PendingRequests,\n timeout: number | undefined,\n): Promise<[Round1Package[], NextResponseArid[]]> {\n const round1Packages: Round1Package[] = [];\n const nextResponseArids: NextResponseArid[] = [];\n const errors: [XID, string][] = [];\n\n for (const [participantXid, collectFromArid] of pendingRequests.iterCollect()) {\n const participant = ctx.registry.participant(participantXid);\n const participantName = participant?.petName() ?? participantXid.urString();\n\n try {\n const [pkg, nextArid] = await fetchRound1Response(\n ctx.client,\n collectFromArid,\n timeout,\n ctx.ownerDoc,\n ctx.groupId,\n participantName,\n );\n round1Packages.push([participantXid, pkg]);\n nextResponseArids.push([participantXid, nextArid]);\n } catch (e) {\n errors.push([participantXid, e instanceof Error ? e.message : String(e)]);\n }\n }\n\n if (errors.length > 0) {\n if (isVerbose()) {\n console.error();\n console.error(`Failed to collect from ${errors.length} participants:`);\n }\n for (const [xid, error] of errors) {\n console.error(` ${xid.urString()}: ${error}`);\n }\n throw new Error(\n `Round 1 collection incomplete: ${errors.length} of ${pendingRequests.len()} responses failed`,\n );\n }\n\n return [round1Packages, nextResponseArids];\n}\n\n/**\n * Collect round 1 responses sequentially.\n *\n * Port of `collect_round1_responses()` from cmd/dkg/coordinator/round1.rs lines 220-241.\n */\nasync function collectRound1Responses(\n ctx: Round1Context,\n pendingRequests: PendingRequests,\n timeout: number | undefined,\n): Promise<Round1Collection> {\n if (isVerbose()) {\n console.error(`Collecting Round 1 responses from ${pendingRequests.len()} participants...`);\n }\n\n const [packages, nextResponseArids] = await fetchAllRound1Packages(ctx, pendingRequests, timeout);\n\n const displayPath = persistRound1Packages(ctx.registryPath, ctx.groupId, packages);\n\n updatePendingForRound2(ctx, nextResponseArids);\n\n return { packages, nextResponseArids, displayPath };\n}\n\n/**\n * Update pending requests for round 2 (sequential path).\n *\n * Port of `update_pending_for_round2()` from cmd/dkg/coordinator/round1.rs lines 342-357.\n */\nfunction updatePendingForRound2(ctx: Round1Context, nextResponseArids: NextResponseArid[]): void {\n const newPending = new PendingRequests();\n for (const [xid, sendToArid] of nextResponseArids) {\n newPending.addSendOnly(xid, sendToArid);\n }\n const groupRecord = ctx.registry.groupMut(ctx.groupId);\n if (groupRecord === undefined) {\n throw new Error(\"Group not found in registry\");\n }\n groupRecord.setPendingRequests(newPending);\n ctx.registry.save(ctx.registryPath);\n}\n\n// -----------------------------------------------------------------------------\n// Round 2 dispatch (sequential)\n// -----------------------------------------------------------------------------\n\n/**\n * Build participant info for round 2 dispatch.\n *\n * Port of `build_round2_participant_info()` from cmd/dkg/coordinator/round1.rs lines 438-458.\n */\nfunction buildRound2ParticipantInfo(\n registry: Registry,\n nextResponseArids: NextResponseArid[],\n): [XID, XIDDocument, ARID, ARID][] {\n return nextResponseArids.map(([xid, sendToArid]) => {\n const participant = registry.participant(xid);\n if (participant === undefined) {\n throw new Error(`Participant ${xid.urString()} not found in registry`);\n }\n const doc = participant.xidDocument();\n const collectFromArid = ARID.new();\n return [xid, doc, sendToArid, collectFromArid];\n });\n}\n\n/**\n * Update pending for round 2 collection (sequential path).\n *\n * Port of `update_pending_for_round2_collection()` from cmd/dkg/coordinator/round1.rs lines 460-475.\n */\nfunction updatePendingForRound2Collection(\n ctx: Round1Context,\n participantInfo: [XID, XIDDocument, ARID, ARID][],\n): void {\n const newPendingRequests = new PendingRequests();\n for (const [xid, , , collectFromArid] of participantInfo) {\n newPendingRequests.addCollectOnly(xid, collectFromArid);\n }\n const groupRecord = ctx.registry.groupMut(ctx.groupId);\n if (groupRecord === undefined) {\n throw new Error(\"Group not found in registry\");\n }\n groupRecord.setPendingRequests(newPendingRequests);\n ctx.registry.save(ctx.registryPath);\n}\n\n/**\n * Dispatch Round 2 requests sequentially.\n *\n * Port of `dispatch_round2_requests()` from cmd/dkg/coordinator/round1.rs lines 363-436.\n */\nasync function dispatchRound2Requests(\n ctx: Round1Context,\n collection: Round1Collection,\n preview: boolean,\n): Promise<[string, string] | undefined> {\n const signerPrivateKeys = ctx.ownerDoc.inceptionPrivateKeys();\n if (signerPrivateKeys === undefined) {\n throw new Error(\"Coordinator XID document has no signing keys\");\n }\n\n const validUntil = new Date(Date.now() + 60 * 60 * 1000); // 1 hour from now\n\n const participantInfo = buildRound2ParticipantInfo(ctx.registry, collection.nextResponseArids);\n\n if (isVerbose()) {\n console.error(`Sending Round 2 requests to ${participantInfo.length} participants...`);\n } else {\n // Blank line to separate get phase from put phase\n console.error();\n }\n\n let previewOutput: [string, string] | undefined;\n\n for (const [xid, recipientDoc, sendToArid, collectFromArid] of participantInfo) {\n const participant = ctx.registry.participant(xid);\n const participantName = participant?.petName() ?? xid.urString();\n\n const request = buildRound2RequestForParticipant(\n ctx.ownerDoc,\n ctx.groupId,\n collection.packages,\n collectFromArid,\n );\n\n if (preview && previewOutput === undefined) {\n const unsealedEnvelope = request.toEnvelope(validUntil, signerPrivateKeys, undefined);\n previewOutput = [participantName, unsealedEnvelope.urString()];\n }\n\n const sealedEnvelope = request.toEnvelope(validUntil, signerPrivateKeys, recipientDoc);\n\n await putWithIndicator(ctx.client, sendToArid, sealedEnvelope, participantName, isVerbose());\n }\n\n updatePendingForRound2Collection(ctx, participantInfo);\n\n return previewOutput;\n}\n\n// -----------------------------------------------------------------------------\n// Output\n// -----------------------------------------------------------------------------\n\n/**\n * Print summary for sequential collection.\n *\n * Port of `print_summary()` from cmd/dkg/coordinator/round1.rs lines 481-506.\n */\nfunction printSummary(collection: Round1Collection, preview: [string, string] | undefined): void {\n if (preview !== undefined) {\n const [participantName, ur] = preview;\n if (isVerbose()) {\n console.error(`# Round 2 preview for ${participantName}`);\n console.error();\n }\n console.error(\n `Collected ${collection.packages.length} Round 1 packages to ${collection.displayPath} ` +\n `and sent ${collection.nextResponseArids.length} Round 2 requests.`,\n );\n console.log(ur);\n } else if (isVerbose()) {\n console.error();\n console.error(\n `Collected ${collection.packages.length} Round 1 packages to ${collection.displayPath} ` +\n `and sent ${collection.nextResponseArids.length} Round 2 requests.`,\n );\n }\n}\n\n/**\n * Print summary for parallel collection.\n *\n * Port of `print_summary_parallel()` from cmd/dkg/coordinator/round1.rs lines 847-901.\n */\nfunction printSummaryParallel(\n collection: CollectionResult<Round1ResponseData>,\n displayPath: string,\n preview: [string, string] | undefined,\n): void {\n // Report any failures\n if (collection.rejections.length > 0) {\n console.error();\n console.error(\"Rejections:\");\n for (const [xid, reason] of collection.rejections) {\n console.error(` ${xid.urString()}: ${reason}`);\n }\n }\n if (collection.errors.length > 0) {\n console.error();\n console.error(\"Errors:\");\n for (const [xid, error] of collection.errors) {\n console.error(` ${xid.urString()}: ${error}`);\n }\n }\n if (collection.timeouts.length > 0) {\n console.error();\n console.error(\"Timeouts:\");\n for (const xid of collection.timeouts) {\n console.error(` ${xid.urString()}`);\n }\n }\n\n if (!collection.allSucceeded()) {\n console.error();\n bailWithCollectionSummary(collection);\n }\n\n if (preview !== undefined) {\n const [participantName, ur] = preview;\n if (isVerbose()) {\n console.error(`# Round 2 preview for ${participantName}`);\n console.error();\n }\n console.error(\n `Collected ${collection.successes.length} Round 1 packages to ${displayPath} ` +\n `and sent ${collection.successes.length} Round 2 requests.`,\n );\n console.log(ur);\n } else if (isVerbose()) {\n console.error();\n console.error(\n `Collected ${collection.successes.length} Round 1 packages to ${displayPath} ` +\n `and sent ${collection.successes.length} Round 2 requests.`,\n );\n }\n}\n\n/**\n * Print collection summary and throw error.\n *\n * Port of `bail_with_collection_summary()` from cmd/dkg/coordinator/round1.rs lines 903-913.\n */\nfunction bailWithCollectionSummary(collection: CollectionResult<Round1ResponseData>): never {\n const msg =\n `Round 1 collection incomplete: ${collection.successes.length} succeeded, ` +\n `${collection.rejections.length} rejected, ${collection.errors.length} errors, ` +\n `${collection.timeouts.length} timeouts`;\n console.error(msg);\n throw new Error(msg);\n}\n\n// -----------------------------------------------------------------------------\n// Main entry point\n// -----------------------------------------------------------------------------\n\n/**\n * Execute the DKG coordinator round 1 command.\n *\n * Collects commitment packages from participants.\n *\n * Port of `CommandArgs::exec()` from cmd/dkg/coordinator/round1.rs lines 59-173.\n */\nexport async function round1(\n client: StorageClient,\n options: DkgRound1Options,\n cwd: string,\n): Promise<DkgRound1Result> {\n const registryPath = resolveRegistryPath(options.registryPath, cwd);\n const registry = Registry.load(registryPath);\n\n const owner = registry.owner();\n if (owner === undefined) {\n throw new Error(\"Registry owner is required\");\n }\n const ownerDoc = owner.xidDocument();\n\n const groupId = parseAridUr(options.groupId);\n const groupRecord = registry.group(groupId);\n\n if (groupRecord === undefined) {\n throw new Error(`Group ${options.groupId} not found in registry`);\n }\n\n validateCoordinator(groupRecord, owner);\n\n const pendingRequests = groupRecord.pendingRequests();\n if (pendingRequests.isEmpty()) {\n throw new Error(\"No pending requests for this group. Round 1 may already be collected.\");\n }\n\n if (options.parallel === true) {\n // Parallel path with progress display\n const collection = await collectRound1Parallel(\n client,\n registry,\n pendingRequests,\n ownerDoc,\n groupId,\n options.timeoutSeconds,\n );\n\n // Extract packages for persistence\n const packages: Round1Package[] = collection.successes.map(([xid, data]) => [\n xid,\n data.package,\n ]);\n\n const displayPath = persistRound1Packages(registryPath, groupId, packages);\n\n updatePendingForRound2FromCollection(registry, registryPath, groupId, collection.successes);\n\n const preview = await dispatchRound2RequestsParallel(\n client,\n registry,\n registryPath,\n ownerDoc,\n groupId,\n collection.successes,\n options.preview ?? false,\n );\n\n printSummaryParallel(collection, displayPath, preview);\n\n return {\n accepted: collection.successes.length,\n rejected: collection.rejections.length,\n errors: collection.errors.length,\n timeouts: collection.timeouts.length,\n };\n } else {\n // Sequential path (original behavior)\n const ctx: Round1Context = {\n client,\n registryPath,\n registry,\n ownerDoc,\n groupId,\n };\n\n const collection = await collectRound1Responses(ctx, pendingRequests, options.timeoutSeconds);\n\n const preview = await dispatchRound2Requests(ctx, collection, options.preview ?? false);\n\n printSummary(collection, preview);\n\n return {\n accepted: collection.packages.length,\n rejected: 0,\n errors: 0,\n timeouts: 0,\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkHA,SAAS,oBAAoB,aAA0B,OAA0B;AAC/E,KAAI,YAAY,aAAa,CAAC,K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AEtD,SAAO;GACL,UAAU,WAAW,UAAU;GAC/B,UAAU,WAAW,WAAW;GAChC,QAAQ,WAAW,OAAO;GAC1B,UAAU,WAAW,SAAS;GAC/B;QACI;EAEL,MAAM,MAAqB;GACzB;GACA;GACA;GACA;GACA;GACD;EAED,MAAM,aAAa,MAAM,uBAAuB,KAAK,iBAAiB,QAAQ,eAAe;AAI7F,eAAa,YAAY,MAFH,uBAAuB,KAAK,YAAY,QAAQ,WAAW,MAAM,CAEtD;AAEjC,SAAO;GACL,UAAU,WAAW,SAAS;GAC9B,UAAU;GACV,QAAQ;GACR,UAAU;GACX"}
1
+ {"version":3,"file":"round1-BOIE1E4O.mjs","names":["JSONWrapper"],"sources":["../src/cmd/dkg/coordinator/round1.ts"],"sourcesContent":["/**\n * Copyright © 2023-2026 Blockchain Commons, LLC\n * Copyright © 2025-2026 Parity Technologies\n *\n *\n * DKG coordinator round 1 command.\n *\n * Port of cmd/dkg/coordinator/round1.rs from frost-hubert-rust.\n *\n * @module\n */\n\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\n\nimport { ARID, JSON as JSONWrapper, type PrivateKeys, type XID } from \"@bcts/components\";\nimport { CborDate } from \"@bcts/dcbor\";\nimport { Envelope } from \"@bcts/envelope\";\nimport { SealedRequest, SealedResponse } from \"@bcts/gstp\";\nimport type { XIDDocument } from \"@bcts/xid\";\n\nimport {\n type GroupRecord,\n type OwnerRecord,\n PendingRequests,\n Registry,\n resolveRegistryPath,\n} from \"../../../registry/index.js\";\nimport { getWithIndicator, putWithIndicator } from \"../../busy.js\";\nimport { groupStateDir, isVerbose } from \"../../common.js\";\nimport {\n type CollectionResult,\n parallelFetch,\n parallelSend,\n type ParallelFetchConfig,\n} from \"../../parallel.js\";\nimport { type StorageClient } from \"../../storage.js\";\nimport { parseAridUr } from \"../common.js\";\nimport { type DkgRound1Package } from \"../../../frost/index.js\";\nimport { serde } from \"@frosts/ed25519\";\n\n/**\n * Options for the DKG round1 command.\n */\nexport interface DkgRound1Options {\n registryPath?: string;\n groupId: string;\n parallel?: boolean;\n timeoutSeconds?: number;\n preview?: boolean;\n verbose?: boolean;\n}\n\n/**\n * Result of the DKG round1 command.\n */\nexport interface DkgRound1Result {\n accepted: number;\n rejected: number;\n errors: number;\n timeouts: number;\n}\n\n// -----------------------------------------------------------------------------\n// Context and result types\n// -----------------------------------------------------------------------------\n\n/**\n * Context for round 1 collection operations.\n */\ninterface Round1Context {\n client: StorageClient;\n registryPath: string;\n registry: Registry;\n ownerDoc: XIDDocument;\n groupId: ARID;\n}\n\n/**\n * Type alias for a round 1 package entry.\n */\ntype Round1Package = [XID, DkgRound1Package];\n\n/**\n * Type alias for next response ARID entry.\n */\ntype NextResponseArid = [XID, ARID];\n\n/**\n * Result of collecting round 1 responses.\n */\ninterface Round1Collection {\n packages: Round1Package[];\n nextResponseArids: NextResponseArid[];\n displayPath: string;\n}\n\n/**\n * Data extracted from a successful Round 1 response.\n */\ninterface Round1ResponseData {\n package: DkgRound1Package;\n nextResponseArid: ARID;\n}\n\n// -----------------------------------------------------------------------------\n// Validation\n// -----------------------------------------------------------------------------\n\n/**\n * Validate that the owner is the coordinator for this group.\n *\n * Port of `validate_coordinator()` from cmd/dkg/coordinator/round1.rs lines 201-214.\n */\nfunction validateCoordinator(groupRecord: GroupRecord, owner: OwnerRecord): void {\n if (groupRecord.coordinator().xid().urString() !== owner.xid().urString()) {\n throw new Error(\n `Only the coordinator can collect and send Round 2 requests. ` +\n `Coordinator: ${groupRecord.coordinator().xid().urString()}, ` +\n `Owner: ${owner.xid().urString()}`,\n );\n }\n}\n\n// -----------------------------------------------------------------------------\n// Sequential fetch implementation\n// -----------------------------------------------------------------------------\n\n/**\n * Fetch a single round 1 response from storage.\n *\n * Port of `fetch_and_validate_response()` from cmd/dkg/coordinator/round1.rs lines 512-566.\n */\nasync function fetchRound1Response(\n client: StorageClient,\n responseArid: ARID,\n timeout: number | undefined,\n coordinator: XIDDocument,\n expectedGroupId: ARID,\n participantName: string,\n): Promise<[DkgRound1Package, ARID]> {\n const envelope = await getWithIndicator(\n client,\n responseArid,\n participantName,\n timeout,\n isVerbose(),\n );\n\n if (envelope === undefined) {\n throw new Error(\"Response not found in Hubert storage\");\n }\n\n const coordinatorPrivateKeys = coordinator.inceptionPrivateKeys();\n if (coordinatorPrivateKeys === undefined) {\n throw new Error(\"Coordinator XID document has no inception private keys\");\n }\n\n const now = CborDate.now().datetime();\n const sealedResponse = SealedResponse.tryFromEncryptedEnvelope(\n envelope,\n undefined,\n now,\n coordinatorPrivateKeys,\n );\n\n if (sealedResponse.isErr()) {\n const error = sealedResponse.error();\n const reasonEnvelope = error.objectForPredicate(\"reason\");\n const reason =\n reasonEnvelope !== undefined\n ? reasonEnvelope.extractSubject((cbor) => cbor.toText())\n : \"unknown reason\";\n throw new Error(`Participant rejected invite: ${reason}`);\n }\n\n const result = sealedResponse.result();\n validateRound1Response(result, expectedGroupId);\n\n const nextResponseArid = result.tryObjectForPredicate<ARID>(\"response_arid\", (cbor) => {\n return ARID.fromTaggedCbor(cbor);\n });\n\n const round1Package = extractRound1Package(result);\n\n return [round1Package, nextResponseArid];\n}\n\n/**\n * Validate a round 1 response envelope.\n *\n * Port of `validate_round1_response()` from cmd/dkg/coordinator/round1.rs lines 568-586.\n */\nfunction validateRound1Response(result: Envelope, expectedGroupId: ARID): void {\n result.checkSubjectUnit();\n result.checkType(\"dkgRound1Response\");\n\n const groupId = result.tryObjectForPredicate<ARID>(\"group\", (cbor) => {\n return ARID.fromTaggedCbor(cbor);\n });\n\n if (groupId.urString() !== expectedGroupId.urString()) {\n throw new Error(\n `Response group ID ${groupId.urString()} does not match expected ${expectedGroupId.urString()}`,\n );\n }\n}\n\n/**\n * Extract a round 1 package from a response envelope.\n *\n * Port of `extract_round1_package()` from cmd/dkg/coordinator/round1.rs lines 588-598.\n */\nfunction extractRound1Package(result: Envelope): DkgRound1Package {\n const round1Envelope = result.objectForPredicate(\"round1_package\");\n if (round1Envelope === undefined) {\n throw new Error(\"round1_package missing from response\");\n }\n\n const round1Json = round1Envelope.extractSubject<JSONWrapper>((cbor) => {\n return JSONWrapper.fromTaggedCbor(cbor);\n });\n\n const jsonStr = new TextDecoder().decode(round1Json.asBytes());\n const jsonObj = globalThis.JSON.parse(jsonStr) as Record<string, unknown>;\n return serde.round1PackageFromJson(jsonObj);\n}\n\n/**\n * Validate and extract data from a round 1 response (for parallel fetch).\n *\n * Port of `validate_and_extract_round1_response()` from cmd/dkg/coordinator/round1.rs lines 674-707.\n */\nfunction validateAndExtractRound1Response(\n envelope: Envelope,\n coordinatorKeys: PrivateKeys,\n expectedGroupId: ARID,\n): Round1ResponseData | { rejected: string } {\n const now = CborDate.now().datetime();\n const sealedResponse = SealedResponse.tryFromEncryptedEnvelope(\n envelope,\n undefined,\n now,\n coordinatorKeys,\n );\n\n if (sealedResponse.isErr()) {\n const error = sealedResponse.error();\n const reasonEnvelope = error.objectForPredicate(\"reason\");\n const reason =\n reasonEnvelope !== undefined\n ? reasonEnvelope.extractSubject((cbor) => cbor.toText())\n : \"unknown reason\";\n return { rejected: `Participant rejected invite: ${reason}` };\n }\n\n const result = sealedResponse.result();\n validateRound1Response(result, expectedGroupId);\n\n const nextResponseArid = result.tryObjectForPredicate<ARID>(\"response_arid\", (cbor) => {\n return ARID.fromTaggedCbor(cbor);\n });\n\n const pkg = extractRound1Package(result);\n\n return { package: pkg, nextResponseArid };\n}\n\n// -----------------------------------------------------------------------------\n// Parallel collection\n// -----------------------------------------------------------------------------\n\n/**\n * Collect Round 1 responses in parallel with progress display.\n *\n * Port of `collect_round1_responses_parallel()` from cmd/dkg/coordinator/round1.rs lines 636-671.\n */\nasync function collectRound1Parallel(\n client: StorageClient,\n registry: Registry,\n pendingRequests: PendingRequests,\n coordinator: XIDDocument,\n expectedGroupId: ARID,\n timeout: number | undefined,\n): Promise<CollectionResult<Round1ResponseData>> {\n const requests: [XID, ARID, string][] = [];\n for (const [xid, arid] of pendingRequests.iterCollect()) {\n const participant = registry.participant(xid);\n const name = participant?.petName() ?? xid.urString();\n requests.push([xid, arid, name]);\n }\n\n const coordinatorKeys = coordinator.inceptionPrivateKeys();\n if (coordinatorKeys === undefined) {\n throw new Error(\"Missing coordinator private keys\");\n }\n\n const config: ParallelFetchConfig = { timeoutSeconds: timeout };\n const groupId = expectedGroupId;\n\n return parallelFetch(\n client,\n requests,\n (envelope: Envelope, _xid: XID) => {\n return validateAndExtractRound1Response(envelope, coordinatorKeys, groupId);\n },\n config,\n );\n}\n\n// -----------------------------------------------------------------------------\n// Round 2 request building\n// -----------------------------------------------------------------------------\n\n/**\n * Build a Round 2 request for a single participant.\n *\n * Port of `build_round2_request_for_participant()` from cmd/dkg/coordinator/round1.rs lines 604-623.\n */\nfunction buildRound2RequestForParticipant(\n sender: XIDDocument,\n groupId: ARID,\n round1Packages: Round1Package[],\n responseArid: ARID,\n): SealedRequest {\n let request = SealedRequest.new(\"dkgRound2\", ARID.new(), sender)\n .withParameter(\"group\", groupId)\n .withParameter(\"responseArid\", responseArid);\n\n for (const [xid, pkg] of round1Packages) {\n const packageJson = serde.round1PackageToJson(pkg);\n const jsonStr = globalThis.JSON.stringify(packageJson);\n const jsonBytes = new TextEncoder().encode(jsonStr);\n const jsonWrapper = JSONWrapper.fromData(jsonBytes);\n const packageEnvelope = Envelope.new(jsonWrapper).addAssertion(\"participant\", xid);\n request = request.withParameter(\"round1Package\", packageEnvelope);\n }\n\n return request;\n}\n\n/**\n * Dispatch Round 2 requests in parallel.\n *\n * Port of `dispatch_round2_requests_parallel()` from cmd/dkg/coordinator/round1.rs lines 729-844.\n */\nasync function dispatchRound2RequestsParallel(\n client: StorageClient,\n registry: Registry,\n registryPath: string,\n coordinator: XIDDocument,\n groupId: ARID,\n successes: [XID, Round1ResponseData][],\n preview: boolean,\n): Promise<[string, string] | undefined> {\n const signerPrivateKeys = coordinator.inceptionPrivateKeys();\n if (signerPrivateKeys === undefined) {\n throw new Error(\"Coordinator XID document has no signing keys\");\n }\n\n const validUntil = new Date(Date.now() + 60 * 60 * 1000); // 1 hour from now\n\n // Build round1 packages list for request building\n const round1Packages: Round1Package[] = successes.map(([xid, data]) => [xid, data.package]);\n\n // Build participant info and messages\n const messages: [XID, ARID, Envelope, string][] = [];\n const collectArids: [XID, ARID][] = [];\n let previewOutput: [string, string] | undefined;\n\n for (const [xid, data] of successes) {\n const participant = registry.participant(xid);\n if (participant === undefined) {\n throw new Error(`Participant ${xid.urString()} not found in registry`);\n }\n const recipientDoc = participant.xidDocument();\n const participantName = participant.petName() ?? xid.urString();\n\n const collectFromArid = ARID.new();\n collectArids.push([xid, collectFromArid]);\n\n const request = buildRound2RequestForParticipant(\n coordinator,\n groupId,\n round1Packages,\n collectFromArid,\n );\n\n if (preview && previewOutput === undefined) {\n const unsealedEnvelope = request.toEnvelope(validUntil, signerPrivateKeys, undefined);\n previewOutput = [participantName, unsealedEnvelope.urString()];\n }\n\n const sealedEnvelope = request.toEnvelope(validUntil, signerPrivateKeys, recipientDoc);\n\n messages.push([xid, data.nextResponseArid, sealedEnvelope, participantName]);\n }\n\n // Blank line to separate get phase from put phase\n console.error();\n\n // Send all messages in parallel\n const sendResults = await parallelSend(client, messages, isVerbose());\n\n // Check for send failures\n const failures: [XID, string][] = [];\n for (const [xid, err] of sendResults) {\n if (err !== null) {\n failures.push([xid, err.message]);\n }\n }\n\n if (failures.length > 0) {\n for (const [xid, error] of failures) {\n console.error(`Failed to send to ${xid.urString()}: ${error}`);\n }\n throw new Error(`Failed to send Round 2 requests to ${failures.length} participants`);\n }\n\n // Update pending requests for Round 2 collection\n const newPendingRequests = new PendingRequests();\n for (const [xid, collectFromArid] of collectArids) {\n newPendingRequests.addCollectOnly(xid, collectFromArid);\n }\n const groupRecord = registry.groupMut(groupId);\n if (groupRecord === undefined) {\n throw new Error(\"Group not found in registry\");\n }\n groupRecord.setPendingRequests(newPendingRequests);\n registry.save(registryPath);\n\n return previewOutput;\n}\n\n// -----------------------------------------------------------------------------\n// Pending request updates\n// -----------------------------------------------------------------------------\n\n/**\n * Update pending requests from parallel collection results.\n *\n * Port of `update_pending_for_round2_from_collection()` from cmd/dkg/coordinator/round1.rs lines 710-726.\n */\nfunction updatePendingForRound2FromCollection(\n registry: Registry,\n registryPath: string,\n groupId: ARID,\n successes: [XID, Round1ResponseData][],\n): void {\n const newPending = new PendingRequests();\n for (const [xid, data] of successes) {\n newPending.addSendOnly(xid, data.nextResponseArid);\n }\n const groupRecord = registry.groupMut(groupId);\n if (groupRecord === undefined) {\n throw new Error(\"Group not found in registry\");\n }\n groupRecord.setPendingRequests(newPending);\n registry.save(registryPath);\n}\n\n// -----------------------------------------------------------------------------\n// Persistence\n// -----------------------------------------------------------------------------\n\n/**\n * Persist collected round 1 packages to disk.\n *\n * Port of `persist_round1_packages()` from cmd/dkg/coordinator/round1.rs lines 301-340.\n */\nfunction persistRound1Packages(\n registryPath: string,\n groupId: ARID,\n packages: Round1Package[],\n): string {\n const packagesDir = groupStateDir(registryPath, groupId.hex());\n fs.mkdirSync(packagesDir, { recursive: true });\n\n const round1PackagesPath = path.join(packagesDir, \"collected_round1.json\");\n const packagesJson: Record<string, unknown> = {};\n\n for (const [xid, pkg] of packages) {\n packagesJson[xid.urString()] = serde.round1PackageToJson(pkg);\n }\n\n fs.writeFileSync(round1PackagesPath, globalThis.JSON.stringify(packagesJson, null, 2));\n\n // Return display path (relative to cwd if possible)\n const cwd = process.cwd();\n if (round1PackagesPath.startsWith(cwd)) {\n return round1PackagesPath.slice(cwd.length + 1);\n }\n return round1PackagesPath;\n}\n\n// -----------------------------------------------------------------------------\n// Sequential collection\n// -----------------------------------------------------------------------------\n\n/**\n * Fetch all round 1 packages sequentially.\n *\n * Port of `fetch_all_round1_packages()` from cmd/dkg/coordinator/round1.rs lines 243-299.\n */\nasync function fetchAllRound1Packages(\n ctx: Round1Context,\n pendingRequests: PendingRequests,\n timeout: number | undefined,\n): Promise<[Round1Package[], NextResponseArid[]]> {\n const round1Packages: Round1Package[] = [];\n const nextResponseArids: NextResponseArid[] = [];\n const errors: [XID, string][] = [];\n\n for (const [participantXid, collectFromArid] of pendingRequests.iterCollect()) {\n const participant = ctx.registry.participant(participantXid);\n const participantName = participant?.petName() ?? participantXid.urString();\n\n try {\n const [pkg, nextArid] = await fetchRound1Response(\n ctx.client,\n collectFromArid,\n timeout,\n ctx.ownerDoc,\n ctx.groupId,\n participantName,\n );\n round1Packages.push([participantXid, pkg]);\n nextResponseArids.push([participantXid, nextArid]);\n } catch (e) {\n errors.push([participantXid, e instanceof Error ? e.message : String(e)]);\n }\n }\n\n if (errors.length > 0) {\n if (isVerbose()) {\n console.error();\n console.error(`Failed to collect from ${errors.length} participants:`);\n }\n for (const [xid, error] of errors) {\n console.error(` ${xid.urString()}: ${error}`);\n }\n throw new Error(\n `Round 1 collection incomplete: ${errors.length} of ${pendingRequests.len()} responses failed`,\n );\n }\n\n return [round1Packages, nextResponseArids];\n}\n\n/**\n * Collect round 1 responses sequentially.\n *\n * Port of `collect_round1_responses()` from cmd/dkg/coordinator/round1.rs lines 220-241.\n */\nasync function collectRound1Responses(\n ctx: Round1Context,\n pendingRequests: PendingRequests,\n timeout: number | undefined,\n): Promise<Round1Collection> {\n if (isVerbose()) {\n console.error(`Collecting Round 1 responses from ${pendingRequests.len()} participants...`);\n }\n\n const [packages, nextResponseArids] = await fetchAllRound1Packages(ctx, pendingRequests, timeout);\n\n const displayPath = persistRound1Packages(ctx.registryPath, ctx.groupId, packages);\n\n updatePendingForRound2(ctx, nextResponseArids);\n\n return { packages, nextResponseArids, displayPath };\n}\n\n/**\n * Update pending requests for round 2 (sequential path).\n *\n * Port of `update_pending_for_round2()` from cmd/dkg/coordinator/round1.rs lines 342-357.\n */\nfunction updatePendingForRound2(ctx: Round1Context, nextResponseArids: NextResponseArid[]): void {\n const newPending = new PendingRequests();\n for (const [xid, sendToArid] of nextResponseArids) {\n newPending.addSendOnly(xid, sendToArid);\n }\n const groupRecord = ctx.registry.groupMut(ctx.groupId);\n if (groupRecord === undefined) {\n throw new Error(\"Group not found in registry\");\n }\n groupRecord.setPendingRequests(newPending);\n ctx.registry.save(ctx.registryPath);\n}\n\n// -----------------------------------------------------------------------------\n// Round 2 dispatch (sequential)\n// -----------------------------------------------------------------------------\n\n/**\n * Build participant info for round 2 dispatch.\n *\n * Port of `build_round2_participant_info()` from cmd/dkg/coordinator/round1.rs lines 438-458.\n */\nfunction buildRound2ParticipantInfo(\n registry: Registry,\n nextResponseArids: NextResponseArid[],\n): [XID, XIDDocument, ARID, ARID][] {\n return nextResponseArids.map(([xid, sendToArid]) => {\n const participant = registry.participant(xid);\n if (participant === undefined) {\n throw new Error(`Participant ${xid.urString()} not found in registry`);\n }\n const doc = participant.xidDocument();\n const collectFromArid = ARID.new();\n return [xid, doc, sendToArid, collectFromArid];\n });\n}\n\n/**\n * Update pending for round 2 collection (sequential path).\n *\n * Port of `update_pending_for_round2_collection()` from cmd/dkg/coordinator/round1.rs lines 460-475.\n */\nfunction updatePendingForRound2Collection(\n ctx: Round1Context,\n participantInfo: [XID, XIDDocument, ARID, ARID][],\n): void {\n const newPendingRequests = new PendingRequests();\n for (const [xid, , , collectFromArid] of participantInfo) {\n newPendingRequests.addCollectOnly(xid, collectFromArid);\n }\n const groupRecord = ctx.registry.groupMut(ctx.groupId);\n if (groupRecord === undefined) {\n throw new Error(\"Group not found in registry\");\n }\n groupRecord.setPendingRequests(newPendingRequests);\n ctx.registry.save(ctx.registryPath);\n}\n\n/**\n * Dispatch Round 2 requests sequentially.\n *\n * Port of `dispatch_round2_requests()` from cmd/dkg/coordinator/round1.rs lines 363-436.\n */\nasync function dispatchRound2Requests(\n ctx: Round1Context,\n collection: Round1Collection,\n preview: boolean,\n): Promise<[string, string] | undefined> {\n const signerPrivateKeys = ctx.ownerDoc.inceptionPrivateKeys();\n if (signerPrivateKeys === undefined) {\n throw new Error(\"Coordinator XID document has no signing keys\");\n }\n\n const validUntil = new Date(Date.now() + 60 * 60 * 1000); // 1 hour from now\n\n const participantInfo = buildRound2ParticipantInfo(ctx.registry, collection.nextResponseArids);\n\n if (isVerbose()) {\n console.error(`Sending Round 2 requests to ${participantInfo.length} participants...`);\n } else {\n // Blank line to separate get phase from put phase\n console.error();\n }\n\n let previewOutput: [string, string] | undefined;\n\n for (const [xid, recipientDoc, sendToArid, collectFromArid] of participantInfo) {\n const participant = ctx.registry.participant(xid);\n const participantName = participant?.petName() ?? xid.urString();\n\n const request = buildRound2RequestForParticipant(\n ctx.ownerDoc,\n ctx.groupId,\n collection.packages,\n collectFromArid,\n );\n\n if (preview && previewOutput === undefined) {\n const unsealedEnvelope = request.toEnvelope(validUntil, signerPrivateKeys, undefined);\n previewOutput = [participantName, unsealedEnvelope.urString()];\n }\n\n const sealedEnvelope = request.toEnvelope(validUntil, signerPrivateKeys, recipientDoc);\n\n await putWithIndicator(ctx.client, sendToArid, sealedEnvelope, participantName, isVerbose());\n }\n\n updatePendingForRound2Collection(ctx, participantInfo);\n\n return previewOutput;\n}\n\n// -----------------------------------------------------------------------------\n// Output\n// -----------------------------------------------------------------------------\n\n/**\n * Print summary for sequential collection.\n *\n * Port of `print_summary()` from cmd/dkg/coordinator/round1.rs lines 481-506.\n */\nfunction printSummary(collection: Round1Collection, preview: [string, string] | undefined): void {\n if (preview !== undefined) {\n const [participantName, ur] = preview;\n if (isVerbose()) {\n console.error(`# Round 2 preview for ${participantName}`);\n console.error();\n }\n console.error(\n `Collected ${collection.packages.length} Round 1 packages to ${collection.displayPath} ` +\n `and sent ${collection.nextResponseArids.length} Round 2 requests.`,\n );\n console.log(ur);\n } else if (isVerbose()) {\n console.error();\n console.error(\n `Collected ${collection.packages.length} Round 1 packages to ${collection.displayPath} ` +\n `and sent ${collection.nextResponseArids.length} Round 2 requests.`,\n );\n }\n}\n\n/**\n * Print summary for parallel collection.\n *\n * Port of `print_summary_parallel()` from cmd/dkg/coordinator/round1.rs lines 847-901.\n */\nfunction printSummaryParallel(\n collection: CollectionResult<Round1ResponseData>,\n displayPath: string,\n preview: [string, string] | undefined,\n): void {\n // Report any failures\n if (collection.rejections.length > 0) {\n console.error();\n console.error(\"Rejections:\");\n for (const [xid, reason] of collection.rejections) {\n console.error(` ${xid.urString()}: ${reason}`);\n }\n }\n if (collection.errors.length > 0) {\n console.error();\n console.error(\"Errors:\");\n for (const [xid, error] of collection.errors) {\n console.error(` ${xid.urString()}: ${error}`);\n }\n }\n if (collection.timeouts.length > 0) {\n console.error();\n console.error(\"Timeouts:\");\n for (const xid of collection.timeouts) {\n console.error(` ${xid.urString()}`);\n }\n }\n\n if (!collection.allSucceeded()) {\n console.error();\n bailWithCollectionSummary(collection);\n }\n\n if (preview !== undefined) {\n const [participantName, ur] = preview;\n if (isVerbose()) {\n console.error(`# Round 2 preview for ${participantName}`);\n console.error();\n }\n console.error(\n `Collected ${collection.successes.length} Round 1 packages to ${displayPath} ` +\n `and sent ${collection.successes.length} Round 2 requests.`,\n );\n console.log(ur);\n } else if (isVerbose()) {\n console.error();\n console.error(\n `Collected ${collection.successes.length} Round 1 packages to ${displayPath} ` +\n `and sent ${collection.successes.length} Round 2 requests.`,\n );\n }\n}\n\n/**\n * Print collection summary and throw error.\n *\n * Port of `bail_with_collection_summary()` from cmd/dkg/coordinator/round1.rs lines 903-913.\n */\nfunction bailWithCollectionSummary(collection: CollectionResult<Round1ResponseData>): never {\n const msg =\n `Round 1 collection incomplete: ${collection.successes.length} succeeded, ` +\n `${collection.rejections.length} rejected, ${collection.errors.length} errors, ` +\n `${collection.timeouts.length} timeouts`;\n console.error(msg);\n throw new Error(msg);\n}\n\n// -----------------------------------------------------------------------------\n// Main entry point\n// -----------------------------------------------------------------------------\n\n/**\n * Execute the DKG coordinator round 1 command.\n *\n * Collects commitment packages from participants.\n *\n * Port of `CommandArgs::exec()` from cmd/dkg/coordinator/round1.rs lines 59-173.\n */\nexport async function round1(\n client: StorageClient,\n options: DkgRound1Options,\n cwd: string,\n): Promise<DkgRound1Result> {\n const registryPath = resolveRegistryPath(options.registryPath, cwd);\n const registry = Registry.load(registryPath);\n\n const owner = registry.owner();\n if (owner === undefined) {\n throw new Error(\"Registry owner is required\");\n }\n const ownerDoc = owner.xidDocument();\n\n const groupId = parseAridUr(options.groupId);\n const groupRecord = registry.group(groupId);\n\n if (groupRecord === undefined) {\n throw new Error(`Group ${options.groupId} not found in registry`);\n }\n\n validateCoordinator(groupRecord, owner);\n\n const pendingRequests = groupRecord.pendingRequests();\n if (pendingRequests.isEmpty()) {\n throw new Error(\"No pending requests for this group. Round 1 may already be collected.\");\n }\n\n if (options.parallel === true) {\n // Parallel path with progress display\n const collection = await collectRound1Parallel(\n client,\n registry,\n pendingRequests,\n ownerDoc,\n groupId,\n options.timeoutSeconds,\n );\n\n // Extract packages for persistence\n const packages: Round1Package[] = collection.successes.map(([xid, data]) => [\n xid,\n data.package,\n ]);\n\n const displayPath = persistRound1Packages(registryPath, groupId, packages);\n\n updatePendingForRound2FromCollection(registry, registryPath, groupId, collection.successes);\n\n const preview = await dispatchRound2RequestsParallel(\n client,\n registry,\n registryPath,\n ownerDoc,\n groupId,\n collection.successes,\n options.preview ?? false,\n );\n\n printSummaryParallel(collection, displayPath, preview);\n\n return {\n accepted: collection.successes.length,\n rejected: collection.rejections.length,\n errors: collection.errors.length,\n timeouts: collection.timeouts.length,\n };\n } else {\n // Sequential path (original behavior)\n const ctx: Round1Context = {\n client,\n registryPath,\n registry,\n ownerDoc,\n groupId,\n };\n\n const collection = await collectRound1Responses(ctx, pendingRequests, options.timeoutSeconds);\n\n const preview = await dispatchRound2Requests(ctx, collection, options.preview ?? false);\n\n printSummary(collection, preview);\n\n return {\n accepted: collection.packages.length,\n rejected: 0,\n errors: 0,\n timeouts: 0,\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkHA,SAAS,oBAAoB,aAA0B,OAA0B;CAC/E,IAAI,YAAY,YAAY,EAAE,IAAI,EAAE,SAAS,MAAM,MAAM,IAAI,EAAE,SAAS,GACtE,MAAM,IAAI,MACR,4EACkB,YAAY,YA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B,YAAY,aAAa,MAVxB,+BACpB,QACA,UACA,cACA,UACA,SACA,WAAW,WACX,QAAQ,WAAW,KACrB,CAEqD;EAErD,OAAO;GACL,UAAU,WAAW,UAAU;GAC/B,UAAU,WAAW,WAAW;GAChC,QAAQ,WAAW,OAAO;GAC1B,UAAU,WAAW,SAAS;EAChC;CACF,OAAO;EAEL,MAAM,MAAqB;GACzB;GACA;GACA;GACA;GACA;EACF;EAEA,MAAM,aAAa,MAAM,uBAAuB,KAAK,iBAAiB,QAAQ,cAAc;EAI5F,aAAa,YAAY,MAFH,uBAAuB,KAAK,YAAY,QAAQ,WAAW,KAAK,CAEtD;EAEhC,OAAO;GACL,UAAU,WAAW,SAAS;GAC9B,UAAU;GACV,QAAQ;GACR,UAAU;EACZ;CACF;AACF"}
@@ -1,8 +1,8 @@
1
- const require_chunk = require("./chunk-CZWwpsFl.cjs");
1
+ const require_chunk = require("./chunk-DakpK96I.cjs");
2
2
  const require_registry_index = require("./registry/index.cjs");
3
- const require_common = require("./common-lKP5EzHy.cjs");
4
- const require_parallel = require("./parallel-D1R6ZGlY.cjs");
5
- const require_common$1 = require("./common-lThIvJmZ.cjs");
3
+ const require_common = require("./common-CnvAUC2b.cjs");
4
+ const require_parallel = require("./parallel-szwYx-bi.cjs");
5
+ const require_common$1 = require("./common-7-BOgaTt.cjs");
6
6
  let _bcts_components = require("@bcts/components");
7
7
  let _bcts_envelope = require("@bcts/envelope");
8
8
  let _bcts_gstp = require("@bcts/gstp");
@@ -419,4 +419,4 @@ Object.defineProperty(exports, "validateAndExtractCommitResponse", {
419
419
  }
420
420
  });
421
421
 
422
- //# sourceMappingURL=round1-4Hyx8w0x.cjs.map
422
+ //# sourceMappingURL=round1-Bq0vweyQ.cjs.map