@bcts/frost-hubert 1.0.0-alpha.23 → 1.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. package/dist/bin/frost.cjs +345 -71
  2. package/dist/bin/frost.cjs.map +1 -1
  3. package/dist/bin/frost.mjs +345 -71
  4. package/dist/bin/frost.mjs.map +1 -1
  5. package/dist/busy-DkM2jAIZ.mjs +27 -0
  6. package/dist/busy-DkM2jAIZ.mjs.map +1 -0
  7. package/dist/busy-EZU7EKr6.cjs +38 -0
  8. package/dist/busy-EZU7EKr6.cjs.map +1 -0
  9. package/dist/cmd/index.cjs +28 -22
  10. package/dist/cmd/index.d.cts +2 -2
  11. package/dist/cmd/index.d.mts +2 -2
  12. package/dist/cmd/index.mjs +7 -3
  13. package/dist/cmd-Bw9_i2_f.cjs +130 -0
  14. package/dist/cmd-Bw9_i2_f.cjs.map +1 -0
  15. package/dist/cmd-CS1uJtuD.mjs +113 -0
  16. package/dist/cmd-CS1uJtuD.mjs.map +1 -0
  17. package/dist/common-CvH6dFvQ.mjs +282 -0
  18. package/dist/common-CvH6dFvQ.mjs.map +1 -0
  19. package/dist/common-DUWvtc08.mjs +96 -0
  20. package/dist/common-DUWvtc08.mjs.map +1 -0
  21. package/dist/common-lKP5EzHy.cjs +372 -0
  22. package/dist/common-lKP5EzHy.cjs.map +1 -0
  23. package/dist/common-lThIvJmZ.cjs +114 -0
  24. package/dist/common-lThIvJmZ.cjs.map +1 -0
  25. package/dist/dkg/index.cjs +6 -102
  26. package/dist/dkg/index.cjs.map +1 -1
  27. package/dist/dkg/index.d.cts +2 -2
  28. package/dist/dkg/index.d.mts +2 -2
  29. package/dist/dkg/index.mjs +4 -101
  30. package/dist/dkg/index.mjs.map +1 -1
  31. package/dist/finalize-BRgJK-Xv.cjs +402 -0
  32. package/dist/finalize-BRgJK-Xv.cjs.map +1 -0
  33. package/dist/finalize-BfLgzn8f.cjs +303 -0
  34. package/dist/finalize-BfLgzn8f.cjs.map +1 -0
  35. package/dist/finalize-CNTDj6aS.mjs +389 -0
  36. package/dist/finalize-CNTDj6aS.mjs.map +1 -0
  37. package/dist/finalize-EC3ikHQq.mjs +252 -0
  38. package/dist/finalize-EC3ikHQq.mjs.map +1 -0
  39. package/dist/finalize-IA01t_Qq.mjs +290 -0
  40. package/dist/finalize-IA01t_Qq.mjs.map +1 -0
  41. package/dist/finalize-UPyI1yb1.cjs +265 -0
  42. package/dist/finalize-UPyI1yb1.cjs.map +1 -0
  43. package/dist/{index-BkqLimZT.d.mts → index-B3c-80VS.d.cts} +26 -3
  44. package/dist/index-B3c-80VS.d.cts.map +1 -0
  45. package/dist/{index-BJlwbPYu.d.cts → index-BgbSGpxn.d.mts} +102 -80
  46. package/dist/index-BgbSGpxn.d.mts.map +1 -0
  47. package/dist/{index-BMbPgH0W.d.cts → index-C8QeHNwa.d.cts} +46 -2
  48. package/dist/{index-BMbPgH0W.d.cts.map → index-C8QeHNwa.d.cts.map} +1 -1
  49. package/dist/{index-DmxfT59Y.d.cts → index-D3QTWkEm.d.mts} +26 -3
  50. package/dist/index-D3QTWkEm.d.mts.map +1 -0
  51. package/dist/{index-DoV5HFvV.d.mts → index-DVbWyOs7.d.mts} +46 -2
  52. package/dist/{index-DoV5HFvV.d.mts.map → index-DVbWyOs7.d.mts.map} +1 -1
  53. package/dist/{index-Dzm1v4_4.d.mts → index-F1iNEAJR.d.cts} +102 -80
  54. package/dist/index-F1iNEAJR.d.cts.map +1 -0
  55. package/dist/index.cjs +31 -23
  56. package/dist/index.cjs.map +1 -1
  57. package/dist/index.d.cts +4 -4
  58. package/dist/index.d.mts +4 -4
  59. package/dist/index.mjs +9 -4
  60. package/dist/index.mjs.map +1 -1
  61. package/dist/invite-5277FQVT.cjs +274 -0
  62. package/dist/invite-5277FQVT.cjs.map +1 -0
  63. package/dist/invite-DUTcfTgX.cjs +109 -0
  64. package/dist/invite-DUTcfTgX.cjs.map +1 -0
  65. package/dist/invite-IU4n0dq2.mjs +96 -0
  66. package/dist/invite-IU4n0dq2.mjs.map +1 -0
  67. package/dist/invite-RU-OXTNS.mjs +219 -0
  68. package/dist/invite-RU-OXTNS.mjs.map +1 -0
  69. package/dist/parallel-D1R6ZGlY.cjs +318 -0
  70. package/dist/parallel-D1R6ZGlY.cjs.map +1 -0
  71. package/dist/parallel-D6zc6VW4.mjs +235 -0
  72. package/dist/parallel-D6zc6VW4.mjs.map +1 -0
  73. package/dist/proposed-participant-Dm1Eq6mX.cjs +141 -0
  74. package/dist/proposed-participant-Dm1Eq6mX.cjs.map +1 -0
  75. package/dist/proposed-participant-cWM7iUrO.mjs +129 -0
  76. package/dist/proposed-participant-cWM7iUrO.mjs.map +1 -0
  77. package/dist/receive-CAI-x4II.cjs +213 -0
  78. package/dist/receive-CAI-x4II.cjs.map +1 -0
  79. package/dist/receive-D2Nn68L7.mjs +188 -0
  80. package/dist/receive-D2Nn68L7.mjs.map +1 -0
  81. package/dist/receive-DA_KQEgk.mjs +177 -0
  82. package/dist/receive-DA_KQEgk.mjs.map +1 -0
  83. package/dist/receive-kZMsXhbK.cjs +190 -0
  84. package/dist/receive-kZMsXhbK.cjs.map +1 -0
  85. package/dist/registry/index.cjs +85 -10
  86. package/dist/registry/index.cjs.map +1 -1
  87. package/dist/registry/index.d.cts +1 -1
  88. package/dist/registry/index.d.mts +1 -1
  89. package/dist/registry/index.mjs +85 -10
  90. package/dist/registry/index.mjs.map +1 -1
  91. package/dist/{registry-loI1_Mh1.cjs → registry-9puTaRrD.cjs} +1 -1
  92. package/dist/{registry-loI1_Mh1.cjs.map → registry-9puTaRrD.cjs.map} +1 -1
  93. package/dist/{registry-CgrCZ4En.mjs → registry-BpCwtrRt.mjs} +1 -1
  94. package/dist/{registry-CgrCZ4En.mjs.map → registry-BpCwtrRt.mjs.map} +1 -1
  95. package/dist/round1-4Hyx8w0x.cjs +422 -0
  96. package/dist/round1-4Hyx8w0x.cjs.map +1 -0
  97. package/dist/round1-7v9LlE11.mjs +373 -0
  98. package/dist/round1-7v9LlE11.mjs.map +1 -0
  99. package/dist/round1-BHBjru1m.cjs +465 -0
  100. package/dist/round1-BHBjru1m.cjs.map +1 -0
  101. package/dist/round1-CMLKN2RR.mjs +195 -0
  102. package/dist/round1-CMLKN2RR.mjs.map +1 -0
  103. package/dist/round1-CWSXZx5R.cjs +208 -0
  104. package/dist/round1-CWSXZx5R.cjs.map +1 -0
  105. package/dist/round1-CcQCGlIT.mjs +208 -0
  106. package/dist/round1-CcQCGlIT.mjs.map +1 -0
  107. package/dist/round1-Cgm7j1kI.mjs +452 -0
  108. package/dist/round1-Cgm7j1kI.mjs.map +1 -0
  109. package/dist/round1-DQ0fnc1H.cjs +221 -0
  110. package/dist/round1-DQ0fnc1H.cjs.map +1 -0
  111. package/dist/round2-BWz9SQIi.cjs +305 -0
  112. package/dist/round2-BWz9SQIi.cjs.map +1 -0
  113. package/dist/round2-BkNRCXgS.mjs +292 -0
  114. package/dist/round2-BkNRCXgS.mjs.map +1 -0
  115. package/dist/round2-Bl2uK93U.mjs +450 -0
  116. package/dist/round2-Bl2uK93U.mjs.map +1 -0
  117. package/dist/round2-CdUT-AhH.cjs +499 -0
  118. package/dist/round2-CdUT-AhH.cjs.map +1 -0
  119. package/dist/round2-DOA3rnV-.mjs +280 -0
  120. package/dist/round2-DOA3rnV-.mjs.map +1 -0
  121. package/dist/round2-Dg24w-TU.mjs +397 -0
  122. package/dist/round2-Dg24w-TU.mjs.map +1 -0
  123. package/dist/round2-LylCa84n.cjs +293 -0
  124. package/dist/round2-LylCa84n.cjs.map +1 -0
  125. package/dist/round2-o2Q-GMbX.cjs +410 -0
  126. package/dist/round2-o2Q-GMbX.cjs.map +1 -0
  127. package/dist/storage-B-Gu68-O.cjs +79 -0
  128. package/dist/storage-B-Gu68-O.cjs.map +1 -0
  129. package/dist/storage-Bkkliz0K.mjs +74 -0
  130. package/dist/storage-Bkkliz0K.mjs.map +1 -0
  131. package/package.json +10 -10
  132. package/src/bin/frost.ts +849 -128
  133. package/src/cmd/common.ts +19 -1
  134. package/src/cmd/dkg/common.ts +97 -10
  135. package/src/cmd/dkg/coordinator/invite.ts +5 -2
  136. package/src/cmd/dkg/participant/finalize.ts +51 -17
  137. package/src/cmd/dkg/participant/round1.ts +39 -38
  138. package/src/cmd/dkg/participant/round2.ts +60 -26
  139. package/src/cmd/sign/coordinator/round2.ts +5 -1
  140. package/src/cmd/sign/participant/finalize.ts +6 -2
  141. package/src/cmd/sign/participant/receive.ts +5 -2
  142. package/src/dkg/group-invite.ts +12 -2
  143. package/src/dkg/proposed-participant.ts +32 -3
  144. package/src/registry/owner-record.ts +12 -0
  145. package/src/registry/participant-record.ts +35 -2
  146. package/src/registry/registry-impl.ts +74 -18
  147. package/dist/cmd-5yLeC_QL.mjs +0 -4708
  148. package/dist/cmd-5yLeC_QL.mjs.map +0 -1
  149. package/dist/cmd-BfZjC3Uh.cjs +0 -4847
  150. package/dist/cmd-BfZjC3Uh.cjs.map +0 -1
  151. package/dist/index-BJlwbPYu.d.cts.map +0 -1
  152. package/dist/index-BkqLimZT.d.mts.map +0 -1
  153. package/dist/index-DmxfT59Y.d.cts.map +0 -1
  154. package/dist/index-Dzm1v4_4.d.mts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["XID","ARID","SigningPublicKey","sanitizeXidUr","UR","Envelope","XIDDocument","XIDVerifySignature","UR","Envelope","XIDDocument","XIDVerifySignature","fs","path"],"sources":["../../src/registry/group-record.ts","../../src/registry/owner-record.ts","../../src/registry/participant-record.ts","../../src/registry/registry-impl.ts"],"sourcesContent":["/**\n * Copyright © 2023-2026 Blockchain Commons, LLC\n * Copyright © 2025-2026 Parity Technologies\n *\n *\n * Group record for the registry.\n *\n * Port of registry/group_record.rs from frost-hubert-rust.\n *\n * @module\n */\n\nimport { ARID, SigningPublicKey, XID } from \"@bcts/components\";\n\n/**\n * A participant in a group.\n *\n * Port of `struct GroupParticipant` from group_record.rs lines 9-13.\n */\nexport class GroupParticipant {\n private readonly _xid: XID;\n\n constructor(xid: XID) {\n this._xid = xid;\n }\n\n xid(): XID {\n return this._xid;\n }\n\n toJSON(): string {\n return this._xid.urString();\n }\n\n static fromJSON(value: string): GroupParticipant {\n const xid = XID.fromURString(value);\n return new GroupParticipant(xid);\n }\n}\n\n/**\n * Contribution paths for DKG state files.\n *\n * Port of `struct ContributionPaths` from group_record.rs lines 21-29.\n */\nexport class ContributionPaths {\n round1Secret?: string | undefined;\n round1Package?: string | undefined;\n round2Secret?: string | undefined;\n keyPackage?: string | undefined;\n\n constructor(init?: Partial<ContributionPaths>) {\n if (init !== undefined) {\n this.round1Secret = init.round1Secret;\n this.round1Package = init.round1Package;\n this.round2Secret = init.round2Secret;\n this.keyPackage = init.keyPackage;\n }\n }\n\n /**\n * Merge missing fields from another ContributionPaths.\n *\n * Port of `ContributionPaths::merge_missing()` from group_record.rs lines 32-45.\n */\n mergeMissing(other: ContributionPaths): void {\n this.round1Secret ??= other.round1Secret;\n this.round1Package ??= other.round1Package;\n this.round2Secret ??= other.round2Secret;\n this.keyPackage ??= other.keyPackage;\n }\n\n /**\n * Check if all fields are empty.\n *\n * Port of `ContributionPaths::is_empty()` from group_record.rs lines 47-53.\n */\n isEmpty(): boolean {\n return (\n this.round1Secret === undefined &&\n this.round1Package === undefined &&\n this.round2Secret === undefined &&\n this.keyPackage === undefined\n );\n }\n\n toJSON(): Record<string, string> {\n const obj: Record<string, string> = {};\n if (this.round1Secret !== undefined) obj[\"round1_secret\"] = this.round1Secret;\n if (this.round1Package !== undefined) obj[\"round1_package\"] = this.round1Package;\n if (this.round2Secret !== undefined) obj[\"round2_secret\"] = this.round2Secret;\n if (this.keyPackage !== undefined) obj[\"key_package\"] = this.keyPackage;\n return obj;\n }\n\n static fromJSON(json: Record<string, string>): ContributionPaths {\n return new ContributionPaths({\n round1Secret: json[\"round1_secret\"],\n round1Package: json[\"round1_package\"],\n round2Secret: json[\"round2_secret\"],\n keyPackage: json[\"key_package\"],\n });\n }\n}\n\n/**\n * A pending request entry.\n */\ninterface PendingRequestEntry {\n participant: XID;\n sendToArid?: ARID | undefined;\n collectFromArid: ARID;\n}\n\n/**\n * Tracks pending communication with participants (coordinator-side).\n *\n * Port of `struct PendingRequests` from group_record.rs lines 71-75.\n */\nexport class PendingRequests {\n private readonly requests: PendingRequestEntry[] = [];\n\n /**\n * Add a pending request where we only know where to collect from.\n *\n * Port of `PendingRequests::add_collect_only()` from group_record.rs lines 90-99.\n */\n addCollectOnly(participant: XID, collectFromArid: ARID): void {\n this.requests.push({\n participant,\n sendToArid: undefined,\n collectFromArid,\n });\n }\n\n /**\n * Add a pending request where we know where to send AND where to collect.\n *\n * Port of `PendingRequests::add_send_and_collect()` from group_record.rs lines 103-115.\n */\n addSendAndCollect(participant: XID, sendToArid: ARID, collectFromArid: ARID): void {\n this.requests.push({\n participant,\n sendToArid,\n collectFromArid,\n });\n }\n\n /**\n * Add a pending request where we only know where to send.\n *\n * Port of `PendingRequests::add_send_only()` from group_record.rs lines 118-127.\n */\n addSendOnly(participant: XID, sendToArid: ARID): void {\n this.requests.push({\n participant,\n sendToArid,\n collectFromArid: sendToArid, // Placeholder\n });\n }\n\n /**\n * Check if there are no pending requests.\n *\n * Port of `PendingRequests::is_empty()` from group_record.rs line 129.\n */\n isEmpty(): boolean {\n return this.requests.length === 0;\n }\n\n /**\n * Get the number of pending requests.\n *\n * Port of `PendingRequests::len()` from group_record.rs line 165.\n */\n len(): number {\n return this.requests.length;\n }\n\n /**\n * Iterate over (participant, collectFromArid) pairs.\n *\n * Port of `PendingRequests::iter_collect()` from group_record.rs lines 132-138.\n */\n *iterCollect(): Generator<[XID, ARID]> {\n for (const r of this.requests) {\n yield [r.participant, r.collectFromArid];\n }\n }\n\n /**\n * Iterate over (participant, sendToArid) pairs.\n *\n * Port of `PendingRequests::iter_send()` from group_record.rs lines 141-150.\n */\n *iterSend(): Generator<[XID, ARID]> {\n for (const r of this.requests) {\n if (r.sendToArid === undefined) {\n throw new Error(\"send_to_arid not set for this request\");\n }\n yield [r.participant, r.sendToArid];\n }\n }\n\n /**\n * Iterate over full (participant, sendToArid, collectFromArid) tuples.\n *\n * Port of `PendingRequests::iter_full()` from group_record.rs lines 153-163.\n */\n *iterFull(): Generator<[XID, ARID | undefined, ARID]> {\n for (const r of this.requests) {\n yield [r.participant, r.sendToArid, r.collectFromArid];\n }\n }\n\n toJSON(): unknown[] {\n return this.requests.map((r) => ({\n participant: r.participant.urString(),\n send_to_arid: r.sendToArid?.urString(),\n collect_from_arid: r.collectFromArid.urString(),\n }));\n }\n\n static fromJSON(json: unknown[]): PendingRequests {\n const pr = new PendingRequests();\n for (const entry of json as Record<string, string>[]) {\n const participant = XID.fromURString(entry[\"participant\"]);\n const sendToArid =\n entry[\"send_to_arid\"] !== undefined && entry[\"send_to_arid\"] !== \"\"\n ? ARID.fromURString(entry[\"send_to_arid\"])\n : undefined;\n const collectFromArid = ARID.fromURString(entry[\"collect_from_arid\"]);\n pr.requests.push({ participant, sendToArid, collectFromArid });\n }\n return pr;\n }\n}\n\n/**\n * Record of a DKG group.\n *\n * Port of `struct GroupRecord` from group_record.rs lines 168-186.\n */\nexport class GroupRecord {\n private readonly _charter: string;\n private readonly _minSigners: number;\n private readonly _coordinator: GroupParticipant;\n private readonly _participants: GroupParticipant[];\n private _contributions: ContributionPaths;\n private _listeningAtArid?: ARID | undefined;\n private _pendingRequests: PendingRequests;\n private _verifyingKey?: SigningPublicKey | undefined;\n\n constructor(\n charter: string,\n minSigners: number,\n coordinator: GroupParticipant,\n participants: GroupParticipant[],\n ) {\n this._charter = charter;\n this._minSigners = minSigners;\n this._coordinator = coordinator;\n this._participants = participants;\n this._contributions = new ContributionPaths();\n this._listeningAtArid = undefined;\n this._pendingRequests = new PendingRequests();\n this._verifyingKey = undefined;\n }\n\n coordinator(): GroupParticipant {\n return this._coordinator;\n }\n\n participants(): GroupParticipant[] {\n return this._participants;\n }\n\n minSigners(): number {\n return this._minSigners;\n }\n\n charter(): string {\n return this._charter;\n }\n\n contributions(): ContributionPaths {\n return this._contributions;\n }\n\n setContributions(contributions: ContributionPaths): void {\n this._contributions = contributions;\n }\n\n mergeContributions(other: ContributionPaths): void {\n this._contributions.mergeMissing(other);\n }\n\n listeningAtArid(): ARID | undefined {\n return this._listeningAtArid;\n }\n\n setListeningAtArid(arid: ARID): void {\n this._listeningAtArid = arid;\n }\n\n clearListeningAtArid(): void {\n this._listeningAtArid = undefined;\n }\n\n pendingRequests(): PendingRequests {\n return this._pendingRequests;\n }\n\n setPendingRequests(requests: PendingRequests): void {\n this._pendingRequests = requests;\n }\n\n clearPendingRequests(): void {\n this._pendingRequests = new PendingRequests();\n }\n\n /**\n * Check if the config matches another group record.\n *\n * Port of `GroupRecord::config_matches()` from group_record.rs lines 247-253.\n */\n configMatches(other: GroupRecord): boolean {\n return (\n this._charter === other._charter &&\n this._minSigners === other._minSigners &&\n this._coordinator.xid().toString() === other._coordinator.xid().toString() &&\n this._participants.length === other._participants.length &&\n this._participants.every(\n (p, i) => p.xid().toString() === other._participants[i].xid().toString(),\n )\n );\n }\n\n verifyingKey(): SigningPublicKey | undefined {\n return this._verifyingKey;\n }\n\n setVerifyingKey(key: SigningPublicKey): void {\n this._verifyingKey = key;\n }\n\n toJSON(): Record<string, unknown> {\n const obj: Record<string, unknown> = {\n charter: this._charter,\n min_signers: this._minSigners,\n coordinator: this._coordinator.toJSON(),\n participants: this._participants.map((p) => p.toJSON()),\n };\n if (!this._contributions.isEmpty()) {\n obj[\"contributions\"] = this._contributions.toJSON();\n }\n if (this._listeningAtArid !== undefined) {\n obj[\"listening_at_arid\"] = this._listeningAtArid.urString();\n }\n if (!this._pendingRequests.isEmpty()) {\n obj[\"pending_requests\"] = this._pendingRequests.toJSON();\n }\n if (this._verifyingKey !== undefined) {\n obj[\"verifying_key\"] = this._verifyingKey.urString();\n }\n return obj;\n }\n\n static fromJSON(json: Record<string, unknown>): GroupRecord {\n const charter = json[\"charter\"] as string;\n const minSigners = json[\"min_signers\"] as number;\n const coordinator = GroupParticipant.fromJSON(json[\"coordinator\"] as string);\n const participants = (json[\"participants\"] as string[]).map((p) =>\n GroupParticipant.fromJSON(p),\n );\n\n const record = new GroupRecord(charter, minSigners, coordinator, participants);\n\n if (json[\"contributions\"] !== undefined) {\n record._contributions = ContributionPaths.fromJSON(\n json[\"contributions\"] as Record<string, string>,\n );\n }\n if (json[\"listening_at_arid\"] !== undefined) {\n record._listeningAtArid = ARID.fromURString(json[\"listening_at_arid\"] as string);\n }\n if (json[\"pending_requests\"] !== undefined) {\n record._pendingRequests = PendingRequests.fromJSON(json[\"pending_requests\"] as unknown[]);\n }\n if (json[\"verifying_key\"] !== undefined) {\n record._verifyingKey = SigningPublicKey.fromURString(json[\"verifying_key\"] as string);\n }\n\n return record;\n }\n}\n","/**\n * Copyright © 2023-2026 Blockchain Commons, LLC\n * Copyright © 2025-2026 Parity Technologies\n *\n *\n * Owner record for the registry.\n *\n * Port of registry/owner_record.rs from frost-hubert-rust.\n *\n * @module\n */\n\nimport { type XID } from \"@bcts/components\";\nimport { Envelope } from \"@bcts/envelope\";\nimport { UR } from \"@bcts/uniform-resources\";\nimport { XIDDocument, XIDVerifySignature } from \"@bcts/xid\";\n\n/**\n * Record of the registry owner (coordinator).\n *\n * Port of `struct OwnerRecord` from owner_record.rs lines 13-17.\n */\nexport class OwnerRecord {\n private readonly _xidDocumentUr: string;\n private readonly _xidDocument: XIDDocument;\n private readonly _petName: string | undefined;\n\n private constructor(\n xidDocumentUr: string,\n xidDocument: XIDDocument,\n petName: string | undefined,\n ) {\n this._xidDocumentUr = xidDocumentUr;\n this._xidDocument = xidDocument;\n this._petName = petName;\n }\n\n /**\n * Create an owner record from a signed XID UR string.\n *\n * Port of `OwnerRecord::from_signed_xid_ur()` from owner_record.rs lines 20-32.\n */\n static fromSignedXidUr(xidDocumentUr: string, petName?: string): OwnerRecord {\n const [raw, document] = parseRelaxedXidDocument(xidDocumentUr);\n\n if (document.inceptionPrivateKeys() === undefined) {\n throw new Error(\"Owner XID document must include private keys\");\n }\n\n return new OwnerRecord(raw, document, petName);\n }\n\n /**\n * Get the XID of the owner.\n *\n * Port of `OwnerRecord::xid()` from owner_record.rs line 34.\n */\n xid(): XID {\n return this._xidDocument.xid();\n }\n\n /**\n * Get the XID document of the owner.\n *\n * Port of `OwnerRecord::xid_document()` from owner_record.rs line 36.\n */\n xidDocument(): XIDDocument {\n return this._xidDocument;\n }\n\n /**\n * Get the UR string of the XID document.\n *\n * Port of `OwnerRecord::xid_document_ur()` from owner_record.rs line 38.\n */\n xidDocumentUr(): string {\n return this._xidDocumentUr;\n }\n\n /**\n * Get the pet name of the owner.\n *\n * Port of `OwnerRecord::pet_name()` from owner_record.rs line 40.\n */\n petName(): string | undefined {\n return this._petName;\n }\n\n /**\n * Serialize to JSON object.\n */\n toJSON(): Record<string, unknown> {\n const obj: Record<string, unknown> = {\n xid_document: this._xidDocumentUr,\n };\n if (this._petName !== undefined) {\n obj[\"pet_name\"] = this._petName;\n }\n return obj;\n }\n\n /**\n * Deserialize from JSON object.\n */\n static fromJSON(json: Record<string, unknown>): OwnerRecord {\n const xidDocumentUr = json[\"xid_document\"] as string;\n const petName = json[\"pet_name\"] as string | undefined;\n return OwnerRecord.fromSignedXidUr(xidDocumentUr, petName);\n }\n}\n\n/**\n * Parse a XID document with relaxed validation (no signature verification).\n *\n * Port of `parse_relaxed_xid_document()` from owner_record.rs lines 144-165.\n */\nfunction parseRelaxedXidDocument(xidDocumentUr: string): [string, XIDDocument] {\n const sanitized = sanitizeXidUr(xidDocumentUr);\n const ur = UR.fromURString(sanitized);\n\n if (ur.urTypeStr() !== \"xid\" && ur.urTypeStr() !== \"envelope\") {\n throw new Error(`Expected a ur:xid document, found ur:${ur.urTypeStr()}`);\n }\n\n const envelopeCbor = ur.cbor();\n let envelope: Envelope;\n try {\n envelope = Envelope.fromTaggedCbor(envelopeCbor);\n } catch {\n envelope = Envelope.fromUntaggedCbor(envelopeCbor);\n }\n\n const document = XIDDocument.fromEnvelope(envelope, undefined, XIDVerifySignature.None);\n\n return [sanitized, document];\n}\n\n/**\n * Sanitize XID UR input.\n *\n * Port of `sanitize_xid_ur()` from owner_record.rs lines 167-174.\n */\nfunction sanitizeXidUr(input: string): string {\n const trimmed = input.trim();\n if (trimmed.length === 0) {\n throw new Error(\"XID document is required\");\n }\n return trimmed;\n}\n","/**\n * Copyright © 2023-2026 Blockchain Commons, LLC\n * Copyright © 2025-2026 Parity Technologies\n *\n *\n * Participant record for the registry.\n *\n * Port of registry/participant_record.rs from frost-hubert-rust.\n *\n * @module\n */\n\nimport { type PublicKeys, type XID } from \"@bcts/components\";\nimport { Envelope } from \"@bcts/envelope\";\nimport { UR } from \"@bcts/uniform-resources\";\nimport { XIDDocument, XIDVerifySignature } from \"@bcts/xid\";\n\n/**\n * Record of a participant in the registry.\n *\n * Port of `struct ParticipantRecord` from participant_record.rs lines 12-17.\n */\nexport class ParticipantRecord {\n private readonly _xidDocumentUr: string;\n private readonly _xidDocument: XIDDocument;\n private readonly _publicKeys: PublicKeys;\n private readonly _petName: string | undefined;\n\n private constructor(\n xidDocumentUr: string,\n xidDocument: XIDDocument,\n publicKeys: PublicKeys,\n petName: string | undefined,\n ) {\n this._xidDocumentUr = xidDocumentUr;\n this._xidDocument = xidDocument;\n this._publicKeys = publicKeys;\n this._petName = petName;\n }\n\n /**\n * Create a participant record from a signed XID UR string.\n *\n * Port of `ParticipantRecord::from_signed_xid_ur()` from participant_record.rs lines 20-26.\n */\n static fromSignedXidUr(xidDocumentUr: string, petName?: string): ParticipantRecord {\n const [raw, document] = parseSignedXidDocument(xidDocumentUr);\n return ParticipantRecord.buildFromParts(document, raw, petName);\n }\n\n /**\n * Get the pet name of the participant.\n *\n * Port of `ParticipantRecord::pet_name()` from participant_record.rs line 28.\n */\n petName(): string | undefined {\n return this._petName;\n }\n\n /**\n * Get the public keys of the participant.\n *\n * Port of `ParticipantRecord::public_keys()` from participant_record.rs line 29.\n */\n publicKeys(): PublicKeys {\n return this._publicKeys;\n }\n\n /**\n * Get the XID of the participant.\n *\n * Port of `ParticipantRecord::xid()` from participant_record.rs line 30.\n */\n xid(): XID {\n return this._xidDocument.xid();\n }\n\n /**\n * Get the XID document of the participant.\n *\n * Port of `ParticipantRecord::xid_document()` from participant_record.rs line 31.\n */\n xidDocument(): XIDDocument {\n return this._xidDocument;\n }\n\n /**\n * Get the UR string of the XID document.\n *\n * Port of `ParticipantRecord::xid_document_ur()` from participant_record.rs line 32.\n */\n xidDocumentUr(): string {\n return this._xidDocumentUr;\n }\n\n /**\n * Build from constituent parts.\n *\n * Port of `ParticipantRecord::build_from_parts()` from participant_record.rs lines 34-49.\n */\n private static buildFromParts(\n document: XIDDocument,\n xidDocumentUr: string,\n petName: string | undefined,\n ): ParticipantRecord {\n const inceptionKey = document.inceptionKey();\n if (inceptionKey === undefined) {\n throw new Error(\"XID document missing inception key\");\n }\n\n const publicKeys = inceptionKey.publicKeys();\n\n return new ParticipantRecord(xidDocumentUr, document, publicKeys, petName);\n }\n\n /**\n * Recreate from serialized data.\n *\n * Port of `ParticipantRecord::recreate_from_serialized()` from participant_record.rs lines 51-57.\n */\n private static recreateFromSerialized(\n xidDocumentUr: string,\n petName: string | undefined,\n ): ParticipantRecord {\n const [raw, document] = parseSignedXidDocument(xidDocumentUr);\n return ParticipantRecord.buildFromParts(document, raw, petName);\n }\n\n /**\n * Serialize to JSON object.\n */\n toJSON(): Record<string, unknown> {\n const obj: Record<string, unknown> = {\n xid_document: this._xidDocumentUr,\n };\n if (this._petName !== undefined) {\n obj[\"pet_name\"] = this._petName;\n }\n return obj;\n }\n\n /**\n * Deserialize from JSON object.\n */\n static fromJSON(json: Record<string, unknown>): ParticipantRecord {\n const xidDocumentUr = json[\"xid_document\"] as string;\n const petName = json[\"pet_name\"] as string | undefined;\n return ParticipantRecord.recreateFromSerialized(xidDocumentUr, petName);\n }\n}\n\n/**\n * Parse a signed XID document from a UR string.\n *\n * Port of `parse_signed_xid_document()` from participant_record.rs lines 170-194.\n */\nfunction parseSignedXidDocument(xidDocumentUr: string): [string, XIDDocument] {\n const sanitized = sanitizeXidUr(xidDocumentUr);\n const ur = UR.fromURString(sanitized);\n\n if (ur.urTypeStr() !== \"xid\" && ur.urTypeStr() !== \"envelope\") {\n throw new Error(`Expected a ur:xid document, found ur:${ur.urTypeStr()}`);\n }\n\n const envelopeCbor = ur.cbor();\n let envelope: Envelope;\n try {\n envelope = Envelope.fromTaggedCbor(envelopeCbor);\n } catch {\n envelope = Envelope.fromUntaggedCbor(envelopeCbor);\n }\n\n const document = XIDDocument.fromEnvelope(envelope, undefined, XIDVerifySignature.Inception);\n\n return [sanitized, document];\n}\n\n/**\n * Sanitize XID UR input.\n *\n * Port of `sanitize_xid_ur()` from participant_record.rs lines 196-203.\n */\nfunction sanitizeXidUr(input: string): string {\n const trimmed = input.trim();\n if (trimmed.length === 0) {\n throw new Error(\"XID document is required\");\n }\n return trimmed;\n}\n","/**\n * Copyright © 2023-2026 Blockchain Commons, LLC\n * Copyright © 2025-2026 Parity Technologies\n *\n *\n * Registry implementation for managing participants and groups.\n *\n * Port of registry/registry_impl.rs from frost-hubert-rust.\n *\n * @module\n */\n\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\n\nimport { type ARID, type XID } from \"@bcts/components\";\n\nimport { GroupRecord } from \"./group-record.js\";\nimport { OwnerRecord } from \"./owner-record.js\";\nimport { ParticipantRecord } from \"./participant-record.js\";\n\n/**\n * Outcome of adding a participant to the registry.\n *\n * Port of `enum AddOutcome` from registry_impl.rs.\n */\nexport enum AddOutcome {\n /** Participant was already present in the registry */\n AlreadyPresent = \"already_present\",\n /** Participant was successfully inserted */\n Inserted = \"inserted\",\n}\n\n/**\n * Outcome of setting the owner in the registry.\n *\n * Port of `enum OwnerOutcome` from registry_impl.rs.\n */\nexport enum OwnerOutcome {\n /** Owner was already present in the registry */\n AlreadyPresent = \"already_present\",\n /** Owner was successfully inserted */\n Inserted = \"inserted\",\n}\n\n/**\n * Outcome of recording a group in the registry.\n *\n * Port of `enum GroupOutcome` from registry_impl.rs.\n */\nexport enum GroupOutcome {\n /** Group was successfully inserted as new */\n Inserted = \"inserted\",\n /** Group already existed and was updated (contributions merged) */\n Updated = \"updated\",\n}\n\n/**\n * Registry for managing participants and groups.\n *\n * Port of `struct Registry` from registry_impl.rs lines 22-26.\n */\nexport class Registry {\n private _owner?: OwnerRecord | undefined;\n private readonly _participants: Map<string, ParticipantRecord>; // Map by XID UR string\n private readonly _groups: Map<string, GroupRecord>; // Map by ARID hex\n\n constructor() {\n this._owner = undefined;\n this._participants = new Map();\n this._groups = new Map();\n }\n\n /**\n * Get the owner record.\n */\n owner(): OwnerRecord | undefined {\n return this._owner;\n }\n\n /**\n * Set the owner record.\n *\n * Returns the outcome indicating whether the owner was already present or newly inserted.\n *\n * Port of `Registry::set_owner()` from registry_impl.rs.\n */\n setOwner(owner: OwnerRecord): OwnerOutcome {\n // Check for pet name conflicts with participants\n const petName = owner.petName();\n if (petName !== undefined) {\n const conflicting = this.participantByPetName(petName);\n if (conflicting?.[1].petName() === petName) {\n throw new Error(`Pet name '${petName}' already used by a participant`);\n }\n }\n\n if (this._owner === undefined) {\n this._owner = owner;\n return OwnerOutcome.Inserted;\n }\n\n const existing = this._owner;\n const existingXidUr = existing.xid().urString();\n const ownerXidUr = owner.xid().urString();\n\n if (\n existingXidUr === ownerXidUr &&\n existing.xidDocumentUr() === owner.xidDocumentUr() &&\n existing.petName() === owner.petName()\n ) {\n return OwnerOutcome.AlreadyPresent;\n }\n\n if (existingXidUr === ownerXidUr) {\n if (existing.xidDocumentUr() !== owner.xidDocumentUr()) {\n throw new Error(\"Owner already exists with different keys\");\n }\n this._owner = owner;\n return OwnerOutcome.Inserted;\n }\n\n throw new Error(`Owner already recorded for ${existing.xid().toString()}`);\n }\n\n /**\n * Get all participants.\n */\n participants(): Map<string, ParticipantRecord> {\n return this._participants;\n }\n\n /**\n * Get a participant by XID.\n */\n participant(xid: XID): ParticipantRecord | undefined {\n return this._participants.get(xid.urString());\n }\n\n /**\n * Add a participant.\n *\n * Returns the outcome indicating whether the participant was already present or newly inserted.\n */\n addParticipant(xid: XID, record: ParticipantRecord): AddOutcome {\n const xidUr = xid.urString();\n\n // Check if already present\n if (this._participants.has(xidUr)) {\n return AddOutcome.AlreadyPresent;\n }\n\n // Check for conflicting pet name\n const petName = record.petName();\n if (petName !== undefined && this.petNameExists(petName)) {\n throw new Error(`Pet name \"${petName}\" is already used by another participant`);\n }\n\n this._participants.set(xidUr, record);\n return AddOutcome.Inserted;\n }\n\n /**\n * Check if a pet name is already used.\n */\n petNameExists(petName: string): boolean {\n for (const record of this._participants.values()) {\n if (record.petName() === petName) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Find a participant by pet name.\n *\n * Port of `Registry::participant_by_pet_name()` from registry_impl.rs.\n */\n participantByPetName(petName: string): [XID, ParticipantRecord] | undefined {\n for (const record of this._participants.values()) {\n if (record.petName() === petName) {\n return [record.xid(), record];\n }\n }\n return undefined;\n }\n\n /**\n * Get all groups.\n */\n groups(): Map<string, GroupRecord> {\n return this._groups;\n }\n\n /**\n * Get a group by ARID.\n */\n group(arid: ARID): GroupRecord | undefined {\n return this._groups.get(arid.hex());\n }\n\n /**\n * Get a mutable reference to a group by ARID.\n */\n groupMut(arid: ARID): GroupRecord | undefined {\n return this._groups.get(arid.hex());\n }\n\n /**\n * Record a group in the registry.\n *\n * If the group already exists:\n * - Validates that the config matches\n * - Merges contributions from the new record\n * - Updates verifying key if not already set\n *\n * Port of `Registry::record_group()` from registry_impl.rs.\n */\n recordGroup(groupId: ARID, record: GroupRecord): GroupOutcome {\n const key = groupId.hex();\n const existing = this._groups.get(key);\n\n if (existing !== undefined) {\n // Validate config matches\n if (!existing.configMatches(record)) {\n throw new Error(`Group ${groupId.hex()} already exists with a different configuration`);\n }\n\n // Merge contributions\n existing.mergeContributions(record.contributions());\n\n // Update verifying key if not already set\n const existingKey = existing.verifyingKey();\n const recordKey = record.verifyingKey();\n if (existingKey === undefined && recordKey !== undefined) {\n existing.setVerifyingKey(recordKey);\n } else if (\n existingKey !== undefined &&\n recordKey !== undefined &&\n existingKey.urString() !== recordKey.urString()\n ) {\n throw new Error(`Group ${groupId.hex()} already exists with a different verifying key`);\n }\n\n return GroupOutcome.Updated;\n }\n\n this._groups.set(key, record);\n return GroupOutcome.Inserted;\n }\n\n /**\n * Add a group (simple variant without merge logic).\n *\n * @deprecated Use recordGroup() for proper merge behavior.\n */\n addGroup(arid: ARID, record: GroupRecord): void {\n this._groups.set(arid.hex(), record);\n }\n\n /**\n * Load a registry from a file.\n */\n static load(filePath: string): Registry {\n if (!fs.existsSync(filePath)) {\n return new Registry();\n }\n\n const content = fs.readFileSync(filePath, \"utf-8\");\n const json = JSON.parse(content) as Record<string, unknown>;\n return Registry.fromJSON(json);\n }\n\n /**\n * Save the registry to a file.\n */\n save(filePath: string): void {\n const dir = path.dirname(filePath);\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir, { recursive: true });\n }\n\n const json = this.toJSON();\n fs.writeFileSync(filePath, JSON.stringify(json, null, 2));\n }\n\n /**\n * Serialize to JSON object.\n */\n toJSON(): Record<string, unknown> {\n const participants: Record<string, unknown> = {};\n for (const [xidUr, record] of this._participants) {\n participants[xidUr] = record.toJSON();\n }\n\n const groups: Record<string, unknown> = {};\n for (const [aridHex, record] of this._groups) {\n groups[aridHex] = record.toJSON();\n }\n\n const obj: Record<string, unknown> = {\n groups,\n participants,\n };\n\n if (this._owner !== undefined) {\n obj[\"owner\"] = this._owner.toJSON();\n }\n\n return obj;\n }\n\n /**\n * Deserialize from JSON object.\n */\n static fromJSON(json: Record<string, unknown>): Registry {\n const registry = new Registry();\n\n if (json[\"owner\"] !== undefined) {\n registry._owner = OwnerRecord.fromJSON(json[\"owner\"] as Record<string, unknown>);\n }\n\n const participantsJson = json[\"participants\"] as\n | Record<string, Record<string, unknown>>\n | undefined;\n if (participantsJson !== undefined) {\n for (const [, recordJson] of Object.entries(participantsJson)) {\n const record = ParticipantRecord.fromJSON(recordJson);\n registry._participants.set(record.xid().urString(), record);\n }\n }\n\n const groupsJson = json[\"groups\"] as Record<string, Record<string, unknown>> | undefined;\n if (groupsJson !== undefined) {\n for (const [aridHex, recordJson] of Object.entries(groupsJson)) {\n const record = GroupRecord.fromJSON(recordJson);\n registry._groups.set(aridHex, record);\n }\n }\n\n return registry;\n }\n}\n\n/**\n * Resolve the registry file path from a given argument.\n *\n * Port of `resolve_registry_path()` from registry/mod.rs lines 49-78.\n */\nexport function resolveRegistryPath(registryArg: string | undefined, cwd: string): string {\n if (registryArg === undefined || registryArg === \"\") {\n return path.join(cwd, \"registry.json\");\n }\n\n // If it ends with / or is a directory, append registry.json\n if (registryArg.endsWith(\"/\") || registryArg.endsWith(path.sep)) {\n return path.join(cwd, registryArg, \"registry.json\");\n }\n\n // If it's just a filename, put it in cwd\n if (!registryArg.includes(\"/\") && !registryArg.includes(path.sep)) {\n return path.join(cwd, registryArg);\n }\n\n // Otherwise, treat as relative path\n return path.resolve(cwd, registryArg);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,IAAa,mBAAb,MAAa,iBAAiB;CAC5B;CAEA,YAAY,KAAU;AACpB,OAAK,OAAO;;CAGd,MAAW;AACT,SAAO,KAAK;;CAGd,SAAiB;AACf,SAAO,KAAK,KAAK,UAAU;;CAG7B,OAAO,SAAS,OAAiC;AAE/C,SAAO,IAAI,iBADCA,iBAAAA,IAAI,aAAa,MACE,CAAC;;;;;;;;AASpC,IAAa,oBAAb,MAAa,kBAAkB;CAC7B;CACA;CACA;CACA;CAEA,YAAY,MAAmC;AAC7C,MAAI,SAAS,KAAA,GAAW;AACtB,QAAK,eAAe,KAAK;AACzB,QAAK,gBAAgB,KAAK;AAC1B,QAAK,eAAe,KAAK;AACzB,QAAK,aAAa,KAAK;;;;;;;;CAS3B,aAAa,OAAgC;AAC3C,OAAK,iBAAiB,MAAM;AAC5B,O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,OAAO,KAAK,CAAC,UAAU,EAAE,OAAO;;EAI/D,MAAM,aAAa,KAAK;AACxB,MAAI,eAAe,KAAA,EACjB,MAAK,MAAM,CAAC,SAAS,eAAe,OAAO,QAAQ,WAAW,EAAE;GAC9D,MAAM,SAAS,YAAY,SAAS,WAAW;AAC/C,YAAS,QAAQ,IAAI,SAAS,OAAO;;AAIzC,SAAO;;;;;;;;AASX,SAAgB,oBAAoB,aAAiC,KAAqB;AACxF,KAAI,gBAAgB,KAAA,KAAa,gBAAgB,GAC/C,QAAOC,UAAK,KAAK,KAAK,gBAAgB;AAIxC,KAAI,YAAY,SAAS,IAAI,IAAI,YAAY,SAASA,UAAK,IAAI,CAC7D,QAAOA,UAAK,KAAK,KAAK,aAAa,gBAAgB;AAIrD,KAAI,CAAC,YAAY,SAAS,IAAI,IAAI,CAAC,YAAY,SAASA,UAAK,IAAI,CAC/D,QAAOA,UAAK,KAAK,KAAK,YAAY;AAIpC,QAAOA,UAAK,QAAQ,KAAK,YAAY"}
1
+ {"version":3,"file":"index.cjs","names":["XID","ARID","SigningPublicKey","sanitizeXidUr","UR","Envelope","XIDDocument","XIDVerifySignature","UR","Envelope","XIDDocument","XIDVerifySignature","fs","path"],"sources":["../../src/registry/group-record.ts","../../src/registry/owner-record.ts","../../src/registry/participant-record.ts","../../src/registry/registry-impl.ts"],"sourcesContent":["/**\n * Copyright © 2023-2026 Blockchain Commons, LLC\n * Copyright © 2025-2026 Parity Technologies\n *\n *\n * Group record for the registry.\n *\n * Port of registry/group_record.rs from frost-hubert-rust.\n *\n * @module\n */\n\nimport { ARID, SigningPublicKey, XID } from \"@bcts/components\";\n\n/**\n * A participant in a group.\n *\n * Port of `struct GroupParticipant` from group_record.rs lines 9-13.\n */\nexport class GroupParticipant {\n private readonly _xid: XID;\n\n constructor(xid: XID) {\n this._xid = xid;\n }\n\n xid(): XID {\n return this._xid;\n }\n\n toJSON(): string {\n return this._xid.urString();\n }\n\n static fromJSON(value: string): GroupParticipant {\n const xid = XID.fromURString(value);\n return new GroupParticipant(xid);\n }\n}\n\n/**\n * Contribution paths for DKG state files.\n *\n * Port of `struct ContributionPaths` from group_record.rs lines 21-29.\n */\nexport class ContributionPaths {\n round1Secret?: string | undefined;\n round1Package?: string | undefined;\n round2Secret?: string | undefined;\n keyPackage?: string | undefined;\n\n constructor(init?: Partial<ContributionPaths>) {\n if (init !== undefined) {\n this.round1Secret = init.round1Secret;\n this.round1Package = init.round1Package;\n this.round2Secret = init.round2Secret;\n this.keyPackage = init.keyPackage;\n }\n }\n\n /**\n * Merge missing fields from another ContributionPaths.\n *\n * Port of `ContributionPaths::merge_missing()` from group_record.rs lines 32-45.\n */\n mergeMissing(other: ContributionPaths): void {\n this.round1Secret ??= other.round1Secret;\n this.round1Package ??= other.round1Package;\n this.round2Secret ??= other.round2Secret;\n this.keyPackage ??= other.keyPackage;\n }\n\n /**\n * Check if all fields are empty.\n *\n * Port of `ContributionPaths::is_empty()` from group_record.rs lines 47-53.\n */\n isEmpty(): boolean {\n return (\n this.round1Secret === undefined &&\n this.round1Package === undefined &&\n this.round2Secret === undefined &&\n this.keyPackage === undefined\n );\n }\n\n toJSON(): Record<string, string> {\n const obj: Record<string, string> = {};\n if (this.round1Secret !== undefined) obj[\"round1_secret\"] = this.round1Secret;\n if (this.round1Package !== undefined) obj[\"round1_package\"] = this.round1Package;\n if (this.round2Secret !== undefined) obj[\"round2_secret\"] = this.round2Secret;\n if (this.keyPackage !== undefined) obj[\"key_package\"] = this.keyPackage;\n return obj;\n }\n\n static fromJSON(json: Record<string, string>): ContributionPaths {\n return new ContributionPaths({\n round1Secret: json[\"round1_secret\"],\n round1Package: json[\"round1_package\"],\n round2Secret: json[\"round2_secret\"],\n keyPackage: json[\"key_package\"],\n });\n }\n}\n\n/**\n * A pending request entry.\n */\ninterface PendingRequestEntry {\n participant: XID;\n sendToArid?: ARID | undefined;\n collectFromArid: ARID;\n}\n\n/**\n * Tracks pending communication with participants (coordinator-side).\n *\n * Port of `struct PendingRequests` from group_record.rs lines 71-75.\n */\nexport class PendingRequests {\n private readonly requests: PendingRequestEntry[] = [];\n\n /**\n * Add a pending request where we only know where to collect from.\n *\n * Port of `PendingRequests::add_collect_only()` from group_record.rs lines 90-99.\n */\n addCollectOnly(participant: XID, collectFromArid: ARID): void {\n this.requests.push({\n participant,\n sendToArid: undefined,\n collectFromArid,\n });\n }\n\n /**\n * Add a pending request where we know where to send AND where to collect.\n *\n * Port of `PendingRequests::add_send_and_collect()` from group_record.rs lines 103-115.\n */\n addSendAndCollect(participant: XID, sendToArid: ARID, collectFromArid: ARID): void {\n this.requests.push({\n participant,\n sendToArid,\n collectFromArid,\n });\n }\n\n /**\n * Add a pending request where we only know where to send.\n *\n * Port of `PendingRequests::add_send_only()` from group_record.rs lines 118-127.\n */\n addSendOnly(participant: XID, sendToArid: ARID): void {\n this.requests.push({\n participant,\n sendToArid,\n collectFromArid: sendToArid, // Placeholder\n });\n }\n\n /**\n * Check if there are no pending requests.\n *\n * Port of `PendingRequests::is_empty()` from group_record.rs line 129.\n */\n isEmpty(): boolean {\n return this.requests.length === 0;\n }\n\n /**\n * Get the number of pending requests.\n *\n * Port of `PendingRequests::len()` from group_record.rs line 165.\n */\n len(): number {\n return this.requests.length;\n }\n\n /**\n * Iterate over (participant, collectFromArid) pairs.\n *\n * Port of `PendingRequests::iter_collect()` from group_record.rs lines 132-138.\n */\n *iterCollect(): Generator<[XID, ARID]> {\n for (const r of this.requests) {\n yield [r.participant, r.collectFromArid];\n }\n }\n\n /**\n * Iterate over (participant, sendToArid) pairs.\n *\n * Port of `PendingRequests::iter_send()` from group_record.rs lines 141-150.\n */\n *iterSend(): Generator<[XID, ARID]> {\n for (const r of this.requests) {\n if (r.sendToArid === undefined) {\n throw new Error(\"send_to_arid not set for this request\");\n }\n yield [r.participant, r.sendToArid];\n }\n }\n\n /**\n * Iterate over full (participant, sendToArid, collectFromArid) tuples.\n *\n * Port of `PendingRequests::iter_full()` from group_record.rs lines 153-163.\n */\n *iterFull(): Generator<[XID, ARID | undefined, ARID]> {\n for (const r of this.requests) {\n yield [r.participant, r.sendToArid, r.collectFromArid];\n }\n }\n\n toJSON(): unknown[] {\n return this.requests.map((r) => ({\n participant: r.participant.urString(),\n send_to_arid: r.sendToArid?.urString(),\n collect_from_arid: r.collectFromArid.urString(),\n }));\n }\n\n static fromJSON(json: unknown[]): PendingRequests {\n const pr = new PendingRequests();\n for (const entry of json as Record<string, string>[]) {\n const participant = XID.fromURString(entry[\"participant\"]);\n const sendToArid =\n entry[\"send_to_arid\"] !== undefined && entry[\"send_to_arid\"] !== \"\"\n ? ARID.fromURString(entry[\"send_to_arid\"])\n : undefined;\n const collectFromArid = ARID.fromURString(entry[\"collect_from_arid\"]);\n pr.requests.push({ participant, sendToArid, collectFromArid });\n }\n return pr;\n }\n}\n\n/**\n * Record of a DKG group.\n *\n * Port of `struct GroupRecord` from group_record.rs lines 168-186.\n */\nexport class GroupRecord {\n private readonly _charter: string;\n private readonly _minSigners: number;\n private readonly _coordinator: GroupParticipant;\n private readonly _participants: GroupParticipant[];\n private _contributions: ContributionPaths;\n private _listeningAtArid?: ARID | undefined;\n private _pendingRequests: PendingRequests;\n private _verifyingKey?: SigningPublicKey | undefined;\n\n constructor(\n charter: string,\n minSigners: number,\n coordinator: GroupParticipant,\n participants: GroupParticipant[],\n ) {\n this._charter = charter;\n this._minSigners = minSigners;\n this._coordinator = coordinator;\n this._participants = participants;\n this._contributions = new ContributionPaths();\n this._listeningAtArid = undefined;\n this._pendingRequests = new PendingRequests();\n this._verifyingKey = undefined;\n }\n\n coordinator(): GroupParticipant {\n return this._coordinator;\n }\n\n participants(): GroupParticipant[] {\n return this._participants;\n }\n\n minSigners(): number {\n return this._minSigners;\n }\n\n charter(): string {\n return this._charter;\n }\n\n contributions(): ContributionPaths {\n return this._contributions;\n }\n\n setContributions(contributions: ContributionPaths): void {\n this._contributions = contributions;\n }\n\n mergeContributions(other: ContributionPaths): void {\n this._contributions.mergeMissing(other);\n }\n\n listeningAtArid(): ARID | undefined {\n return this._listeningAtArid;\n }\n\n setListeningAtArid(arid: ARID): void {\n this._listeningAtArid = arid;\n }\n\n clearListeningAtArid(): void {\n this._listeningAtArid = undefined;\n }\n\n pendingRequests(): PendingRequests {\n return this._pendingRequests;\n }\n\n setPendingRequests(requests: PendingRequests): void {\n this._pendingRequests = requests;\n }\n\n clearPendingRequests(): void {\n this._pendingRequests = new PendingRequests();\n }\n\n /**\n * Check if the config matches another group record.\n *\n * Port of `GroupRecord::config_matches()` from group_record.rs lines 247-253.\n */\n configMatches(other: GroupRecord): boolean {\n return (\n this._charter === other._charter &&\n this._minSigners === other._minSigners &&\n this._coordinator.xid().toString() === other._coordinator.xid().toString() &&\n this._participants.length === other._participants.length &&\n this._participants.every(\n (p, i) => p.xid().toString() === other._participants[i].xid().toString(),\n )\n );\n }\n\n verifyingKey(): SigningPublicKey | undefined {\n return this._verifyingKey;\n }\n\n setVerifyingKey(key: SigningPublicKey): void {\n this._verifyingKey = key;\n }\n\n toJSON(): Record<string, unknown> {\n const obj: Record<string, unknown> = {\n charter: this._charter,\n min_signers: this._minSigners,\n coordinator: this._coordinator.toJSON(),\n participants: this._participants.map((p) => p.toJSON()),\n };\n if (!this._contributions.isEmpty()) {\n obj[\"contributions\"] = this._contributions.toJSON();\n }\n if (this._listeningAtArid !== undefined) {\n obj[\"listening_at_arid\"] = this._listeningAtArid.urString();\n }\n if (!this._pendingRequests.isEmpty()) {\n obj[\"pending_requests\"] = this._pendingRequests.toJSON();\n }\n if (this._verifyingKey !== undefined) {\n obj[\"verifying_key\"] = this._verifyingKey.urString();\n }\n return obj;\n }\n\n static fromJSON(json: Record<string, unknown>): GroupRecord {\n const charter = json[\"charter\"] as string;\n const minSigners = json[\"min_signers\"] as number;\n const coordinator = GroupParticipant.fromJSON(json[\"coordinator\"] as string);\n const participants = (json[\"participants\"] as string[]).map((p) =>\n GroupParticipant.fromJSON(p),\n );\n\n const record = new GroupRecord(charter, minSigners, coordinator, participants);\n\n if (json[\"contributions\"] !== undefined) {\n record._contributions = ContributionPaths.fromJSON(\n json[\"contributions\"] as Record<string, string>,\n );\n }\n if (json[\"listening_at_arid\"] !== undefined) {\n record._listeningAtArid = ARID.fromURString(json[\"listening_at_arid\"] as string);\n }\n if (json[\"pending_requests\"] !== undefined) {\n record._pendingRequests = PendingRequests.fromJSON(json[\"pending_requests\"] as unknown[]);\n }\n if (json[\"verifying_key\"] !== undefined) {\n record._verifyingKey = SigningPublicKey.fromURString(json[\"verifying_key\"] as string);\n }\n\n return record;\n }\n}\n","/**\n * Copyright © 2023-2026 Blockchain Commons, LLC\n * Copyright © 2025-2026 Parity Technologies\n *\n *\n * Owner record for the registry.\n *\n * Port of registry/owner_record.rs from frost-hubert-rust.\n *\n * @module\n */\n\nimport { type XID } from \"@bcts/components\";\nimport { Envelope } from \"@bcts/envelope\";\nimport { UR } from \"@bcts/uniform-resources\";\nimport { XIDDocument, XIDVerifySignature } from \"@bcts/xid\";\n\n/**\n * Record of the registry owner (coordinator).\n *\n * Port of `struct OwnerRecord` from owner_record.rs lines 13-17.\n */\nexport class OwnerRecord {\n private readonly _xidDocumentUr: string;\n private readonly _xidDocument: XIDDocument;\n private readonly _petName: string | undefined;\n\n private constructor(\n xidDocumentUr: string,\n xidDocument: XIDDocument,\n petName: string | undefined,\n ) {\n this._xidDocumentUr = xidDocumentUr;\n this._xidDocument = xidDocument;\n this._petName = petName;\n }\n\n /**\n * Create an owner record from a signed XID UR string.\n *\n * Port of `OwnerRecord::from_signed_xid_ur()` from owner_record.rs lines 20-32.\n */\n static fromSignedXidUr(xidDocumentUr: string, petName?: string): OwnerRecord {\n const [raw, document] = parseRelaxedXidDocument(xidDocumentUr);\n\n if (document.inceptionPrivateKeys() === undefined) {\n throw new Error(\"Owner XID document must include private keys\");\n }\n\n return new OwnerRecord(raw, document, petName);\n }\n\n /**\n * Get the XID of the owner.\n *\n * Port of `OwnerRecord::xid()` from owner_record.rs line 34.\n */\n xid(): XID {\n return this._xidDocument.xid();\n }\n\n /**\n * Get the XID document of the owner.\n *\n * Port of `OwnerRecord::xid_document()` from owner_record.rs line 36.\n */\n xidDocument(): XIDDocument {\n return this._xidDocument;\n }\n\n /**\n * Get the UR string of the XID document.\n *\n * Port of `OwnerRecord::xid_document_ur()` from owner_record.rs line 38.\n */\n xidDocumentUr(): string {\n return this._xidDocumentUr;\n }\n\n /**\n * Get the pet name of the owner.\n *\n * Port of `OwnerRecord::pet_name()` from owner_record.rs line 40.\n */\n petName(): string | undefined {\n return this._petName;\n }\n\n /**\n * Serialize to JSON object.\n */\n toJSON(): Record<string, unknown> {\n const obj: Record<string, unknown> = {\n xid_document: this._xidDocumentUr,\n };\n if (this._petName !== undefined) {\n obj[\"pet_name\"] = this._petName;\n }\n return obj;\n }\n\n /**\n * Deserialize from JSON object.\n *\n * Mirrors Rust's `#[serde(deny_unknown_fields)]` derive on\n * `OwnerRecord` (`owner_record.rs:13-17`) — any field not in\n * `{xid_document, pet_name}` causes Rust's `serde_json::from_str`\n * to error with `unknown field`, and we mirror that here so a\n * registry file produced by a future Rust version with extra\n * fields is rejected explicitly rather than silently lossy.\n */\n static fromJSON(json: Record<string, unknown>): OwnerRecord {\n for (const key of Object.keys(json)) {\n if (key !== \"xid_document\" && key !== \"pet_name\") {\n throw new Error(`unknown field \\`${key}\\`, expected \\`xid_document\\` or \\`pet_name\\``);\n }\n }\n const xidDocumentUr = json[\"xid_document\"] as string;\n const petName = json[\"pet_name\"] as string | undefined;\n return OwnerRecord.fromSignedXidUr(xidDocumentUr, petName);\n }\n}\n\n/**\n * Parse a XID document with relaxed validation (no signature verification).\n *\n * Port of `parse_relaxed_xid_document()` from owner_record.rs lines 144-165.\n */\nfunction parseRelaxedXidDocument(xidDocumentUr: string): [string, XIDDocument] {\n const sanitized = sanitizeXidUr(xidDocumentUr);\n const ur = UR.fromURString(sanitized);\n\n if (ur.urTypeStr() !== \"xid\" && ur.urTypeStr() !== \"envelope\") {\n throw new Error(`Expected a ur:xid document, found ur:${ur.urTypeStr()}`);\n }\n\n const envelopeCbor = ur.cbor();\n let envelope: Envelope;\n try {\n envelope = Envelope.fromTaggedCbor(envelopeCbor);\n } catch {\n envelope = Envelope.fromUntaggedCbor(envelopeCbor);\n }\n\n const document = XIDDocument.fromEnvelope(envelope, undefined, XIDVerifySignature.None);\n\n return [sanitized, document];\n}\n\n/**\n * Sanitize XID UR input.\n *\n * Port of `sanitize_xid_ur()` from owner_record.rs lines 167-174.\n */\nfunction sanitizeXidUr(input: string): string {\n const trimmed = input.trim();\n if (trimmed.length === 0) {\n throw new Error(\"XID document is required\");\n }\n return trimmed;\n}\n","/**\n * Copyright © 2023-2026 Blockchain Commons, LLC\n * Copyright © 2025-2026 Parity Technologies\n *\n *\n * Participant record for the registry.\n *\n * Port of registry/participant_record.rs from frost-hubert-rust.\n *\n * @module\n */\n\nimport { type PublicKeys, type XID } from \"@bcts/components\";\nimport { Envelope } from \"@bcts/envelope\";\nimport { UR } from \"@bcts/uniform-resources\";\nimport { XIDDocument, XIDVerifySignature } from \"@bcts/xid\";\n\n/**\n * Record of a participant in the registry.\n *\n * Port of `struct ParticipantRecord` from participant_record.rs lines 12-17.\n */\nexport class ParticipantRecord {\n private readonly _xidDocumentUr: string;\n private readonly _xidDocument: XIDDocument;\n private readonly _publicKeys: PublicKeys;\n private readonly _petName: string | undefined;\n\n private constructor(\n xidDocumentUr: string,\n xidDocument: XIDDocument,\n publicKeys: PublicKeys,\n petName: string | undefined,\n ) {\n this._xidDocumentUr = xidDocumentUr;\n this._xidDocument = xidDocument;\n this._publicKeys = publicKeys;\n this._petName = petName;\n }\n\n /**\n * Create a participant record from a signed XID UR string.\n *\n * Port of `ParticipantRecord::from_signed_xid_ur()` from participant_record.rs lines 20-26.\n */\n static fromSignedXidUr(xidDocumentUr: string, petName?: string): ParticipantRecord {\n const [raw, document] = parseSignedXidDocument(xidDocumentUr);\n return ParticipantRecord.buildFromParts(document, raw, petName);\n }\n\n /**\n * Get the pet name of the participant.\n *\n * Port of `ParticipantRecord::pet_name()` from participant_record.rs line 28.\n */\n petName(): string | undefined {\n return this._petName;\n }\n\n /**\n * Get the public keys of the participant.\n *\n * Port of `ParticipantRecord::public_keys()` from participant_record.rs line 29.\n */\n publicKeys(): PublicKeys {\n return this._publicKeys;\n }\n\n /**\n * Get the XID of the participant.\n *\n * Port of `ParticipantRecord::xid()` from participant_record.rs line 30.\n */\n xid(): XID {\n return this._xidDocument.xid();\n }\n\n /**\n * Get the XID document of the participant.\n *\n * Port of `ParticipantRecord::xid_document()` from participant_record.rs line 31.\n */\n xidDocument(): XIDDocument {\n return this._xidDocument;\n }\n\n /**\n * Get the UR string of the XID document.\n *\n * Port of `ParticipantRecord::xid_document_ur()` from participant_record.rs line 32.\n */\n xidDocumentUr(): string {\n return this._xidDocumentUr;\n }\n\n /**\n * Build from constituent parts.\n *\n * Port of `ParticipantRecord::build_from_parts()` from participant_record.rs lines 34-49.\n */\n private static buildFromParts(\n document: XIDDocument,\n xidDocumentUr: string,\n petName: string | undefined,\n ): ParticipantRecord {\n const inceptionKey = document.inceptionKey();\n if (inceptionKey === undefined) {\n throw new Error(\"XID document missing inception key\");\n }\n\n const publicKeys = inceptionKey.publicKeys();\n\n return new ParticipantRecord(xidDocumentUr, document, publicKeys, petName);\n }\n\n /**\n * Recreate from serialized data.\n *\n * Port of `ParticipantRecord::recreate_from_serialized()` from participant_record.rs lines 51-57.\n */\n private static recreateFromSerialized(\n xidDocumentUr: string,\n petName: string | undefined,\n ): ParticipantRecord {\n const [raw, document] = parseSignedXidDocument(xidDocumentUr);\n return ParticipantRecord.buildFromParts(document, raw, petName);\n }\n\n /**\n * Serialize to JSON object.\n */\n toJSON(): Record<string, unknown> {\n const obj: Record<string, unknown> = {\n xid_document: this._xidDocumentUr,\n };\n if (this._petName !== undefined) {\n obj[\"pet_name\"] = this._petName;\n }\n return obj;\n }\n\n /**\n * Deserialize from JSON object.\n *\n * Mirrors Rust's `#[serde(deny_unknown_fields)]` derive on\n * `ParticipantRecord` (`participant_record.rs:12-17`) — Rust's\n * `serde_json::from_str` errors with `unknown field` for any\n * field outside `{xid_document, pet_name}`. We mirror that\n * behaviour so a registry file produced by a future Rust\n * version with extra fields is rejected explicitly rather than\n * silently lossy.\n */\n static fromJSON(json: Record<string, unknown>): ParticipantRecord {\n for (const key of Object.keys(json)) {\n if (key !== \"xid_document\" && key !== \"pet_name\") {\n throw new Error(`unknown field \\`${key}\\`, expected \\`xid_document\\` or \\`pet_name\\``);\n }\n }\n const xidDocumentUr = json[\"xid_document\"] as string;\n const petName = json[\"pet_name\"] as string | undefined;\n return ParticipantRecord.recreateFromSerialized(xidDocumentUr, petName);\n }\n}\n\n/**\n * Parse a signed XID document from a UR string.\n *\n * Port of `parse_signed_xid_document()` from participant_record.rs lines 170-194.\n */\nfunction parseSignedXidDocument(xidDocumentUr: string): [string, XIDDocument] {\n const sanitized = sanitizeXidUr(xidDocumentUr);\n const ur = UR.fromURString(sanitized);\n\n if (ur.urTypeStr() !== \"xid\" && ur.urTypeStr() !== \"envelope\") {\n throw new Error(`Expected a ur:xid document, found ur:${ur.urTypeStr()}`);\n }\n\n const envelopeCbor = ur.cbor();\n let envelope: Envelope;\n try {\n envelope = Envelope.fromTaggedCbor(envelopeCbor);\n } catch {\n try {\n envelope = Envelope.fromUntaggedCbor(envelopeCbor);\n } catch (e) {\n throw new Error(\n `Unable to decode XID document envelope: ${(e as Error).message ?? String(e)}`,\n {\n cause: e,\n },\n );\n }\n }\n\n // Mirror Rust `participant_record.rs:198-203`'s `.context(...)` wrap:\n // any failure from `XIDDocument::from_envelope(..., XIDVerifySignature::Inception)`\n // is surfaced as \"XID document must be signed by its inception key: <cause>\".\n let document: XIDDocument;\n try {\n document = XIDDocument.fromEnvelope(envelope, undefined, XIDVerifySignature.Inception);\n } catch (e) {\n throw new Error(\n `XID document must be signed by its inception key: ${(e as Error).message ?? String(e)}`,\n { cause: e },\n );\n }\n\n return [sanitized, document];\n}\n\n/**\n * Sanitize XID UR input.\n *\n * Port of `sanitize_xid_ur()` from participant_record.rs lines 196-203.\n */\nfunction sanitizeXidUr(input: string): string {\n const trimmed = input.trim();\n if (trimmed.length === 0) {\n throw new Error(\"XID document is required\");\n }\n return trimmed;\n}\n","/**\n * Copyright © 2023-2026 Blockchain Commons, LLC\n * Copyright © 2025-2026 Parity Technologies\n *\n *\n * Registry implementation for managing participants and groups.\n *\n * Port of registry/registry_impl.rs from frost-hubert-rust.\n *\n * @module\n */\n\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\n\nimport { type ARID, type PublicKeys, type XID } from \"@bcts/components\";\n\nimport { GroupRecord } from \"./group-record.js\";\nimport { OwnerRecord } from \"./owner-record.js\";\nimport { ParticipantRecord } from \"./participant-record.js\";\n\n/**\n * Outcome of adding a participant to the registry.\n *\n * Port of `enum AddOutcome` from registry_impl.rs.\n */\nexport enum AddOutcome {\n /** Participant was already present in the registry */\n AlreadyPresent = \"already_present\",\n /** Participant was successfully inserted */\n Inserted = \"inserted\",\n}\n\n/**\n * Outcome of setting the owner in the registry.\n *\n * Port of `enum OwnerOutcome` from registry_impl.rs.\n */\nexport enum OwnerOutcome {\n /** Owner was already present in the registry */\n AlreadyPresent = \"already_present\",\n /** Owner was successfully inserted */\n Inserted = \"inserted\",\n}\n\n/**\n * Outcome of recording a group in the registry.\n *\n * Port of `enum GroupOutcome` from registry_impl.rs.\n */\nexport enum GroupOutcome {\n /** Group was successfully inserted as new */\n Inserted = \"inserted\",\n /** Group already existed and was updated (contributions merged) */\n Updated = \"updated\",\n}\n\n/**\n * Registry for managing participants and groups.\n *\n * Port of `struct Registry` from registry_impl.rs lines 22-26.\n */\nexport class Registry {\n private _owner?: OwnerRecord | undefined;\n private readonly _participants: Map<string, ParticipantRecord>; // Map by XID UR string\n private readonly _groups: Map<string, GroupRecord>; // Map by ARID hex\n\n constructor() {\n this._owner = undefined;\n this._participants = new Map();\n this._groups = new Map();\n }\n\n /**\n * Get the owner record.\n */\n owner(): OwnerRecord | undefined {\n return this._owner;\n }\n\n /**\n * Set the owner record.\n *\n * Returns the outcome indicating whether the owner was already present or newly inserted.\n *\n * Port of `Registry::set_owner()` from registry_impl.rs.\n */\n setOwner(owner: OwnerRecord): OwnerOutcome {\n // Check for pet name conflicts with participants\n const petName = owner.petName();\n if (petName !== undefined) {\n const conflicting = this.participantByPetName(petName);\n if (conflicting?.[1].petName() === petName) {\n throw new Error(`Pet name '${petName}' already used by a participant`);\n }\n }\n\n if (this._owner === undefined) {\n this._owner = owner;\n return OwnerOutcome.Inserted;\n }\n\n const existing = this._owner;\n const existingXidUr = existing.xid().urString();\n const ownerXidUr = owner.xid().urString();\n\n if (\n existingXidUr === ownerXidUr &&\n existing.xidDocumentUr() === owner.xidDocumentUr() &&\n existing.petName() === owner.petName()\n ) {\n return OwnerOutcome.AlreadyPresent;\n }\n\n if (existingXidUr === ownerXidUr) {\n if (existing.xidDocumentUr() !== owner.xidDocumentUr()) {\n throw new Error(\"Owner already exists with different keys\");\n }\n this._owner = owner;\n return OwnerOutcome.Inserted;\n }\n\n throw new Error(`Owner already recorded for ${existing.xid().toString()}`);\n }\n\n /**\n * Get all participants.\n */\n participants(): Map<string, ParticipantRecord> {\n return this._participants;\n }\n\n /**\n * Get a participant by XID.\n */\n participant(xid: XID): ParticipantRecord | undefined {\n return this._participants.get(xid.urString());\n }\n\n /**\n * Add a participant.\n *\n * Mirrors Rust `Registry::add_participant`\n * (`registry_impl.rs:83-124`):\n *\n * 1. If `record.pet_name()` is already used by some other XID,\n * bail with `\"Pet name '{name}' already used by another\n * participant\"`.\n * 2. If `record.pet_name()` matches an existing record under the\n * *same* XID and the public keys also match, return\n * `AlreadyPresent`.\n * 3. If the pet name matches the same XID but public keys don't,\n * bail with `\"Participant already exists with a different pet\n * name\"`.\n * 4. Otherwise look up by XID. If present and public-keys + pet-name\n * both match, return `AlreadyPresent`; if XID is present but\n * anything differs, bail. If XID is new, insert and return\n * `Inserted`.\n *\n * The earlier port short-circuited on `participants.has(xidUr)` and\n * always returned `AlreadyPresent` — silently allowing re-adds with\n * a different pet name or different public keys, which Rust\n * correctly forbids.\n */\n addParticipant(xid: XID, record: ParticipantRecord): AddOutcome {\n const xidUr = xid.urString();\n const petName = record.petName();\n\n // Steps 1–3: pet-name conflict resolution.\n if (petName !== undefined) {\n for (const [existingXidUr, existingRecord] of this._participants) {\n if (existingRecord.petName() === petName) {\n if (existingXidUr !== xidUr) {\n throw new Error(`Pet name '${petName}' already used by another participant`);\n }\n if (publicKeysEqual(existingRecord.publicKeys(), record.publicKeys())) {\n return AddOutcome.AlreadyPresent;\n }\n throw new Error(\"Participant already exists with a different pet name\");\n }\n }\n }\n\n // Step 4: XID lookup.\n const existing = this._participants.get(xidUr);\n if (existing !== undefined) {\n if (\n publicKeysEqual(existing.publicKeys(), record.publicKeys()) &&\n existing.petName() === record.petName()\n ) {\n return AddOutcome.AlreadyPresent;\n }\n throw new Error(\"Participant already exists with a different pet name\");\n }\n\n this._participants.set(xidUr, record);\n return AddOutcome.Inserted;\n }\n\n /**\n * Check if a pet name is already used.\n */\n petNameExists(petName: string): boolean {\n for (const record of this._participants.values()) {\n if (record.petName() === petName) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Find a participant by pet name.\n *\n * Port of `Registry::participant_by_pet_name()` from registry_impl.rs.\n */\n participantByPetName(petName: string): [XID, ParticipantRecord] | undefined {\n for (const record of this._participants.values()) {\n if (record.petName() === petName) {\n return [record.xid(), record];\n }\n }\n return undefined;\n }\n\n /**\n * Get all groups.\n */\n groups(): Map<string, GroupRecord> {\n return this._groups;\n }\n\n /**\n * Get a group by ARID.\n */\n group(arid: ARID): GroupRecord | undefined {\n return this._groups.get(arid.hex());\n }\n\n /**\n * Get a mutable reference to a group by ARID.\n */\n groupMut(arid: ARID): GroupRecord | undefined {\n return this._groups.get(arid.hex());\n }\n\n /**\n * Record a group in the registry.\n *\n * If the group already exists:\n * - Validates that the config matches\n * - Merges contributions from the new record\n * - Updates verifying key if not already set\n *\n * Port of `Registry::record_group()` from registry_impl.rs.\n */\n recordGroup(groupId: ARID, record: GroupRecord): GroupOutcome {\n const key = groupId.hex();\n const existing = this._groups.get(key);\n\n if (existing !== undefined) {\n // Validate config matches\n if (!existing.configMatches(record)) {\n throw new Error(`Group ${groupId.hex()} already exists with a different configuration`);\n }\n\n // Merge contributions\n existing.mergeContributions(record.contributions());\n\n // Update verifying key if not already set\n const existingKey = existing.verifyingKey();\n const recordKey = record.verifyingKey();\n if (existingKey === undefined && recordKey !== undefined) {\n existing.setVerifyingKey(recordKey);\n } else if (\n existingKey !== undefined &&\n recordKey !== undefined &&\n existingKey.urString() !== recordKey.urString()\n ) {\n throw new Error(`Group ${groupId.hex()} already exists with a different verifying key`);\n }\n\n return GroupOutcome.Updated;\n }\n\n this._groups.set(key, record);\n return GroupOutcome.Inserted;\n }\n\n /**\n * Add a group (simple variant without merge logic).\n *\n * @deprecated Use recordGroup() for proper merge behavior.\n */\n addGroup(arid: ARID, record: GroupRecord): void {\n this._groups.set(arid.hex(), record);\n }\n\n /**\n * Load a registry from a file.\n */\n static load(filePath: string): Registry {\n if (!fs.existsSync(filePath)) {\n return new Registry();\n }\n\n const content = fs.readFileSync(filePath, \"utf-8\");\n const json = JSON.parse(content) as Record<string, unknown>;\n return Registry.fromJSON(json);\n }\n\n /**\n * Save the registry to a file.\n */\n save(filePath: string): void {\n const dir = path.dirname(filePath);\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir, { recursive: true });\n }\n\n const json = this.toJSON();\n fs.writeFileSync(filePath, JSON.stringify(json, null, 2));\n }\n\n /**\n * Serialize to JSON object.\n *\n * Mirrors Rust `Registry`'s field declaration order\n * (`registry_impl.rs:8-14` — `owner, participants, groups`). JSON\n * object member order is not semantically significant, but\n * `serde_json::to_string_pretty` emits keys in declaration order,\n * so for byte-equal `registry.json` (used by the integration tests\n * as a string assertion) the TS port must match Rust's order.\n * Empty `owner` is omitted via `Option::None` skip in Rust; we\n * reproduce that by only setting the key when the owner exists.\n */\n toJSON(): Record<string, unknown> {\n const obj: Record<string, unknown> = {};\n\n if (this._owner !== undefined) {\n obj[\"owner\"] = this._owner.toJSON();\n }\n\n const participants: Record<string, unknown> = {};\n for (const [xidUr, record] of this._participants) {\n participants[xidUr] = record.toJSON();\n }\n obj[\"participants\"] = participants;\n\n const groups: Record<string, unknown> = {};\n for (const [aridHex, record] of this._groups) {\n groups[aridHex] = record.toJSON();\n }\n obj[\"groups\"] = groups;\n\n return obj;\n }\n\n /**\n * Deserialize from JSON object.\n */\n static fromJSON(json: Record<string, unknown>): Registry {\n const registry = new Registry();\n\n if (json[\"owner\"] !== undefined) {\n registry._owner = OwnerRecord.fromJSON(json[\"owner\"] as Record<string, unknown>);\n }\n\n const participantsJson = json[\"participants\"] as\n | Record<string, Record<string, unknown>>\n | undefined;\n if (participantsJson !== undefined) {\n for (const [, recordJson] of Object.entries(participantsJson)) {\n const record = ParticipantRecord.fromJSON(recordJson);\n registry._participants.set(record.xid().urString(), record);\n }\n }\n\n const groupsJson = json[\"groups\"] as Record<string, Record<string, unknown>> | undefined;\n if (groupsJson !== undefined) {\n for (const [aridHex, recordJson] of Object.entries(groupsJson)) {\n const record = GroupRecord.fromJSON(recordJson);\n registry._groups.set(aridHex, record);\n }\n }\n\n return registry;\n }\n}\n\n/**\n * Resolve the registry file path from a given argument.\n *\n * Port of `resolve_registry_path()` from registry/mod.rs lines 49-78.\n */\nexport function resolveRegistryPath(registryArg: string | undefined, cwd: string): string {\n if (registryArg === undefined || registryArg === \"\") {\n return path.join(cwd, \"registry.json\");\n }\n\n // If it ends with / or is a directory, append registry.json\n if (registryArg.endsWith(\"/\") || registryArg.endsWith(path.sep)) {\n return path.join(cwd, registryArg, \"registry.json\");\n }\n\n // If it's just a filename, put it in cwd\n if (!registryArg.includes(\"/\") && !registryArg.includes(path.sep)) {\n return path.join(cwd, registryArg);\n }\n\n // Otherwise, treat as relative path\n return path.resolve(cwd, registryArg);\n}\n\n/**\n * Structural equality on `PublicKeys`, mirroring Rust's\n * `PartialEq::eq` derive (per-component comparison of the signing\n * and encapsulation public keys).\n *\n * @internal\n */\nfunction publicKeysEqual(a: PublicKeys, b: PublicKeys): boolean {\n return a.equals(b);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,IAAa,mBAAb,MAAa,iBAAiB;CAC5B;CAEA,YAAY,KAAU;AACpB,OAAK,OAAO;;CAGd,MAAW;AACT,SAAO,KAAK;;CAGd,SAAiB;AACf,SAAO,KAAK,KAAK,UAAU;;CAG7B,OAAO,SAAS,OAAiC;AAE/C,SAAO,IAAI,iBADCA,iBAAAA,IAAI,aAAa,MACE,CAAC;;;;;;;;AASpC,IAAa,oBAAb,MAAa,kBAAkB;CAC7B;CACA;CACA;CACA;CAEA,YAAY,MAAmC;AAC7C,MAAI,SAAS,KAAA,GAAW;AACtB,QAAK,eAAe,KAAK;AACzB,QAAK,gBAAgB,KAAK;AAC1B,QAAK,eAAe,KAAK;AACzB,QAAK,aAAa,KAAK;;;;;;;;CAS3B,aAAa,OAAgC;AAC3C,OAAK,iBAAiB,MAAM;AAC5B,OAAK,kBAAkB,MAAM;AAC7B,OAAK,iBAAiB,MAAM;AAC5B,OAAK,eAAe,MAAM;;;;;;;CAQ5B,UAAmB;AACjB,SACE,KAAK,iBAAiB,KAAA,KACtB,KAAK,kBAAkB,KAAA,KACvB,KAAK,iBAAiB,KAAA,KACtB,KAAK,eAAe,KAAA;;CAIxB,SAAiC;EAC/B,MAAM,MAA8B,EAAE;AACtC,MAAI,KAAK,iBAAiB,KAAA,EAAW,KAAI,mBAAmB,KAAK;AACjE,MAAI,KAAK,kBAAkB,KAAA,EAAW,KAAI,oBAAoB,KAAK;AACnE,MAAI,KAAK,iBAAiB,KAAA,EAAW,KAAI,mBAAmB,KAAK;AACjE,MAAI,KAAK,eAAe,KAAA,EAAW,KAAI,iBAAiB,KAAK;AAC7D,SAAO;;CAGT,OAAO,SAAS,MAAiD;AAC/D,SAAO,IAAI,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,QACnC,QAAO,WAAW,OAAO,QAAQ;AAEnC,MAAI,YAAY;AAEhB,SAAO;;;;;CAMT,OAAO,SAAS,MAAyC;EACvD,MAAM,WAAW,IAAI,UAAU;AAE/B,MAAI,KAAK,aAAa,KAAA,EACpB,UAAS,SAAS,YAAY,SAAS,KAAK,SAAoC;EAGlF,MAAM,mBAAmB,KAAK;AAG9B,MAAI,qBAAqB,KAAA,EACvB,MAAK,MAAM,GAAG,eAAe,OAAO,QAAQ,iBAAiB,EAAE;GAC7D,MAAM,SAAS,kBAAkB,SAAS,WAAW;AACrD,YAAS,cAAc,IAAI,OAAO,KAAK,CAAC,UAAU,EAAE,OAAO;;EAI/D,MAAM,aAAa,KAAK;AACxB,MAAI,eAAe,KAAA,EACjB,MAAK,MAAM,CAAC,SAAS,eAAe,OAAO,QAAQ,WAAW,EAAE;GAC9D,MAAM,SAAS,YAAY,SAAS,WAAW;AAC/C,YAAS,QAAQ,IAAI,SAAS,OAAO;;AAIzC,SAAO;;;;;;;;AASX,SAAgB,oBAAoB,aAAiC,KAAqB;AACxF,KAAI,gBAAgB,KAAA,KAAa,gBAAgB,GAC/C,QAAOC,UAAK,KAAK,KAAK,gBAAgB;AAIxC,KAAI,YAAY,SAAS,IAAI,IAAI,YAAY,SAASA,UAAK,IAAI,CAC7D,QAAOA,UAAK,KAAK,KAAK,aAAa,gBAAgB;AAIrD,KAAI,CAAC,YAAY,SAAS,IAAI,IAAI,CAAC,YAAY,SAASA,UAAK,IAAI,CAC/D,QAAOA,UAAK,KAAK,KAAK,YAAY;AAIpC,QAAOA,UAAK,QAAQ,KAAK,YAAY;;;;;;;;;AAUvC,SAAS,gBAAgB,GAAe,GAAwB;AAC9D,QAAO,EAAE,OAAO,EAAE"}
@@ -1,2 +1,2 @@
1
- import { a as resolveRegistryPath, c as ContributionPaths, d as PendingRequests, i as Registry, l as GroupParticipant, n as GroupOutcome, o as ParticipantRecord, r as OwnerOutcome, s as OwnerRecord, t as AddOutcome, u as GroupRecord } from "../index-BMbPgH0W.cjs";
1
+ import { a as resolveRegistryPath, c as ContributionPaths, d as PendingRequests, i as Registry, l as GroupParticipant, n as GroupOutcome, o as ParticipantRecord, r as OwnerOutcome, s as OwnerRecord, t as AddOutcome, u as GroupRecord } from "../index-C8QeHNwa.cjs";
2
2
  export { AddOutcome, ContributionPaths, GroupOutcome, GroupParticipant, GroupRecord, OwnerOutcome, OwnerRecord, ParticipantRecord, PendingRequests, Registry, resolveRegistryPath };
@@ -1,2 +1,2 @@
1
- import { a as resolveRegistryPath, c as ContributionPaths, d as PendingRequests, i as Registry, l as GroupParticipant, n as GroupOutcome, o as ParticipantRecord, r as OwnerOutcome, s as OwnerRecord, t as AddOutcome, u as GroupRecord } from "../index-DoV5HFvV.mjs";
1
+ import { a as resolveRegistryPath, c as ContributionPaths, d as PendingRequests, i as Registry, l as GroupParticipant, n as GroupOutcome, o as ParticipantRecord, r as OwnerOutcome, s as OwnerRecord, t as AddOutcome, u as GroupRecord } from "../index-DVbWyOs7.mjs";
2
2
  export { AddOutcome, ContributionPaths, GroupOutcome, GroupParticipant, GroupRecord, OwnerOutcome, OwnerRecord, ParticipantRecord, PendingRequests, Registry, resolveRegistryPath };
@@ -371,8 +371,16 @@ var OwnerRecord = class OwnerRecord {
371
371
  }
372
372
  /**
373
373
  * Deserialize from JSON object.
374
+ *
375
+ * Mirrors Rust's `#[serde(deny_unknown_fields)]` derive on
376
+ * `OwnerRecord` (`owner_record.rs:13-17`) — any field not in
377
+ * `{xid_document, pet_name}` causes Rust's `serde_json::from_str`
378
+ * to error with `unknown field`, and we mirror that here so a
379
+ * registry file produced by a future Rust version with extra
380
+ * fields is rejected explicitly rather than silently lossy.
374
381
  */
375
382
  static fromJSON(json) {
383
+ for (const key of Object.keys(json)) if (key !== "xid_document" && key !== "pet_name") throw new Error(`unknown field \`${key}\`, expected \`xid_document\` or \`pet_name\``);
376
384
  const xidDocumentUr = json["xid_document"];
377
385
  const petName = json["pet_name"];
378
386
  return OwnerRecord.fromSignedXidUr(xidDocumentUr, petName);
@@ -502,8 +510,17 @@ var ParticipantRecord = class ParticipantRecord {
502
510
  }
503
511
  /**
504
512
  * Deserialize from JSON object.
513
+ *
514
+ * Mirrors Rust's `#[serde(deny_unknown_fields)]` derive on
515
+ * `ParticipantRecord` (`participant_record.rs:12-17`) — Rust's
516
+ * `serde_json::from_str` errors with `unknown field` for any
517
+ * field outside `{xid_document, pet_name}`. We mirror that
518
+ * behaviour so a registry file produced by a future Rust
519
+ * version with extra fields is rejected explicitly rather than
520
+ * silently lossy.
505
521
  */
506
522
  static fromJSON(json) {
523
+ for (const key of Object.keys(json)) if (key !== "xid_document" && key !== "pet_name") throw new Error(`unknown field \`${key}\`, expected \`xid_document\` or \`pet_name\``);
507
524
  const xidDocumentUr = json["xid_document"];
508
525
  const petName = json["pet_name"];
509
526
  return ParticipantRecord.recreateFromSerialized(xidDocumentUr, petName);
@@ -523,9 +540,19 @@ function parseSignedXidDocument(xidDocumentUr) {
523
540
  try {
524
541
  envelope = Envelope.fromTaggedCbor(envelopeCbor);
525
542
  } catch {
526
- envelope = Envelope.fromUntaggedCbor(envelopeCbor);
543
+ try {
544
+ envelope = Envelope.fromUntaggedCbor(envelopeCbor);
545
+ } catch (e) {
546
+ throw new Error(`Unable to decode XID document envelope: ${e.message ?? String(e)}`, { cause: e });
547
+ }
548
+ }
549
+ let document;
550
+ try {
551
+ document = XIDDocument.fromEnvelope(envelope, void 0, XIDVerifySignature.Inception);
552
+ } catch (e) {
553
+ throw new Error(`XID document must be signed by its inception key: ${e.message ?? String(e)}`, { cause: e });
527
554
  }
528
- return [sanitized, XIDDocument.fromEnvelope(envelope, void 0, XIDVerifySignature.Inception)];
555
+ return [sanitized, document];
529
556
  }
530
557
  /**
531
558
  * Sanitize XID UR input.
@@ -648,13 +675,43 @@ var Registry = class Registry {
648
675
  /**
649
676
  * Add a participant.
650
677
  *
651
- * Returns the outcome indicating whether the participant was already present or newly inserted.
678
+ * Mirrors Rust `Registry::add_participant`
679
+ * (`registry_impl.rs:83-124`):
680
+ *
681
+ * 1. If `record.pet_name()` is already used by some other XID,
682
+ * bail with `"Pet name '{name}' already used by another
683
+ * participant"`.
684
+ * 2. If `record.pet_name()` matches an existing record under the
685
+ * *same* XID and the public keys also match, return
686
+ * `AlreadyPresent`.
687
+ * 3. If the pet name matches the same XID but public keys don't,
688
+ * bail with `"Participant already exists with a different pet
689
+ * name"`.
690
+ * 4. Otherwise look up by XID. If present and public-keys + pet-name
691
+ * both match, return `AlreadyPresent`; if XID is present but
692
+ * anything differs, bail. If XID is new, insert and return
693
+ * `Inserted`.
694
+ *
695
+ * The earlier port short-circuited on `participants.has(xidUr)` and
696
+ * always returned `AlreadyPresent` — silently allowing re-adds with
697
+ * a different pet name or different public keys, which Rust
698
+ * correctly forbids.
652
699
  */
653
700
  addParticipant(xid, record) {
654
701
  const xidUr = xid.urString();
655
- if (this._participants.has(xidUr)) return "already_present";
656
702
  const petName = record.petName();
657
- if (petName !== void 0 && this.petNameExists(petName)) throw new Error(`Pet name "${petName}" is already used by another participant`);
703
+ if (petName !== void 0) {
704
+ for (const [existingXidUr, existingRecord] of this._participants) if (existingRecord.petName() === petName) {
705
+ if (existingXidUr !== xidUr) throw new Error(`Pet name '${petName}' already used by another participant`);
706
+ if (publicKeysEqual(existingRecord.publicKeys(), record.publicKeys())) return "already_present";
707
+ throw new Error("Participant already exists with a different pet name");
708
+ }
709
+ }
710
+ const existing = this._participants.get(xidUr);
711
+ if (existing !== void 0) {
712
+ if (publicKeysEqual(existing.publicKeys(), record.publicKeys()) && existing.petName() === record.petName()) return "already_present";
713
+ throw new Error("Participant already exists with a different pet name");
714
+ }
658
715
  this._participants.set(xidUr, record);
659
716
  return "inserted";
660
717
  }
@@ -744,17 +801,25 @@ var Registry = class Registry {
744
801
  }
745
802
  /**
746
803
  * Serialize to JSON object.
804
+ *
805
+ * Mirrors Rust `Registry`'s field declaration order
806
+ * (`registry_impl.rs:8-14` — `owner, participants, groups`). JSON
807
+ * object member order is not semantically significant, but
808
+ * `serde_json::to_string_pretty` emits keys in declaration order,
809
+ * so for byte-equal `registry.json` (used by the integration tests
810
+ * as a string assertion) the TS port must match Rust's order.
811
+ * Empty `owner` is omitted via `Option::None` skip in Rust; we
812
+ * reproduce that by only setting the key when the owner exists.
747
813
  */
748
814
  toJSON() {
815
+ const obj = {};
816
+ if (this._owner !== void 0) obj["owner"] = this._owner.toJSON();
749
817
  const participants = {};
750
818
  for (const [xidUr, record] of this._participants) participants[xidUr] = record.toJSON();
819
+ obj["participants"] = participants;
751
820
  const groups = {};
752
821
  for (const [aridHex, record] of this._groups) groups[aridHex] = record.toJSON();
753
- const obj = {
754
- groups,
755
- participants
756
- };
757
- if (this._owner !== void 0) obj["owner"] = this._owner.toJSON();
822
+ obj["groups"] = groups;
758
823
  return obj;
759
824
  }
760
825
  /**
@@ -787,6 +852,16 @@ function resolveRegistryPath(registryArg, cwd) {
787
852
  if (!registryArg.includes("/") && !registryArg.includes(path.sep)) return path.join(cwd, registryArg);
788
853
  return path.resolve(cwd, registryArg);
789
854
  }
855
+ /**
856
+ * Structural equality on `PublicKeys`, mirroring Rust's
857
+ * `PartialEq::eq` derive (per-component comparison of the signing
858
+ * and encapsulation public keys).
859
+ *
860
+ * @internal
861
+ */
862
+ function publicKeysEqual(a, b) {
863
+ return a.equals(b);
864
+ }
790
865
  //#endregion
791
866
  export { AddOutcome, ContributionPaths, GroupOutcome, GroupParticipant, GroupRecord, OwnerOutcome, OwnerRecord, ParticipantRecord, PendingRequests, Registry, resolveRegistryPath };
792
867
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["sanitizeXidUr"],"sources":["../../src/registry/group-record.ts","../../src/registry/owner-record.ts","../../src/registry/participant-record.ts","../../src/registry/registry-impl.ts"],"sourcesContent":["/**\n * Copyright © 2023-2026 Blockchain Commons, LLC\n * Copyright © 2025-2026 Parity Technologies\n *\n *\n * Group record for the registry.\n *\n * Port of registry/group_record.rs from frost-hubert-rust.\n *\n * @module\n */\n\nimport { ARID, SigningPublicKey, XID } from \"@bcts/components\";\n\n/**\n * A participant in a group.\n *\n * Port of `struct GroupParticipant` from group_record.rs lines 9-13.\n */\nexport class GroupParticipant {\n private readonly _xid: XID;\n\n constructor(xid: XID) {\n this._xid = xid;\n }\n\n xid(): XID {\n return this._xid;\n }\n\n toJSON(): string {\n return this._xid.urString();\n }\n\n static fromJSON(value: string): GroupParticipant {\n const xid = XID.fromURString(value);\n return new GroupParticipant(xid);\n }\n}\n\n/**\n * Contribution paths for DKG state files.\n *\n * Port of `struct ContributionPaths` from group_record.rs lines 21-29.\n */\nexport class ContributionPaths {\n round1Secret?: string | undefined;\n round1Package?: string | undefined;\n round2Secret?: string | undefined;\n keyPackage?: string | undefined;\n\n constructor(init?: Partial<ContributionPaths>) {\n if (init !== undefined) {\n this.round1Secret = init.round1Secret;\n this.round1Package = init.round1Package;\n this.round2Secret = init.round2Secret;\n this.keyPackage = init.keyPackage;\n }\n }\n\n /**\n * Merge missing fields from another ContributionPaths.\n *\n * Port of `ContributionPaths::merge_missing()` from group_record.rs lines 32-45.\n */\n mergeMissing(other: ContributionPaths): void {\n this.round1Secret ??= other.round1Secret;\n this.round1Package ??= other.round1Package;\n this.round2Secret ??= other.round2Secret;\n this.keyPackage ??= other.keyPackage;\n }\n\n /**\n * Check if all fields are empty.\n *\n * Port of `ContributionPaths::is_empty()` from group_record.rs lines 47-53.\n */\n isEmpty(): boolean {\n return (\n this.round1Secret === undefined &&\n this.round1Package === undefined &&\n this.round2Secret === undefined &&\n this.keyPackage === undefined\n );\n }\n\n toJSON(): Record<string, string> {\n const obj: Record<string, string> = {};\n if (this.round1Secret !== undefined) obj[\"round1_secret\"] = this.round1Secret;\n if (this.round1Package !== undefined) obj[\"round1_package\"] = this.round1Package;\n if (this.round2Secret !== undefined) obj[\"round2_secret\"] = this.round2Secret;\n if (this.keyPackage !== undefined) obj[\"key_package\"] = this.keyPackage;\n return obj;\n }\n\n static fromJSON(json: Record<string, string>): ContributionPaths {\n return new ContributionPaths({\n round1Secret: json[\"round1_secret\"],\n round1Package: json[\"round1_package\"],\n round2Secret: json[\"round2_secret\"],\n keyPackage: json[\"key_package\"],\n });\n }\n}\n\n/**\n * A pending request entry.\n */\ninterface PendingRequestEntry {\n participant: XID;\n sendToArid?: ARID | undefined;\n collectFromArid: ARID;\n}\n\n/**\n * Tracks pending communication with participants (coordinator-side).\n *\n * Port of `struct PendingRequests` from group_record.rs lines 71-75.\n */\nexport class PendingRequests {\n private readonly requests: PendingRequestEntry[] = [];\n\n /**\n * Add a pending request where we only know where to collect from.\n *\n * Port of `PendingRequests::add_collect_only()` from group_record.rs lines 90-99.\n */\n addCollectOnly(participant: XID, collectFromArid: ARID): void {\n this.requests.push({\n participant,\n sendToArid: undefined,\n collectFromArid,\n });\n }\n\n /**\n * Add a pending request where we know where to send AND where to collect.\n *\n * Port of `PendingRequests::add_send_and_collect()` from group_record.rs lines 103-115.\n */\n addSendAndCollect(participant: XID, sendToArid: ARID, collectFromArid: ARID): void {\n this.requests.push({\n participant,\n sendToArid,\n collectFromArid,\n });\n }\n\n /**\n * Add a pending request where we only know where to send.\n *\n * Port of `PendingRequests::add_send_only()` from group_record.rs lines 118-127.\n */\n addSendOnly(participant: XID, sendToArid: ARID): void {\n this.requests.push({\n participant,\n sendToArid,\n collectFromArid: sendToArid, // Placeholder\n });\n }\n\n /**\n * Check if there are no pending requests.\n *\n * Port of `PendingRequests::is_empty()` from group_record.rs line 129.\n */\n isEmpty(): boolean {\n return this.requests.length === 0;\n }\n\n /**\n * Get the number of pending requests.\n *\n * Port of `PendingRequests::len()` from group_record.rs line 165.\n */\n len(): number {\n return this.requests.length;\n }\n\n /**\n * Iterate over (participant, collectFromArid) pairs.\n *\n * Port of `PendingRequests::iter_collect()` from group_record.rs lines 132-138.\n */\n *iterCollect(): Generator<[XID, ARID]> {\n for (const r of this.requests) {\n yield [r.participant, r.collectFromArid];\n }\n }\n\n /**\n * Iterate over (participant, sendToArid) pairs.\n *\n * Port of `PendingRequests::iter_send()` from group_record.rs lines 141-150.\n */\n *iterSend(): Generator<[XID, ARID]> {\n for (const r of this.requests) {\n if (r.sendToArid === undefined) {\n throw new Error(\"send_to_arid not set for this request\");\n }\n yield [r.participant, r.sendToArid];\n }\n }\n\n /**\n * Iterate over full (participant, sendToArid, collectFromArid) tuples.\n *\n * Port of `PendingRequests::iter_full()` from group_record.rs lines 153-163.\n */\n *iterFull(): Generator<[XID, ARID | undefined, ARID]> {\n for (const r of this.requests) {\n yield [r.participant, r.sendToArid, r.collectFromArid];\n }\n }\n\n toJSON(): unknown[] {\n return this.requests.map((r) => ({\n participant: r.participant.urString(),\n send_to_arid: r.sendToArid?.urString(),\n collect_from_arid: r.collectFromArid.urString(),\n }));\n }\n\n static fromJSON(json: unknown[]): PendingRequests {\n const pr = new PendingRequests();\n for (const entry of json as Record<string, string>[]) {\n const participant = XID.fromURString(entry[\"participant\"]);\n const sendToArid =\n entry[\"send_to_arid\"] !== undefined && entry[\"send_to_arid\"] !== \"\"\n ? ARID.fromURString(entry[\"send_to_arid\"])\n : undefined;\n const collectFromArid = ARID.fromURString(entry[\"collect_from_arid\"]);\n pr.requests.push({ participant, sendToArid, collectFromArid });\n }\n return pr;\n }\n}\n\n/**\n * Record of a DKG group.\n *\n * Port of `struct GroupRecord` from group_record.rs lines 168-186.\n */\nexport class GroupRecord {\n private readonly _charter: string;\n private readonly _minSigners: number;\n private readonly _coordinator: GroupParticipant;\n private readonly _participants: GroupParticipant[];\n private _contributions: ContributionPaths;\n private _listeningAtArid?: ARID | undefined;\n private _pendingRequests: PendingRequests;\n private _verifyingKey?: SigningPublicKey | undefined;\n\n constructor(\n charter: string,\n minSigners: number,\n coordinator: GroupParticipant,\n participants: GroupParticipant[],\n ) {\n this._charter = charter;\n this._minSigners = minSigners;\n this._coordinator = coordinator;\n this._participants = participants;\n this._contributions = new ContributionPaths();\n this._listeningAtArid = undefined;\n this._pendingRequests = new PendingRequests();\n this._verifyingKey = undefined;\n }\n\n coordinator(): GroupParticipant {\n return this._coordinator;\n }\n\n participants(): GroupParticipant[] {\n return this._participants;\n }\n\n minSigners(): number {\n return this._minSigners;\n }\n\n charter(): string {\n return this._charter;\n }\n\n contributions(): ContributionPaths {\n return this._contributions;\n }\n\n setContributions(contributions: ContributionPaths): void {\n this._contributions = contributions;\n }\n\n mergeContributions(other: ContributionPaths): void {\n this._contributions.mergeMissing(other);\n }\n\n listeningAtArid(): ARID | undefined {\n return this._listeningAtArid;\n }\n\n setListeningAtArid(arid: ARID): void {\n this._listeningAtArid = arid;\n }\n\n clearListeningAtArid(): void {\n this._listeningAtArid = undefined;\n }\n\n pendingRequests(): PendingRequests {\n return this._pendingRequests;\n }\n\n setPendingRequests(requests: PendingRequests): void {\n this._pendingRequests = requests;\n }\n\n clearPendingRequests(): void {\n this._pendingRequests = new PendingRequests();\n }\n\n /**\n * Check if the config matches another group record.\n *\n * Port of `GroupRecord::config_matches()` from group_record.rs lines 247-253.\n */\n configMatches(other: GroupRecord): boolean {\n return (\n this._charter === other._charter &&\n this._minSigners === other._minSigners &&\n this._coordinator.xid().toString() === other._coordinator.xid().toString() &&\n this._participants.length === other._participants.length &&\n this._participants.every(\n (p, i) => p.xid().toString() === other._participants[i].xid().toString(),\n )\n );\n }\n\n verifyingKey(): SigningPublicKey | undefined {\n return this._verifyingKey;\n }\n\n setVerifyingKey(key: SigningPublicKey): void {\n this._verifyingKey = key;\n }\n\n toJSON(): Record<string, unknown> {\n const obj: Record<string, unknown> = {\n charter: this._charter,\n min_signers: this._minSigners,\n coordinator: this._coordinator.toJSON(),\n participants: this._participants.map((p) => p.toJSON()),\n };\n if (!this._contributions.isEmpty()) {\n obj[\"contributions\"] = this._contributions.toJSON();\n }\n if (this._listeningAtArid !== undefined) {\n obj[\"listening_at_arid\"] = this._listeningAtArid.urString();\n }\n if (!this._pendingRequests.isEmpty()) {\n obj[\"pending_requests\"] = this._pendingRequests.toJSON();\n }\n if (this._verifyingKey !== undefined) {\n obj[\"verifying_key\"] = this._verifyingKey.urString();\n }\n return obj;\n }\n\n static fromJSON(json: Record<string, unknown>): GroupRecord {\n const charter = json[\"charter\"] as string;\n const minSigners = json[\"min_signers\"] as number;\n const coordinator = GroupParticipant.fromJSON(json[\"coordinator\"] as string);\n const participants = (json[\"participants\"] as string[]).map((p) =>\n GroupParticipant.fromJSON(p),\n );\n\n const record = new GroupRecord(charter, minSigners, coordinator, participants);\n\n if (json[\"contributions\"] !== undefined) {\n record._contributions = ContributionPaths.fromJSON(\n json[\"contributions\"] as Record<string, string>,\n );\n }\n if (json[\"listening_at_arid\"] !== undefined) {\n record._listeningAtArid = ARID.fromURString(json[\"listening_at_arid\"] as string);\n }\n if (json[\"pending_requests\"] !== undefined) {\n record._pendingRequests = PendingRequests.fromJSON(json[\"pending_requests\"] as unknown[]);\n }\n if (json[\"verifying_key\"] !== undefined) {\n record._verifyingKey = SigningPublicKey.fromURString(json[\"verifying_key\"] as string);\n }\n\n return record;\n }\n}\n","/**\n * Copyright © 2023-2026 Blockchain Commons, LLC\n * Copyright © 2025-2026 Parity Technologies\n *\n *\n * Owner record for the registry.\n *\n * Port of registry/owner_record.rs from frost-hubert-rust.\n *\n * @module\n */\n\nimport { type XID } from \"@bcts/components\";\nimport { Envelope } from \"@bcts/envelope\";\nimport { UR } from \"@bcts/uniform-resources\";\nimport { XIDDocument, XIDVerifySignature } from \"@bcts/xid\";\n\n/**\n * Record of the registry owner (coordinator).\n *\n * Port of `struct OwnerRecord` from owner_record.rs lines 13-17.\n */\nexport class OwnerRecord {\n private readonly _xidDocumentUr: string;\n private readonly _xidDocument: XIDDocument;\n private readonly _petName: string | undefined;\n\n private constructor(\n xidDocumentUr: string,\n xidDocument: XIDDocument,\n petName: string | undefined,\n ) {\n this._xidDocumentUr = xidDocumentUr;\n this._xidDocument = xidDocument;\n this._petName = petName;\n }\n\n /**\n * Create an owner record from a signed XID UR string.\n *\n * Port of `OwnerRecord::from_signed_xid_ur()` from owner_record.rs lines 20-32.\n */\n static fromSignedXidUr(xidDocumentUr: string, petName?: string): OwnerRecord {\n const [raw, document] = parseRelaxedXidDocument(xidDocumentUr);\n\n if (document.inceptionPrivateKeys() === undefined) {\n throw new Error(\"Owner XID document must include private keys\");\n }\n\n return new OwnerRecord(raw, document, petName);\n }\n\n /**\n * Get the XID of the owner.\n *\n * Port of `OwnerRecord::xid()` from owner_record.rs line 34.\n */\n xid(): XID {\n return this._xidDocument.xid();\n }\n\n /**\n * Get the XID document of the owner.\n *\n * Port of `OwnerRecord::xid_document()` from owner_record.rs line 36.\n */\n xidDocument(): XIDDocument {\n return this._xidDocument;\n }\n\n /**\n * Get the UR string of the XID document.\n *\n * Port of `OwnerRecord::xid_document_ur()` from owner_record.rs line 38.\n */\n xidDocumentUr(): string {\n return this._xidDocumentUr;\n }\n\n /**\n * Get the pet name of the owner.\n *\n * Port of `OwnerRecord::pet_name()` from owner_record.rs line 40.\n */\n petName(): string | undefined {\n return this._petName;\n }\n\n /**\n * Serialize to JSON object.\n */\n toJSON(): Record<string, unknown> {\n const obj: Record<string, unknown> = {\n xid_document: this._xidDocumentUr,\n };\n if (this._petName !== undefined) {\n obj[\"pet_name\"] = this._petName;\n }\n return obj;\n }\n\n /**\n * Deserialize from JSON object.\n */\n static fromJSON(json: Record<string, unknown>): OwnerRecord {\n const xidDocumentUr = json[\"xid_document\"] as string;\n const petName = json[\"pet_name\"] as string | undefined;\n return OwnerRecord.fromSignedXidUr(xidDocumentUr, petName);\n }\n}\n\n/**\n * Parse a XID document with relaxed validation (no signature verification).\n *\n * Port of `parse_relaxed_xid_document()` from owner_record.rs lines 144-165.\n */\nfunction parseRelaxedXidDocument(xidDocumentUr: string): [string, XIDDocument] {\n const sanitized = sanitizeXidUr(xidDocumentUr);\n const ur = UR.fromURString(sanitized);\n\n if (ur.urTypeStr() !== \"xid\" && ur.urTypeStr() !== \"envelope\") {\n throw new Error(`Expected a ur:xid document, found ur:${ur.urTypeStr()}`);\n }\n\n const envelopeCbor = ur.cbor();\n let envelope: Envelope;\n try {\n envelope = Envelope.fromTaggedCbor(envelopeCbor);\n } catch {\n envelope = Envelope.fromUntaggedCbor(envelopeCbor);\n }\n\n const document = XIDDocument.fromEnvelope(envelope, undefined, XIDVerifySignature.None);\n\n return [sanitized, document];\n}\n\n/**\n * Sanitize XID UR input.\n *\n * Port of `sanitize_xid_ur()` from owner_record.rs lines 167-174.\n */\nfunction sanitizeXidUr(input: string): string {\n const trimmed = input.trim();\n if (trimmed.length === 0) {\n throw new Error(\"XID document is required\");\n }\n return trimmed;\n}\n","/**\n * Copyright © 2023-2026 Blockchain Commons, LLC\n * Copyright © 2025-2026 Parity Technologies\n *\n *\n * Participant record for the registry.\n *\n * Port of registry/participant_record.rs from frost-hubert-rust.\n *\n * @module\n */\n\nimport { type PublicKeys, type XID } from \"@bcts/components\";\nimport { Envelope } from \"@bcts/envelope\";\nimport { UR } from \"@bcts/uniform-resources\";\nimport { XIDDocument, XIDVerifySignature } from \"@bcts/xid\";\n\n/**\n * Record of a participant in the registry.\n *\n * Port of `struct ParticipantRecord` from participant_record.rs lines 12-17.\n */\nexport class ParticipantRecord {\n private readonly _xidDocumentUr: string;\n private readonly _xidDocument: XIDDocument;\n private readonly _publicKeys: PublicKeys;\n private readonly _petName: string | undefined;\n\n private constructor(\n xidDocumentUr: string,\n xidDocument: XIDDocument,\n publicKeys: PublicKeys,\n petName: string | undefined,\n ) {\n this._xidDocumentUr = xidDocumentUr;\n this._xidDocument = xidDocument;\n this._publicKeys = publicKeys;\n this._petName = petName;\n }\n\n /**\n * Create a participant record from a signed XID UR string.\n *\n * Port of `ParticipantRecord::from_signed_xid_ur()` from participant_record.rs lines 20-26.\n */\n static fromSignedXidUr(xidDocumentUr: string, petName?: string): ParticipantRecord {\n const [raw, document] = parseSignedXidDocument(xidDocumentUr);\n return ParticipantRecord.buildFromParts(document, raw, petName);\n }\n\n /**\n * Get the pet name of the participant.\n *\n * Port of `ParticipantRecord::pet_name()` from participant_record.rs line 28.\n */\n petName(): string | undefined {\n return this._petName;\n }\n\n /**\n * Get the public keys of the participant.\n *\n * Port of `ParticipantRecord::public_keys()` from participant_record.rs line 29.\n */\n publicKeys(): PublicKeys {\n return this._publicKeys;\n }\n\n /**\n * Get the XID of the participant.\n *\n * Port of `ParticipantRecord::xid()` from participant_record.rs line 30.\n */\n xid(): XID {\n return this._xidDocument.xid();\n }\n\n /**\n * Get the XID document of the participant.\n *\n * Port of `ParticipantRecord::xid_document()` from participant_record.rs line 31.\n */\n xidDocument(): XIDDocument {\n return this._xidDocument;\n }\n\n /**\n * Get the UR string of the XID document.\n *\n * Port of `ParticipantRecord::xid_document_ur()` from participant_record.rs line 32.\n */\n xidDocumentUr(): string {\n return this._xidDocumentUr;\n }\n\n /**\n * Build from constituent parts.\n *\n * Port of `ParticipantRecord::build_from_parts()` from participant_record.rs lines 34-49.\n */\n private static buildFromParts(\n document: XIDDocument,\n xidDocumentUr: string,\n petName: string | undefined,\n ): ParticipantRecord {\n const inceptionKey = document.inceptionKey();\n if (inceptionKey === undefined) {\n throw new Error(\"XID document missing inception key\");\n }\n\n const publicKeys = inceptionKey.publicKeys();\n\n return new ParticipantRecord(xidDocumentUr, document, publicKeys, petName);\n }\n\n /**\n * Recreate from serialized data.\n *\n * Port of `ParticipantRecord::recreate_from_serialized()` from participant_record.rs lines 51-57.\n */\n private static recreateFromSerialized(\n xidDocumentUr: string,\n petName: string | undefined,\n ): ParticipantRecord {\n const [raw, document] = parseSignedXidDocument(xidDocumentUr);\n return ParticipantRecord.buildFromParts(document, raw, petName);\n }\n\n /**\n * Serialize to JSON object.\n */\n toJSON(): Record<string, unknown> {\n const obj: Record<string, unknown> = {\n xid_document: this._xidDocumentUr,\n };\n if (this._petName !== undefined) {\n obj[\"pet_name\"] = this._petName;\n }\n return obj;\n }\n\n /**\n * Deserialize from JSON object.\n */\n static fromJSON(json: Record<string, unknown>): ParticipantRecord {\n const xidDocumentUr = json[\"xid_document\"] as string;\n const petName = json[\"pet_name\"] as string | undefined;\n return ParticipantRecord.recreateFromSerialized(xidDocumentUr, petName);\n }\n}\n\n/**\n * Parse a signed XID document from a UR string.\n *\n * Port of `parse_signed_xid_document()` from participant_record.rs lines 170-194.\n */\nfunction parseSignedXidDocument(xidDocumentUr: string): [string, XIDDocument] {\n const sanitized = sanitizeXidUr(xidDocumentUr);\n const ur = UR.fromURString(sanitized);\n\n if (ur.urTypeStr() !== \"xid\" && ur.urTypeStr() !== \"envelope\") {\n throw new Error(`Expected a ur:xid document, found ur:${ur.urTypeStr()}`);\n }\n\n const envelopeCbor = ur.cbor();\n let envelope: Envelope;\n try {\n envelope = Envelope.fromTaggedCbor(envelopeCbor);\n } catch {\n envelope = Envelope.fromUntaggedCbor(envelopeCbor);\n }\n\n const document = XIDDocument.fromEnvelope(envelope, undefined, XIDVerifySignature.Inception);\n\n return [sanitized, document];\n}\n\n/**\n * Sanitize XID UR input.\n *\n * Port of `sanitize_xid_ur()` from participant_record.rs lines 196-203.\n */\nfunction sanitizeXidUr(input: string): string {\n const trimmed = input.trim();\n if (trimmed.length === 0) {\n throw new Error(\"XID document is required\");\n }\n return trimmed;\n}\n","/**\n * Copyright © 2023-2026 Blockchain Commons, LLC\n * Copyright © 2025-2026 Parity Technologies\n *\n *\n * Registry implementation for managing participants and groups.\n *\n * Port of registry/registry_impl.rs from frost-hubert-rust.\n *\n * @module\n */\n\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\n\nimport { type ARID, type XID } from \"@bcts/components\";\n\nimport { GroupRecord } from \"./group-record.js\";\nimport { OwnerRecord } from \"./owner-record.js\";\nimport { ParticipantRecord } from \"./participant-record.js\";\n\n/**\n * Outcome of adding a participant to the registry.\n *\n * Port of `enum AddOutcome` from registry_impl.rs.\n */\nexport enum AddOutcome {\n /** Participant was already present in the registry */\n AlreadyPresent = \"already_present\",\n /** Participant was successfully inserted */\n Inserted = \"inserted\",\n}\n\n/**\n * Outcome of setting the owner in the registry.\n *\n * Port of `enum OwnerOutcome` from registry_impl.rs.\n */\nexport enum OwnerOutcome {\n /** Owner was already present in the registry */\n AlreadyPresent = \"already_present\",\n /** Owner was successfully inserted */\n Inserted = \"inserted\",\n}\n\n/**\n * Outcome of recording a group in the registry.\n *\n * Port of `enum GroupOutcome` from registry_impl.rs.\n */\nexport enum GroupOutcome {\n /** Group was successfully inserted as new */\n Inserted = \"inserted\",\n /** Group already existed and was updated (contributions merged) */\n Updated = \"updated\",\n}\n\n/**\n * Registry for managing participants and groups.\n *\n * Port of `struct Registry` from registry_impl.rs lines 22-26.\n */\nexport class Registry {\n private _owner?: OwnerRecord | undefined;\n private readonly _participants: Map<string, ParticipantRecord>; // Map by XID UR string\n private readonly _groups: Map<string, GroupRecord>; // Map by ARID hex\n\n constructor() {\n this._owner = undefined;\n this._participants = new Map();\n this._groups = new Map();\n }\n\n /**\n * Get the owner record.\n */\n owner(): OwnerRecord | undefined {\n return this._owner;\n }\n\n /**\n * Set the owner record.\n *\n * Returns the outcome indicating whether the owner was already present or newly inserted.\n *\n * Port of `Registry::set_owner()` from registry_impl.rs.\n */\n setOwner(owner: OwnerRecord): OwnerOutcome {\n // Check for pet name conflicts with participants\n const petName = owner.petName();\n if (petName !== undefined) {\n const conflicting = this.participantByPetName(petName);\n if (conflicting?.[1].petName() === petName) {\n throw new Error(`Pet name '${petName}' already used by a participant`);\n }\n }\n\n if (this._owner === undefined) {\n this._owner = owner;\n return OwnerOutcome.Inserted;\n }\n\n const existing = this._owner;\n const existingXidUr = existing.xid().urString();\n const ownerXidUr = owner.xid().urString();\n\n if (\n existingXidUr === ownerXidUr &&\n existing.xidDocumentUr() === owner.xidDocumentUr() &&\n existing.petName() === owner.petName()\n ) {\n return OwnerOutcome.AlreadyPresent;\n }\n\n if (existingXidUr === ownerXidUr) {\n if (existing.xidDocumentUr() !== owner.xidDocumentUr()) {\n throw new Error(\"Owner already exists with different keys\");\n }\n this._owner = owner;\n return OwnerOutcome.Inserted;\n }\n\n throw new Error(`Owner already recorded for ${existing.xid().toString()}`);\n }\n\n /**\n * Get all participants.\n */\n participants(): Map<string, ParticipantRecord> {\n return this._participants;\n }\n\n /**\n * Get a participant by XID.\n */\n participant(xid: XID): ParticipantRecord | undefined {\n return this._participants.get(xid.urString());\n }\n\n /**\n * Add a participant.\n *\n * Returns the outcome indicating whether the participant was already present or newly inserted.\n */\n addParticipant(xid: XID, record: ParticipantRecord): AddOutcome {\n const xidUr = xid.urString();\n\n // Check if already present\n if (this._participants.has(xidUr)) {\n return AddOutcome.AlreadyPresent;\n }\n\n // Check for conflicting pet name\n const petName = record.petName();\n if (petName !== undefined && this.petNameExists(petName)) {\n throw new Error(`Pet name \"${petName}\" is already used by another participant`);\n }\n\n this._participants.set(xidUr, record);\n return AddOutcome.Inserted;\n }\n\n /**\n * Check if a pet name is already used.\n */\n petNameExists(petName: string): boolean {\n for (const record of this._participants.values()) {\n if (record.petName() === petName) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Find a participant by pet name.\n *\n * Port of `Registry::participant_by_pet_name()` from registry_impl.rs.\n */\n participantByPetName(petName: string): [XID, ParticipantRecord] | undefined {\n for (const record of this._participants.values()) {\n if (record.petName() === petName) {\n return [record.xid(), record];\n }\n }\n return undefined;\n }\n\n /**\n * Get all groups.\n */\n groups(): Map<string, GroupRecord> {\n return this._groups;\n }\n\n /**\n * Get a group by ARID.\n */\n group(arid: ARID): GroupRecord | undefined {\n return this._groups.get(arid.hex());\n }\n\n /**\n * Get a mutable reference to a group by ARID.\n */\n groupMut(arid: ARID): GroupRecord | undefined {\n return this._groups.get(arid.hex());\n }\n\n /**\n * Record a group in the registry.\n *\n * If the group already exists:\n * - Validates that the config matches\n * - Merges contributions from the new record\n * - Updates verifying key if not already set\n *\n * Port of `Registry::record_group()` from registry_impl.rs.\n */\n recordGroup(groupId: ARID, record: GroupRecord): GroupOutcome {\n const key = groupId.hex();\n const existing = this._groups.get(key);\n\n if (existing !== undefined) {\n // Validate config matches\n if (!existing.configMatches(record)) {\n throw new Error(`Group ${groupId.hex()} already exists with a different configuration`);\n }\n\n // Merge contributions\n existing.mergeContributions(record.contributions());\n\n // Update verifying key if not already set\n const existingKey = existing.verifyingKey();\n const recordKey = record.verifyingKey();\n if (existingKey === undefined && recordKey !== undefined) {\n existing.setVerifyingKey(recordKey);\n } else if (\n existingKey !== undefined &&\n recordKey !== undefined &&\n existingKey.urString() !== recordKey.urString()\n ) {\n throw new Error(`Group ${groupId.hex()} already exists with a different verifying key`);\n }\n\n return GroupOutcome.Updated;\n }\n\n this._groups.set(key, record);\n return GroupOutcome.Inserted;\n }\n\n /**\n * Add a group (simple variant without merge logic).\n *\n * @deprecated Use recordGroup() for proper merge behavior.\n */\n addGroup(arid: ARID, record: GroupRecord): void {\n this._groups.set(arid.hex(), record);\n }\n\n /**\n * Load a registry from a file.\n */\n static load(filePath: string): Registry {\n if (!fs.existsSync(filePath)) {\n return new Registry();\n }\n\n const content = fs.readFileSync(filePath, \"utf-8\");\n const json = JSON.parse(content) as Record<string, unknown>;\n return Registry.fromJSON(json);\n }\n\n /**\n * Save the registry to a file.\n */\n save(filePath: string): void {\n const dir = path.dirname(filePath);\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir, { recursive: true });\n }\n\n const json = this.toJSON();\n fs.writeFileSync(filePath, JSON.stringify(json, null, 2));\n }\n\n /**\n * Serialize to JSON object.\n */\n toJSON(): Record<string, unknown> {\n const participants: Record<string, unknown> = {};\n for (const [xidUr, record] of this._participants) {\n participants[xidUr] = record.toJSON();\n }\n\n const groups: Record<string, unknown> = {};\n for (const [aridHex, record] of this._groups) {\n groups[aridHex] = record.toJSON();\n }\n\n const obj: Record<string, unknown> = {\n groups,\n participants,\n };\n\n if (this._owner !== undefined) {\n obj[\"owner\"] = this._owner.toJSON();\n }\n\n return obj;\n }\n\n /**\n * Deserialize from JSON object.\n */\n static fromJSON(json: Record<string, unknown>): Registry {\n const registry = new Registry();\n\n if (json[\"owner\"] !== undefined) {\n registry._owner = OwnerRecord.fromJSON(json[\"owner\"] as Record<string, unknown>);\n }\n\n const participantsJson = json[\"participants\"] as\n | Record<string, Record<string, unknown>>\n | undefined;\n if (participantsJson !== undefined) {\n for (const [, recordJson] of Object.entries(participantsJson)) {\n const record = ParticipantRecord.fromJSON(recordJson);\n registry._participants.set(record.xid().urString(), record);\n }\n }\n\n const groupsJson = json[\"groups\"] as Record<string, Record<string, unknown>> | undefined;\n if (groupsJson !== undefined) {\n for (const [aridHex, recordJson] of Object.entries(groupsJson)) {\n const record = GroupRecord.fromJSON(recordJson);\n registry._groups.set(aridHex, record);\n }\n }\n\n return registry;\n }\n}\n\n/**\n * Resolve the registry file path from a given argument.\n *\n * Port of `resolve_registry_path()` from registry/mod.rs lines 49-78.\n */\nexport function resolveRegistryPath(registryArg: string | undefined, cwd: string): string {\n if (registryArg === undefined || registryArg === \"\") {\n return path.join(cwd, \"registry.json\");\n }\n\n // If it ends with / or is a directory, append registry.json\n if (registryArg.endsWith(\"/\") || registryArg.endsWith(path.sep)) {\n return path.join(cwd, registryArg, \"registry.json\");\n }\n\n // If it's just a filename, put it in cwd\n if (!registryArg.includes(\"/\") && !registryArg.includes(path.sep)) {\n return path.join(cwd, registryArg);\n }\n\n // Otherwise, treat as relative path\n return path.resolve(cwd, registryArg);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAmBA,IAAa,mBAAb,MAAa,iBAAiB;CAC5B;CAEA,YAAY,KAAU;AACpB,OAAK,OAAO;;CAGd,MAAW;AACT,SAAO,KAAK;;CAGd,SAAiB;AACf,SAAO,KAAK,KAAK,UAAU;;CAG7B,OAAO,SAAS,OAAiC;AAE/C,SAAO,IAAI,iBADC,IAAI,aAAa,MACE,CAAC;;;;;;;;AASpC,IAAa,oBAAb,MAAa,kBAAkB;CAC7B;CACA;CACA;CACA;CAEA,YAAY,MAAmC;AAC7C,MAAI,SAAS,KAAA,GAAW;AACtB,QAAK,eAAe,KAAK;AACzB,QAAK,gBAAgB,KAAK;AAC1B,QAAK,eAAe,K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,MAAM,aAAa,KAAK;AACxB,MAAI,eAAe,KAAA,EACjB,MAAK,MAAM,CAAC,SAAS,eAAe,OAAO,QAAQ,WAAW,EAAE;GAC9D,MAAM,SAAS,YAAY,SAAS,WAAW;AAC/C,YAAS,QAAQ,IAAI,SAAS,OAAO;;AAIzC,SAAO;;;;;;;;AASX,SAAgB,oBAAoB,aAAiC,KAAqB;AACxF,KAAI,gBAAgB,KAAA,KAAa,gBAAgB,GAC/C,QAAO,KAAK,KAAK,KAAK,gBAAgB;AAIxC,KAAI,YAAY,SAAS,IAAI,IAAI,YAAY,SAAS,KAAK,IAAI,CAC7D,QAAO,KAAK,KAAK,KAAK,aAAa,gBAAgB;AAIrD,KAAI,CAAC,YAAY,SAAS,IAAI,IAAI,CAAC,YAAY,SAAS,KAAK,IAAI,CAC/D,QAAO,KAAK,KAAK,KAAK,YAAY;AAIpC,QAAO,KAAK,QAAQ,KAAK,YAAY"}
1
+ {"version":3,"file":"index.mjs","names":["sanitizeXidUr"],"sources":["../../src/registry/group-record.ts","../../src/registry/owner-record.ts","../../src/registry/participant-record.ts","../../src/registry/registry-impl.ts"],"sourcesContent":["/**\n * Copyright © 2023-2026 Blockchain Commons, LLC\n * Copyright © 2025-2026 Parity Technologies\n *\n *\n * Group record for the registry.\n *\n * Port of registry/group_record.rs from frost-hubert-rust.\n *\n * @module\n */\n\nimport { ARID, SigningPublicKey, XID } from \"@bcts/components\";\n\n/**\n * A participant in a group.\n *\n * Port of `struct GroupParticipant` from group_record.rs lines 9-13.\n */\nexport class GroupParticipant {\n private readonly _xid: XID;\n\n constructor(xid: XID) {\n this._xid = xid;\n }\n\n xid(): XID {\n return this._xid;\n }\n\n toJSON(): string {\n return this._xid.urString();\n }\n\n static fromJSON(value: string): GroupParticipant {\n const xid = XID.fromURString(value);\n return new GroupParticipant(xid);\n }\n}\n\n/**\n * Contribution paths for DKG state files.\n *\n * Port of `struct ContributionPaths` from group_record.rs lines 21-29.\n */\nexport class ContributionPaths {\n round1Secret?: string | undefined;\n round1Package?: string | undefined;\n round2Secret?: string | undefined;\n keyPackage?: string | undefined;\n\n constructor(init?: Partial<ContributionPaths>) {\n if (init !== undefined) {\n this.round1Secret = init.round1Secret;\n this.round1Package = init.round1Package;\n this.round2Secret = init.round2Secret;\n this.keyPackage = init.keyPackage;\n }\n }\n\n /**\n * Merge missing fields from another ContributionPaths.\n *\n * Port of `ContributionPaths::merge_missing()` from group_record.rs lines 32-45.\n */\n mergeMissing(other: ContributionPaths): void {\n this.round1Secret ??= other.round1Secret;\n this.round1Package ??= other.round1Package;\n this.round2Secret ??= other.round2Secret;\n this.keyPackage ??= other.keyPackage;\n }\n\n /**\n * Check if all fields are empty.\n *\n * Port of `ContributionPaths::is_empty()` from group_record.rs lines 47-53.\n */\n isEmpty(): boolean {\n return (\n this.round1Secret === undefined &&\n this.round1Package === undefined &&\n this.round2Secret === undefined &&\n this.keyPackage === undefined\n );\n }\n\n toJSON(): Record<string, string> {\n const obj: Record<string, string> = {};\n if (this.round1Secret !== undefined) obj[\"round1_secret\"] = this.round1Secret;\n if (this.round1Package !== undefined) obj[\"round1_package\"] = this.round1Package;\n if (this.round2Secret !== undefined) obj[\"round2_secret\"] = this.round2Secret;\n if (this.keyPackage !== undefined) obj[\"key_package\"] = this.keyPackage;\n return obj;\n }\n\n static fromJSON(json: Record<string, string>): ContributionPaths {\n return new ContributionPaths({\n round1Secret: json[\"round1_secret\"],\n round1Package: json[\"round1_package\"],\n round2Secret: json[\"round2_secret\"],\n keyPackage: json[\"key_package\"],\n });\n }\n}\n\n/**\n * A pending request entry.\n */\ninterface PendingRequestEntry {\n participant: XID;\n sendToArid?: ARID | undefined;\n collectFromArid: ARID;\n}\n\n/**\n * Tracks pending communication with participants (coordinator-side).\n *\n * Port of `struct PendingRequests` from group_record.rs lines 71-75.\n */\nexport class PendingRequests {\n private readonly requests: PendingRequestEntry[] = [];\n\n /**\n * Add a pending request where we only know where to collect from.\n *\n * Port of `PendingRequests::add_collect_only()` from group_record.rs lines 90-99.\n */\n addCollectOnly(participant: XID, collectFromArid: ARID): void {\n this.requests.push({\n participant,\n sendToArid: undefined,\n collectFromArid,\n });\n }\n\n /**\n * Add a pending request where we know where to send AND where to collect.\n *\n * Port of `PendingRequests::add_send_and_collect()` from group_record.rs lines 103-115.\n */\n addSendAndCollect(participant: XID, sendToArid: ARID, collectFromArid: ARID): void {\n this.requests.push({\n participant,\n sendToArid,\n collectFromArid,\n });\n }\n\n /**\n * Add a pending request where we only know where to send.\n *\n * Port of `PendingRequests::add_send_only()` from group_record.rs lines 118-127.\n */\n addSendOnly(participant: XID, sendToArid: ARID): void {\n this.requests.push({\n participant,\n sendToArid,\n collectFromArid: sendToArid, // Placeholder\n });\n }\n\n /**\n * Check if there are no pending requests.\n *\n * Port of `PendingRequests::is_empty()` from group_record.rs line 129.\n */\n isEmpty(): boolean {\n return this.requests.length === 0;\n }\n\n /**\n * Get the number of pending requests.\n *\n * Port of `PendingRequests::len()` from group_record.rs line 165.\n */\n len(): number {\n return this.requests.length;\n }\n\n /**\n * Iterate over (participant, collectFromArid) pairs.\n *\n * Port of `PendingRequests::iter_collect()` from group_record.rs lines 132-138.\n */\n *iterCollect(): Generator<[XID, ARID]> {\n for (const r of this.requests) {\n yield [r.participant, r.collectFromArid];\n }\n }\n\n /**\n * Iterate over (participant, sendToArid) pairs.\n *\n * Port of `PendingRequests::iter_send()` from group_record.rs lines 141-150.\n */\n *iterSend(): Generator<[XID, ARID]> {\n for (const r of this.requests) {\n if (r.sendToArid === undefined) {\n throw new Error(\"send_to_arid not set for this request\");\n }\n yield [r.participant, r.sendToArid];\n }\n }\n\n /**\n * Iterate over full (participant, sendToArid, collectFromArid) tuples.\n *\n * Port of `PendingRequests::iter_full()` from group_record.rs lines 153-163.\n */\n *iterFull(): Generator<[XID, ARID | undefined, ARID]> {\n for (const r of this.requests) {\n yield [r.participant, r.sendToArid, r.collectFromArid];\n }\n }\n\n toJSON(): unknown[] {\n return this.requests.map((r) => ({\n participant: r.participant.urString(),\n send_to_arid: r.sendToArid?.urString(),\n collect_from_arid: r.collectFromArid.urString(),\n }));\n }\n\n static fromJSON(json: unknown[]): PendingRequests {\n const pr = new PendingRequests();\n for (const entry of json as Record<string, string>[]) {\n const participant = XID.fromURString(entry[\"participant\"]);\n const sendToArid =\n entry[\"send_to_arid\"] !== undefined && entry[\"send_to_arid\"] !== \"\"\n ? ARID.fromURString(entry[\"send_to_arid\"])\n : undefined;\n const collectFromArid = ARID.fromURString(entry[\"collect_from_arid\"]);\n pr.requests.push({ participant, sendToArid, collectFromArid });\n }\n return pr;\n }\n}\n\n/**\n * Record of a DKG group.\n *\n * Port of `struct GroupRecord` from group_record.rs lines 168-186.\n */\nexport class GroupRecord {\n private readonly _charter: string;\n private readonly _minSigners: number;\n private readonly _coordinator: GroupParticipant;\n private readonly _participants: GroupParticipant[];\n private _contributions: ContributionPaths;\n private _listeningAtArid?: ARID | undefined;\n private _pendingRequests: PendingRequests;\n private _verifyingKey?: SigningPublicKey | undefined;\n\n constructor(\n charter: string,\n minSigners: number,\n coordinator: GroupParticipant,\n participants: GroupParticipant[],\n ) {\n this._charter = charter;\n this._minSigners = minSigners;\n this._coordinator = coordinator;\n this._participants = participants;\n this._contributions = new ContributionPaths();\n this._listeningAtArid = undefined;\n this._pendingRequests = new PendingRequests();\n this._verifyingKey = undefined;\n }\n\n coordinator(): GroupParticipant {\n return this._coordinator;\n }\n\n participants(): GroupParticipant[] {\n return this._participants;\n }\n\n minSigners(): number {\n return this._minSigners;\n }\n\n charter(): string {\n return this._charter;\n }\n\n contributions(): ContributionPaths {\n return this._contributions;\n }\n\n setContributions(contributions: ContributionPaths): void {\n this._contributions = contributions;\n }\n\n mergeContributions(other: ContributionPaths): void {\n this._contributions.mergeMissing(other);\n }\n\n listeningAtArid(): ARID | undefined {\n return this._listeningAtArid;\n }\n\n setListeningAtArid(arid: ARID): void {\n this._listeningAtArid = arid;\n }\n\n clearListeningAtArid(): void {\n this._listeningAtArid = undefined;\n }\n\n pendingRequests(): PendingRequests {\n return this._pendingRequests;\n }\n\n setPendingRequests(requests: PendingRequests): void {\n this._pendingRequests = requests;\n }\n\n clearPendingRequests(): void {\n this._pendingRequests = new PendingRequests();\n }\n\n /**\n * Check if the config matches another group record.\n *\n * Port of `GroupRecord::config_matches()` from group_record.rs lines 247-253.\n */\n configMatches(other: GroupRecord): boolean {\n return (\n this._charter === other._charter &&\n this._minSigners === other._minSigners &&\n this._coordinator.xid().toString() === other._coordinator.xid().toString() &&\n this._participants.length === other._participants.length &&\n this._participants.every(\n (p, i) => p.xid().toString() === other._participants[i].xid().toString(),\n )\n );\n }\n\n verifyingKey(): SigningPublicKey | undefined {\n return this._verifyingKey;\n }\n\n setVerifyingKey(key: SigningPublicKey): void {\n this._verifyingKey = key;\n }\n\n toJSON(): Record<string, unknown> {\n const obj: Record<string, unknown> = {\n charter: this._charter,\n min_signers: this._minSigners,\n coordinator: this._coordinator.toJSON(),\n participants: this._participants.map((p) => p.toJSON()),\n };\n if (!this._contributions.isEmpty()) {\n obj[\"contributions\"] = this._contributions.toJSON();\n }\n if (this._listeningAtArid !== undefined) {\n obj[\"listening_at_arid\"] = this._listeningAtArid.urString();\n }\n if (!this._pendingRequests.isEmpty()) {\n obj[\"pending_requests\"] = this._pendingRequests.toJSON();\n }\n if (this._verifyingKey !== undefined) {\n obj[\"verifying_key\"] = this._verifyingKey.urString();\n }\n return obj;\n }\n\n static fromJSON(json: Record<string, unknown>): GroupRecord {\n const charter = json[\"charter\"] as string;\n const minSigners = json[\"min_signers\"] as number;\n const coordinator = GroupParticipant.fromJSON(json[\"coordinator\"] as string);\n const participants = (json[\"participants\"] as string[]).map((p) =>\n GroupParticipant.fromJSON(p),\n );\n\n const record = new GroupRecord(charter, minSigners, coordinator, participants);\n\n if (json[\"contributions\"] !== undefined) {\n record._contributions = ContributionPaths.fromJSON(\n json[\"contributions\"] as Record<string, string>,\n );\n }\n if (json[\"listening_at_arid\"] !== undefined) {\n record._listeningAtArid = ARID.fromURString(json[\"listening_at_arid\"] as string);\n }\n if (json[\"pending_requests\"] !== undefined) {\n record._pendingRequests = PendingRequests.fromJSON(json[\"pending_requests\"] as unknown[]);\n }\n if (json[\"verifying_key\"] !== undefined) {\n record._verifyingKey = SigningPublicKey.fromURString(json[\"verifying_key\"] as string);\n }\n\n return record;\n }\n}\n","/**\n * Copyright © 2023-2026 Blockchain Commons, LLC\n * Copyright © 2025-2026 Parity Technologies\n *\n *\n * Owner record for the registry.\n *\n * Port of registry/owner_record.rs from frost-hubert-rust.\n *\n * @module\n */\n\nimport { type XID } from \"@bcts/components\";\nimport { Envelope } from \"@bcts/envelope\";\nimport { UR } from \"@bcts/uniform-resources\";\nimport { XIDDocument, XIDVerifySignature } from \"@bcts/xid\";\n\n/**\n * Record of the registry owner (coordinator).\n *\n * Port of `struct OwnerRecord` from owner_record.rs lines 13-17.\n */\nexport class OwnerRecord {\n private readonly _xidDocumentUr: string;\n private readonly _xidDocument: XIDDocument;\n private readonly _petName: string | undefined;\n\n private constructor(\n xidDocumentUr: string,\n xidDocument: XIDDocument,\n petName: string | undefined,\n ) {\n this._xidDocumentUr = xidDocumentUr;\n this._xidDocument = xidDocument;\n this._petName = petName;\n }\n\n /**\n * Create an owner record from a signed XID UR string.\n *\n * Port of `OwnerRecord::from_signed_xid_ur()` from owner_record.rs lines 20-32.\n */\n static fromSignedXidUr(xidDocumentUr: string, petName?: string): OwnerRecord {\n const [raw, document] = parseRelaxedXidDocument(xidDocumentUr);\n\n if (document.inceptionPrivateKeys() === undefined) {\n throw new Error(\"Owner XID document must include private keys\");\n }\n\n return new OwnerRecord(raw, document, petName);\n }\n\n /**\n * Get the XID of the owner.\n *\n * Port of `OwnerRecord::xid()` from owner_record.rs line 34.\n */\n xid(): XID {\n return this._xidDocument.xid();\n }\n\n /**\n * Get the XID document of the owner.\n *\n * Port of `OwnerRecord::xid_document()` from owner_record.rs line 36.\n */\n xidDocument(): XIDDocument {\n return this._xidDocument;\n }\n\n /**\n * Get the UR string of the XID document.\n *\n * Port of `OwnerRecord::xid_document_ur()` from owner_record.rs line 38.\n */\n xidDocumentUr(): string {\n return this._xidDocumentUr;\n }\n\n /**\n * Get the pet name of the owner.\n *\n * Port of `OwnerRecord::pet_name()` from owner_record.rs line 40.\n */\n petName(): string | undefined {\n return this._petName;\n }\n\n /**\n * Serialize to JSON object.\n */\n toJSON(): Record<string, unknown> {\n const obj: Record<string, unknown> = {\n xid_document: this._xidDocumentUr,\n };\n if (this._petName !== undefined) {\n obj[\"pet_name\"] = this._petName;\n }\n return obj;\n }\n\n /**\n * Deserialize from JSON object.\n *\n * Mirrors Rust's `#[serde(deny_unknown_fields)]` derive on\n * `OwnerRecord` (`owner_record.rs:13-17`) — any field not in\n * `{xid_document, pet_name}` causes Rust's `serde_json::from_str`\n * to error with `unknown field`, and we mirror that here so a\n * registry file produced by a future Rust version with extra\n * fields is rejected explicitly rather than silently lossy.\n */\n static fromJSON(json: Record<string, unknown>): OwnerRecord {\n for (const key of Object.keys(json)) {\n if (key !== \"xid_document\" && key !== \"pet_name\") {\n throw new Error(`unknown field \\`${key}\\`, expected \\`xid_document\\` or \\`pet_name\\``);\n }\n }\n const xidDocumentUr = json[\"xid_document\"] as string;\n const petName = json[\"pet_name\"] as string | undefined;\n return OwnerRecord.fromSignedXidUr(xidDocumentUr, petName);\n }\n}\n\n/**\n * Parse a XID document with relaxed validation (no signature verification).\n *\n * Port of `parse_relaxed_xid_document()` from owner_record.rs lines 144-165.\n */\nfunction parseRelaxedXidDocument(xidDocumentUr: string): [string, XIDDocument] {\n const sanitized = sanitizeXidUr(xidDocumentUr);\n const ur = UR.fromURString(sanitized);\n\n if (ur.urTypeStr() !== \"xid\" && ur.urTypeStr() !== \"envelope\") {\n throw new Error(`Expected a ur:xid document, found ur:${ur.urTypeStr()}`);\n }\n\n const envelopeCbor = ur.cbor();\n let envelope: Envelope;\n try {\n envelope = Envelope.fromTaggedCbor(envelopeCbor);\n } catch {\n envelope = Envelope.fromUntaggedCbor(envelopeCbor);\n }\n\n const document = XIDDocument.fromEnvelope(envelope, undefined, XIDVerifySignature.None);\n\n return [sanitized, document];\n}\n\n/**\n * Sanitize XID UR input.\n *\n * Port of `sanitize_xid_ur()` from owner_record.rs lines 167-174.\n */\nfunction sanitizeXidUr(input: string): string {\n const trimmed = input.trim();\n if (trimmed.length === 0) {\n throw new Error(\"XID document is required\");\n }\n return trimmed;\n}\n","/**\n * Copyright © 2023-2026 Blockchain Commons, LLC\n * Copyright © 2025-2026 Parity Technologies\n *\n *\n * Participant record for the registry.\n *\n * Port of registry/participant_record.rs from frost-hubert-rust.\n *\n * @module\n */\n\nimport { type PublicKeys, type XID } from \"@bcts/components\";\nimport { Envelope } from \"@bcts/envelope\";\nimport { UR } from \"@bcts/uniform-resources\";\nimport { XIDDocument, XIDVerifySignature } from \"@bcts/xid\";\n\n/**\n * Record of a participant in the registry.\n *\n * Port of `struct ParticipantRecord` from participant_record.rs lines 12-17.\n */\nexport class ParticipantRecord {\n private readonly _xidDocumentUr: string;\n private readonly _xidDocument: XIDDocument;\n private readonly _publicKeys: PublicKeys;\n private readonly _petName: string | undefined;\n\n private constructor(\n xidDocumentUr: string,\n xidDocument: XIDDocument,\n publicKeys: PublicKeys,\n petName: string | undefined,\n ) {\n this._xidDocumentUr = xidDocumentUr;\n this._xidDocument = xidDocument;\n this._publicKeys = publicKeys;\n this._petName = petName;\n }\n\n /**\n * Create a participant record from a signed XID UR string.\n *\n * Port of `ParticipantRecord::from_signed_xid_ur()` from participant_record.rs lines 20-26.\n */\n static fromSignedXidUr(xidDocumentUr: string, petName?: string): ParticipantRecord {\n const [raw, document] = parseSignedXidDocument(xidDocumentUr);\n return ParticipantRecord.buildFromParts(document, raw, petName);\n }\n\n /**\n * Get the pet name of the participant.\n *\n * Port of `ParticipantRecord::pet_name()` from participant_record.rs line 28.\n */\n petName(): string | undefined {\n return this._petName;\n }\n\n /**\n * Get the public keys of the participant.\n *\n * Port of `ParticipantRecord::public_keys()` from participant_record.rs line 29.\n */\n publicKeys(): PublicKeys {\n return this._publicKeys;\n }\n\n /**\n * Get the XID of the participant.\n *\n * Port of `ParticipantRecord::xid()` from participant_record.rs line 30.\n */\n xid(): XID {\n return this._xidDocument.xid();\n }\n\n /**\n * Get the XID document of the participant.\n *\n * Port of `ParticipantRecord::xid_document()` from participant_record.rs line 31.\n */\n xidDocument(): XIDDocument {\n return this._xidDocument;\n }\n\n /**\n * Get the UR string of the XID document.\n *\n * Port of `ParticipantRecord::xid_document_ur()` from participant_record.rs line 32.\n */\n xidDocumentUr(): string {\n return this._xidDocumentUr;\n }\n\n /**\n * Build from constituent parts.\n *\n * Port of `ParticipantRecord::build_from_parts()` from participant_record.rs lines 34-49.\n */\n private static buildFromParts(\n document: XIDDocument,\n xidDocumentUr: string,\n petName: string | undefined,\n ): ParticipantRecord {\n const inceptionKey = document.inceptionKey();\n if (inceptionKey === undefined) {\n throw new Error(\"XID document missing inception key\");\n }\n\n const publicKeys = inceptionKey.publicKeys();\n\n return new ParticipantRecord(xidDocumentUr, document, publicKeys, petName);\n }\n\n /**\n * Recreate from serialized data.\n *\n * Port of `ParticipantRecord::recreate_from_serialized()` from participant_record.rs lines 51-57.\n */\n private static recreateFromSerialized(\n xidDocumentUr: string,\n petName: string | undefined,\n ): ParticipantRecord {\n const [raw, document] = parseSignedXidDocument(xidDocumentUr);\n return ParticipantRecord.buildFromParts(document, raw, petName);\n }\n\n /**\n * Serialize to JSON object.\n */\n toJSON(): Record<string, unknown> {\n const obj: Record<string, unknown> = {\n xid_document: this._xidDocumentUr,\n };\n if (this._petName !== undefined) {\n obj[\"pet_name\"] = this._petName;\n }\n return obj;\n }\n\n /**\n * Deserialize from JSON object.\n *\n * Mirrors Rust's `#[serde(deny_unknown_fields)]` derive on\n * `ParticipantRecord` (`participant_record.rs:12-17`) — Rust's\n * `serde_json::from_str` errors with `unknown field` for any\n * field outside `{xid_document, pet_name}`. We mirror that\n * behaviour so a registry file produced by a future Rust\n * version with extra fields is rejected explicitly rather than\n * silently lossy.\n */\n static fromJSON(json: Record<string, unknown>): ParticipantRecord {\n for (const key of Object.keys(json)) {\n if (key !== \"xid_document\" && key !== \"pet_name\") {\n throw new Error(`unknown field \\`${key}\\`, expected \\`xid_document\\` or \\`pet_name\\``);\n }\n }\n const xidDocumentUr = json[\"xid_document\"] as string;\n const petName = json[\"pet_name\"] as string | undefined;\n return ParticipantRecord.recreateFromSerialized(xidDocumentUr, petName);\n }\n}\n\n/**\n * Parse a signed XID document from a UR string.\n *\n * Port of `parse_signed_xid_document()` from participant_record.rs lines 170-194.\n */\nfunction parseSignedXidDocument(xidDocumentUr: string): [string, XIDDocument] {\n const sanitized = sanitizeXidUr(xidDocumentUr);\n const ur = UR.fromURString(sanitized);\n\n if (ur.urTypeStr() !== \"xid\" && ur.urTypeStr() !== \"envelope\") {\n throw new Error(`Expected a ur:xid document, found ur:${ur.urTypeStr()}`);\n }\n\n const envelopeCbor = ur.cbor();\n let envelope: Envelope;\n try {\n envelope = Envelope.fromTaggedCbor(envelopeCbor);\n } catch {\n try {\n envelope = Envelope.fromUntaggedCbor(envelopeCbor);\n } catch (e) {\n throw new Error(\n `Unable to decode XID document envelope: ${(e as Error).message ?? String(e)}`,\n {\n cause: e,\n },\n );\n }\n }\n\n // Mirror Rust `participant_record.rs:198-203`'s `.context(...)` wrap:\n // any failure from `XIDDocument::from_envelope(..., XIDVerifySignature::Inception)`\n // is surfaced as \"XID document must be signed by its inception key: <cause>\".\n let document: XIDDocument;\n try {\n document = XIDDocument.fromEnvelope(envelope, undefined, XIDVerifySignature.Inception);\n } catch (e) {\n throw new Error(\n `XID document must be signed by its inception key: ${(e as Error).message ?? String(e)}`,\n { cause: e },\n );\n }\n\n return [sanitized, document];\n}\n\n/**\n * Sanitize XID UR input.\n *\n * Port of `sanitize_xid_ur()` from participant_record.rs lines 196-203.\n */\nfunction sanitizeXidUr(input: string): string {\n const trimmed = input.trim();\n if (trimmed.length === 0) {\n throw new Error(\"XID document is required\");\n }\n return trimmed;\n}\n","/**\n * Copyright © 2023-2026 Blockchain Commons, LLC\n * Copyright © 2025-2026 Parity Technologies\n *\n *\n * Registry implementation for managing participants and groups.\n *\n * Port of registry/registry_impl.rs from frost-hubert-rust.\n *\n * @module\n */\n\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\n\nimport { type ARID, type PublicKeys, type XID } from \"@bcts/components\";\n\nimport { GroupRecord } from \"./group-record.js\";\nimport { OwnerRecord } from \"./owner-record.js\";\nimport { ParticipantRecord } from \"./participant-record.js\";\n\n/**\n * Outcome of adding a participant to the registry.\n *\n * Port of `enum AddOutcome` from registry_impl.rs.\n */\nexport enum AddOutcome {\n /** Participant was already present in the registry */\n AlreadyPresent = \"already_present\",\n /** Participant was successfully inserted */\n Inserted = \"inserted\",\n}\n\n/**\n * Outcome of setting the owner in the registry.\n *\n * Port of `enum OwnerOutcome` from registry_impl.rs.\n */\nexport enum OwnerOutcome {\n /** Owner was already present in the registry */\n AlreadyPresent = \"already_present\",\n /** Owner was successfully inserted */\n Inserted = \"inserted\",\n}\n\n/**\n * Outcome of recording a group in the registry.\n *\n * Port of `enum GroupOutcome` from registry_impl.rs.\n */\nexport enum GroupOutcome {\n /** Group was successfully inserted as new */\n Inserted = \"inserted\",\n /** Group already existed and was updated (contributions merged) */\n Updated = \"updated\",\n}\n\n/**\n * Registry for managing participants and groups.\n *\n * Port of `struct Registry` from registry_impl.rs lines 22-26.\n */\nexport class Registry {\n private _owner?: OwnerRecord | undefined;\n private readonly _participants: Map<string, ParticipantRecord>; // Map by XID UR string\n private readonly _groups: Map<string, GroupRecord>; // Map by ARID hex\n\n constructor() {\n this._owner = undefined;\n this._participants = new Map();\n this._groups = new Map();\n }\n\n /**\n * Get the owner record.\n */\n owner(): OwnerRecord | undefined {\n return this._owner;\n }\n\n /**\n * Set the owner record.\n *\n * Returns the outcome indicating whether the owner was already present or newly inserted.\n *\n * Port of `Registry::set_owner()` from registry_impl.rs.\n */\n setOwner(owner: OwnerRecord): OwnerOutcome {\n // Check for pet name conflicts with participants\n const petName = owner.petName();\n if (petName !== undefined) {\n const conflicting = this.participantByPetName(petName);\n if (conflicting?.[1].petName() === petName) {\n throw new Error(`Pet name '${petName}' already used by a participant`);\n }\n }\n\n if (this._owner === undefined) {\n this._owner = owner;\n return OwnerOutcome.Inserted;\n }\n\n const existing = this._owner;\n const existingXidUr = existing.xid().urString();\n const ownerXidUr = owner.xid().urString();\n\n if (\n existingXidUr === ownerXidUr &&\n existing.xidDocumentUr() === owner.xidDocumentUr() &&\n existing.petName() === owner.petName()\n ) {\n return OwnerOutcome.AlreadyPresent;\n }\n\n if (existingXidUr === ownerXidUr) {\n if (existing.xidDocumentUr() !== owner.xidDocumentUr()) {\n throw new Error(\"Owner already exists with different keys\");\n }\n this._owner = owner;\n return OwnerOutcome.Inserted;\n }\n\n throw new Error(`Owner already recorded for ${existing.xid().toString()}`);\n }\n\n /**\n * Get all participants.\n */\n participants(): Map<string, ParticipantRecord> {\n return this._participants;\n }\n\n /**\n * Get a participant by XID.\n */\n participant(xid: XID): ParticipantRecord | undefined {\n return this._participants.get(xid.urString());\n }\n\n /**\n * Add a participant.\n *\n * Mirrors Rust `Registry::add_participant`\n * (`registry_impl.rs:83-124`):\n *\n * 1. If `record.pet_name()` is already used by some other XID,\n * bail with `\"Pet name '{name}' already used by another\n * participant\"`.\n * 2. If `record.pet_name()` matches an existing record under the\n * *same* XID and the public keys also match, return\n * `AlreadyPresent`.\n * 3. If the pet name matches the same XID but public keys don't,\n * bail with `\"Participant already exists with a different pet\n * name\"`.\n * 4. Otherwise look up by XID. If present and public-keys + pet-name\n * both match, return `AlreadyPresent`; if XID is present but\n * anything differs, bail. If XID is new, insert and return\n * `Inserted`.\n *\n * The earlier port short-circuited on `participants.has(xidUr)` and\n * always returned `AlreadyPresent` — silently allowing re-adds with\n * a different pet name or different public keys, which Rust\n * correctly forbids.\n */\n addParticipant(xid: XID, record: ParticipantRecord): AddOutcome {\n const xidUr = xid.urString();\n const petName = record.petName();\n\n // Steps 1–3: pet-name conflict resolution.\n if (petName !== undefined) {\n for (const [existingXidUr, existingRecord] of this._participants) {\n if (existingRecord.petName() === petName) {\n if (existingXidUr !== xidUr) {\n throw new Error(`Pet name '${petName}' already used by another participant`);\n }\n if (publicKeysEqual(existingRecord.publicKeys(), record.publicKeys())) {\n return AddOutcome.AlreadyPresent;\n }\n throw new Error(\"Participant already exists with a different pet name\");\n }\n }\n }\n\n // Step 4: XID lookup.\n const existing = this._participants.get(xidUr);\n if (existing !== undefined) {\n if (\n publicKeysEqual(existing.publicKeys(), record.publicKeys()) &&\n existing.petName() === record.petName()\n ) {\n return AddOutcome.AlreadyPresent;\n }\n throw new Error(\"Participant already exists with a different pet name\");\n }\n\n this._participants.set(xidUr, record);\n return AddOutcome.Inserted;\n }\n\n /**\n * Check if a pet name is already used.\n */\n petNameExists(petName: string): boolean {\n for (const record of this._participants.values()) {\n if (record.petName() === petName) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Find a participant by pet name.\n *\n * Port of `Registry::participant_by_pet_name()` from registry_impl.rs.\n */\n participantByPetName(petName: string): [XID, ParticipantRecord] | undefined {\n for (const record of this._participants.values()) {\n if (record.petName() === petName) {\n return [record.xid(), record];\n }\n }\n return undefined;\n }\n\n /**\n * Get all groups.\n */\n groups(): Map<string, GroupRecord> {\n return this._groups;\n }\n\n /**\n * Get a group by ARID.\n */\n group(arid: ARID): GroupRecord | undefined {\n return this._groups.get(arid.hex());\n }\n\n /**\n * Get a mutable reference to a group by ARID.\n */\n groupMut(arid: ARID): GroupRecord | undefined {\n return this._groups.get(arid.hex());\n }\n\n /**\n * Record a group in the registry.\n *\n * If the group already exists:\n * - Validates that the config matches\n * - Merges contributions from the new record\n * - Updates verifying key if not already set\n *\n * Port of `Registry::record_group()` from registry_impl.rs.\n */\n recordGroup(groupId: ARID, record: GroupRecord): GroupOutcome {\n const key = groupId.hex();\n const existing = this._groups.get(key);\n\n if (existing !== undefined) {\n // Validate config matches\n if (!existing.configMatches(record)) {\n throw new Error(`Group ${groupId.hex()} already exists with a different configuration`);\n }\n\n // Merge contributions\n existing.mergeContributions(record.contributions());\n\n // Update verifying key if not already set\n const existingKey = existing.verifyingKey();\n const recordKey = record.verifyingKey();\n if (existingKey === undefined && recordKey !== undefined) {\n existing.setVerifyingKey(recordKey);\n } else if (\n existingKey !== undefined &&\n recordKey !== undefined &&\n existingKey.urString() !== recordKey.urString()\n ) {\n throw new Error(`Group ${groupId.hex()} already exists with a different verifying key`);\n }\n\n return GroupOutcome.Updated;\n }\n\n this._groups.set(key, record);\n return GroupOutcome.Inserted;\n }\n\n /**\n * Add a group (simple variant without merge logic).\n *\n * @deprecated Use recordGroup() for proper merge behavior.\n */\n addGroup(arid: ARID, record: GroupRecord): void {\n this._groups.set(arid.hex(), record);\n }\n\n /**\n * Load a registry from a file.\n */\n static load(filePath: string): Registry {\n if (!fs.existsSync(filePath)) {\n return new Registry();\n }\n\n const content = fs.readFileSync(filePath, \"utf-8\");\n const json = JSON.parse(content) as Record<string, unknown>;\n return Registry.fromJSON(json);\n }\n\n /**\n * Save the registry to a file.\n */\n save(filePath: string): void {\n const dir = path.dirname(filePath);\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir, { recursive: true });\n }\n\n const json = this.toJSON();\n fs.writeFileSync(filePath, JSON.stringify(json, null, 2));\n }\n\n /**\n * Serialize to JSON object.\n *\n * Mirrors Rust `Registry`'s field declaration order\n * (`registry_impl.rs:8-14` — `owner, participants, groups`). JSON\n * object member order is not semantically significant, but\n * `serde_json::to_string_pretty` emits keys in declaration order,\n * so for byte-equal `registry.json` (used by the integration tests\n * as a string assertion) the TS port must match Rust's order.\n * Empty `owner` is omitted via `Option::None` skip in Rust; we\n * reproduce that by only setting the key when the owner exists.\n */\n toJSON(): Record<string, unknown> {\n const obj: Record<string, unknown> = {};\n\n if (this._owner !== undefined) {\n obj[\"owner\"] = this._owner.toJSON();\n }\n\n const participants: Record<string, unknown> = {};\n for (const [xidUr, record] of this._participants) {\n participants[xidUr] = record.toJSON();\n }\n obj[\"participants\"] = participants;\n\n const groups: Record<string, unknown> = {};\n for (const [aridHex, record] of this._groups) {\n groups[aridHex] = record.toJSON();\n }\n obj[\"groups\"] = groups;\n\n return obj;\n }\n\n /**\n * Deserialize from JSON object.\n */\n static fromJSON(json: Record<string, unknown>): Registry {\n const registry = new Registry();\n\n if (json[\"owner\"] !== undefined) {\n registry._owner = OwnerRecord.fromJSON(json[\"owner\"] as Record<string, unknown>);\n }\n\n const participantsJson = json[\"participants\"] as\n | Record<string, Record<string, unknown>>\n | undefined;\n if (participantsJson !== undefined) {\n for (const [, recordJson] of Object.entries(participantsJson)) {\n const record = ParticipantRecord.fromJSON(recordJson);\n registry._participants.set(record.xid().urString(), record);\n }\n }\n\n const groupsJson = json[\"groups\"] as Record<string, Record<string, unknown>> | undefined;\n if (groupsJson !== undefined) {\n for (const [aridHex, recordJson] of Object.entries(groupsJson)) {\n const record = GroupRecord.fromJSON(recordJson);\n registry._groups.set(aridHex, record);\n }\n }\n\n return registry;\n }\n}\n\n/**\n * Resolve the registry file path from a given argument.\n *\n * Port of `resolve_registry_path()` from registry/mod.rs lines 49-78.\n */\nexport function resolveRegistryPath(registryArg: string | undefined, cwd: string): string {\n if (registryArg === undefined || registryArg === \"\") {\n return path.join(cwd, \"registry.json\");\n }\n\n // If it ends with / or is a directory, append registry.json\n if (registryArg.endsWith(\"/\") || registryArg.endsWith(path.sep)) {\n return path.join(cwd, registryArg, \"registry.json\");\n }\n\n // If it's just a filename, put it in cwd\n if (!registryArg.includes(\"/\") && !registryArg.includes(path.sep)) {\n return path.join(cwd, registryArg);\n }\n\n // Otherwise, treat as relative path\n return path.resolve(cwd, registryArg);\n}\n\n/**\n * Structural equality on `PublicKeys`, mirroring Rust's\n * `PartialEq::eq` derive (per-component comparison of the signing\n * and encapsulation public keys).\n *\n * @internal\n */\nfunction publicKeysEqual(a: PublicKeys, b: PublicKeys): boolean {\n return a.equals(b);\n}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