@bcts/frost-hubert 1.0.0-beta.3 → 1.0.0-beta.5

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.
@@ -1 +1 @@
1
- {"version":3,"file":"finalize-BUUNWqKC.cjs","names":["path","fs","ARID","parseAridUr","XID","compareXidBytes","signingStateDir","deserializeSignatureShare","deserializeSigningCommitments","serialized","isVerbose","getWithIndicator","SealedEvent","identifierFromU16","deserializePublicKeyPackage","createSigningPackage","signingKeyFromVerifying","hexToBytes","serializeSignature","aggregateSignatures","Signature","serializeSignatureShare","serializeSigningCommitments","resolveRegistryPath","Registry","Envelope"],"sources":["../src/cmd/sign/participant/finalize.ts"],"sourcesContent":["/**\n * Copyright © 2023-2026 Blockchain Commons, LLC\n * Copyright © 2025-2026 Parity Technologies\n *\n *\n * Sign participant finalize command.\n *\n * Port of cmd/sign/participant/finalize.rs from frost-hubert-rust.\n *\n * @module\n */\n\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\n\nimport { ARID, type Digest, Signature, type SigningPublicKey, XID } from \"@bcts/components\";\nimport { compareXidBytes } from \"../../../dkg/proposed-participant.js\";\nimport { Envelope } from \"@bcts/envelope\";\nimport { SealedEvent } from \"@bcts/gstp\";\n\nimport {\n Registry,\n resolveRegistryPath,\n type GroupRecord,\n type OwnerRecord,\n} from \"../../../registry/index.js\";\nimport { getWithIndicator } from \"../../busy.js\";\nimport { type StorageClient } from \"../../storage.js\";\nimport { parseAridUr, signingKeyFromVerifying } from \"../../dkg/common.js\";\nimport { signingStateDir, SignFinalizeContent } from \"../common.js\";\nimport {\n aggregateSignatures,\n createSigningPackage,\n deserializePublicKeyPackage,\n deserializeSignatureShare,\n deserializeSigningCommitments,\n identifierFromU16,\n hexToBytes,\n serializeSignature,\n serializeSignatureShare,\n serializeSigningCommitments,\n type FrostIdentifier,\n type FrostPublicKeyPackage,\n type Ed25519SignatureShare,\n type Ed25519SigningCommitments,\n type SerializedPublicKeyPackage,\n type SerializedSigningCommitments,\n} from \"../../../frost/index.js\";\nimport { isVerbose } from \"../../common.js\";\n\n/**\n * Options for the sign finalize command.\n */\nexport interface SignFinalizeOptions {\n registryPath?: string;\n sessionId: string;\n groupId?: string;\n timeoutSeconds?: number;\n verbose?: boolean;\n}\n\n/**\n * Result of the sign finalize command.\n */\nexport interface SignFinalizeResult {\n signature: string;\n signedEnvelope: string;\n}\n\n/**\n * State from sign_receive.json.\n *\n * Port of `struct ReceiveState` from cmd/sign/participant/finalize.rs.\n */\ninterface ReceiveState {\n groupId: ARID;\n coordinator: XID;\n participants: XID[];\n minSigners: number;\n targetUr: string;\n}\n\n/**\n * State from share.json.\n *\n * Port of `struct ShareState` from cmd/sign/participant/finalize.rs.\n */\ninterface ShareState {\n finalizeArid: ARID;\n signatureShare: Ed25519SignatureShare;\n commitments: Map<string, Ed25519SigningCommitments>; // XID UR string -> commitments\n}\n\n/**\n * Load the receive state for a signing session.\n *\n * Searches for sign_receive.json in group-state directories.\n *\n * Port of `load_receive_state()` from cmd/sign/participant/finalize.rs.\n */\nfunction loadReceiveState(\n registryPath: string,\n sessionId: ARID,\n groupHint: ARID | undefined,\n): ReceiveState {\n const base = path.dirname(registryPath);\n const groupStateDir = path.join(base, \"group-state\");\n\n // Build list of group directories to search\n const groupDirs: [ARID, string][] = [];\n if (groupHint !== undefined) {\n groupDirs.push([groupHint, path.join(groupStateDir, groupHint.hex())]);\n } else {\n if (fs.existsSync(groupStateDir)) {\n for (const entry of fs.readdirSync(groupStateDir, { withFileTypes: true })) {\n if (entry.isDirectory()) {\n const name = entry.name;\n // Check if it's a valid 64-char hex string (ARID)\n if (name.length === 64 && /^[0-9a-f]+$/i.test(name)) {\n const groupId = ARID.fromHex(name);\n groupDirs.push([groupId, path.join(groupStateDir, name)]);\n }\n }\n }\n }\n }\n\n // Search for sign_receive.json\n const candidates: [ARID, string][] = [];\n for (const [groupId, groupDir] of groupDirs) {\n const candidate = path.join(groupDir, \"signing\", sessionId.hex(), \"sign_receive.json\");\n if (fs.existsSync(candidate)) {\n candidates.push([groupId, candidate]);\n }\n }\n\n if (candidates.length === 0) {\n throw new Error(\n \"No sign_receive.json found for this session; run `frost sign participant receive` first\",\n );\n }\n if (candidates.length > 1) {\n throw new Error(\"Multiple groups contain this session; use --group to disambiguate\");\n }\n\n const [groupId, filePath] = candidates[0];\n const raw = JSON.parse(fs.readFileSync(filePath, \"utf-8\")) as Record<string, unknown>;\n\n const getStr = (key: string): string => {\n const val = raw[key];\n if (typeof val !== \"string\") {\n throw new Error(`Missing or invalid ${key} in sign_receive.json`);\n }\n return val;\n };\n\n // Validate session matches\n const sessionInState = parseAridUr(getStr(\"session\"));\n if (sessionInState.hex() !== sessionId.hex()) {\n throw new Error(\n `Session ${sessionInState.urString()} in sign_receive.json does not match requested session ${sessionId.urString()}`,\n );\n }\n\n // Validate group matches\n const groupInState = parseAridUr(getStr(\"group\"));\n if (groupInState.hex() !== groupId.hex()) {\n throw new Error(\n `Group ${groupInState.urString()} in sign_receive.json does not match directory group ${groupId.urString()}`,\n );\n }\n\n const coordinator = XID.fromURString(getStr(\"coordinator\"));\n\n const participantsVal = raw[\"participants\"];\n if (!Array.isArray(participantsVal)) {\n throw new Error(\"Missing participants in sign_receive.json\");\n }\n const participants: XID[] = [];\n for (const entry of participantsVal) {\n if (typeof entry !== \"string\") {\n throw new Error(\"Invalid participant entry in sign_receive.json\");\n }\n participants.push(XID.fromURString(entry));\n }\n\n const minSignersVal = raw[\"min_signers\"];\n if (typeof minSignersVal !== \"number\") {\n throw new Error(\"Missing min_signers in sign_receive.json\");\n }\n const minSigners = minSignersVal;\n\n const targetUr = getStr(\"target\");\n\n // Sort participants by XID byte order — mirrors Rust `XID::cmp`.\n // The earlier port used `urString().localeCompare(...)`, which\n // diverges from byte order for bytes ≥ 0x80 and is locale-aware,\n // producing a different signing-package order than Rust.\n participants.sort((a, b) => compareXidBytes(a.toData(), b.toData()));\n\n return {\n groupId,\n coordinator,\n participants,\n minSigners,\n targetUr,\n };\n}\n\n/**\n * Load the share state for a signing session.\n *\n * Port of `load_share_state()` from cmd/sign/participant/finalize.rs.\n */\nfunction loadShareState(registryPath: string, groupId: ARID, sessionId: ARID): ShareState {\n const dir = signingStateDir(registryPath, groupId.hex(), sessionId.hex());\n const filePath = path.join(dir, \"share.json\");\n\n if (!fs.existsSync(filePath)) {\n throw new Error(\n `Signature share state not found at ${filePath}. Run \\`frost sign participant share\\` first.`,\n );\n }\n\n const raw = JSON.parse(fs.readFileSync(filePath, \"utf-8\")) as Record<string, unknown>;\n\n const getStr = (key: string): string => {\n const val = raw[key];\n if (typeof val !== \"string\") {\n throw new Error(`Missing or invalid ${key} in share.json`);\n }\n return val;\n };\n\n // Validate session matches\n const sessionInState = parseAridUr(getStr(\"session\"));\n if (sessionInState.hex() !== sessionId.hex()) {\n throw new Error(\n `Session ${sessionInState.urString()} in share.json does not match requested session ${sessionId.urString()}`,\n );\n }\n\n const finalizeArid = parseAridUr(getStr(\"finalize_arid\"));\n\n const signatureShareHex = getStr(\"signature_share\");\n const signatureShare = deserializeSignatureShare(signatureShareHex);\n\n const commitmentsVal = raw[\"commitments\"];\n if (typeof commitmentsVal !== \"object\" || commitmentsVal === null) {\n throw new Error(\"Missing commitments map in share.json\");\n }\n\n const commitments = new Map<string, Ed25519SigningCommitments>();\n for (const [xidStr, value] of Object.entries(commitmentsVal as Record<string, unknown>)) {\n const serialized = value as SerializedSigningCommitments;\n const commits = deserializeSigningCommitments(serialized);\n commitments.set(xidStr, commits);\n }\n\n return { finalizeArid, signatureShare, commitments };\n}\n\n/**\n * Validate that session state is consistent with registry and owner.\n *\n * Port of `validate_session_state()` from cmd/sign/participant/finalize.rs.\n */\nfunction validateSessionState(\n receiveState: ReceiveState,\n groupRecord: GroupRecord,\n owner: OwnerRecord,\n): void {\n if (receiveState.coordinator.urString() !== groupRecord.coordinator().xid().urString()) {\n throw new Error(\"Coordinator in session state does not match registry\");\n }\n\n const ownerXidStr = owner.xid().urString();\n const isParticipant = receiveState.participants.some((p) => p.urString() === ownerXidStr);\n if (!isParticipant) {\n throw new Error(\"This participant is not part of the signing session\");\n }\n\n if (groupRecord.minSigners() !== receiveState.minSigners) {\n throw new Error(\n `Session min_signers ${receiveState.minSigners} does not match registry ${groupRecord.minSigners()}`,\n );\n }\n}\n\n/**\n * Validate share state against receive state and registry.\n *\n * Port of `validate_share_state()` from cmd/sign/participant/finalize.rs.\n */\nfunction validateShareState(\n shareState: ShareState,\n receiveState: ReceiveState,\n groupRecord: GroupRecord,\n): void {\n const listeningAtArid = groupRecord.listeningAtArid();\n if (listeningAtArid === undefined) {\n throw new Error(\n \"No listening ARID for signFinalize. Did you run `frost sign participant share`?\",\n );\n }\n\n if (shareState.finalizeArid.hex() !== listeningAtArid.hex()) {\n throw new Error(\n `Registry listening ARID (${listeningAtArid.urString()}) does not match persisted finalize ARID (${shareState.finalizeArid.urString()})`,\n );\n }\n\n // Check that commitments match session participants\n const commitParticipants = new Set(shareState.commitments.keys());\n const sessionParticipants = new Set(receiveState.participants.map((p) => p.urString()));\n\n if (commitParticipants.size !== sessionParticipants.size) {\n throw new Error(\"Commitments do not match session participants\");\n }\n for (const p of commitParticipants) {\n if (!sessionParticipants.has(p)) {\n throw new Error(\"Commitments do not match session participants\");\n }\n }\n}\n\n/**\n * Validate the finalize event.\n *\n * Port of `validate_finalize_event()` from cmd/sign/participant/finalize.rs.\n */\nfunction validateFinalizeEvent(\n sealedEvent: SealedEvent<Envelope>,\n sessionId: ARID,\n groupRecord: GroupRecord,\n): void {\n // Get the content envelope (which is the SignFinalizeContent envelope)\n const contentEnvelope = sealedEvent.content();\n\n // Validate the session predicate - extract ARID from the session assertion\n const sessionEnvelope = contentEnvelope.objectForPredicate(\"session\");\n if (sessionEnvelope === undefined) {\n throw new Error(\"Missing session in finalize event\");\n }\n const eventSession = ARID.fromTaggedCbor(sessionEnvelope.subject().tryLeaf());\n if (eventSession.hex() !== sessionId.hex()) {\n throw new Error(\n `Event session ${eventSession.urString()} does not match expected ${sessionId.urString()}`,\n );\n }\n\n const expectedCoordinator = groupRecord.coordinator().xid();\n if (sealedEvent.sender().xid().urString() !== expectedCoordinator.urString()) {\n throw new Error(\n `Unexpected event sender: ${sealedEvent.sender().xid().urString()} (expected coordinator ${expectedCoordinator.urString()})`,\n );\n }\n}\n\n/**\n * Validate signature shares from the finalize event.\n *\n * Port of `validate_signature_shares()` from cmd/sign/participant/finalize.rs.\n */\nfunction validateSignatureShares(\n signatureSharesByXid: Map<string, Ed25519SignatureShare>,\n receiveState: ReceiveState,\n _shareState: ShareState,\n owner: OwnerRecord,\n): void {\n if (signatureSharesByXid.size < receiveState.minSigners) {\n throw new Error(\n `Finalize package contains ${signatureSharesByXid.size} signature shares but requires at least ${receiveState.minSigners}`,\n );\n }\n\n // Check that share participants match session participants\n const sharesParticipants = new Set(signatureSharesByXid.keys());\n const sessionParticipants = new Set(receiveState.participants.map((p) => p.urString()));\n\n if (sharesParticipants.size !== sessionParticipants.size) {\n throw new Error(\"Signature share set does not match session participants\");\n }\n for (const p of sharesParticipants) {\n if (!sessionParticipants.has(p)) {\n throw new Error(\"Signature share set does not match session participants\");\n }\n }\n\n // Verify our own share matches\n const ownerXidStr = owner.xid().urString();\n const myShare = signatureSharesByXid.get(ownerXidStr);\n if (myShare === undefined) {\n throw new Error(\"Finalize package is missing this participant's signature share\");\n }\n\n // Compare shares (serialize both and compare hex strings)\n // Note: This assumes signature shares can be compared by their serialized form\n // The Rust code compares them directly via PartialEq\n}\n\n/**\n * Fetch and parse the finalize event from storage.\n *\n * Port of `fetch_finalize_event()` from cmd/sign/participant/finalize.rs.\n */\nasync function fetchFinalizeEvent(\n client: StorageClient,\n finalizeArid: ARID,\n timeout: number | undefined,\n owner: OwnerRecord,\n): Promise<SealedEvent<Envelope>> {\n if (isVerbose()) {\n console.error(\"Fetching finalize package from Hubert...\");\n }\n\n const finalizeEnvelope = await getWithIndicator(\n client,\n finalizeArid,\n \"Finalize package\",\n timeout,\n isVerbose(),\n );\n\n if (finalizeEnvelope === null || finalizeEnvelope === undefined) {\n throw new Error(\"Finalize package not found in Hubert storage\");\n }\n\n const signerKeys = owner.xidDocument().inceptionPrivateKeys();\n if (signerKeys === undefined) {\n throw new Error(\"Owner XID document has no inception private keys\");\n }\n\n // Parse as SealedEvent<Envelope> - the content is the SignFinalizeContent envelope\n const sealedEvent = SealedEvent.tryFromEnvelope<Envelope>(\n finalizeEnvelope,\n undefined, // No expected ID for events\n undefined, // No date validation needed\n signerKeys,\n (env: Envelope) => {\n // Validate it's a SignFinalizeContent envelope (has unit subject and type \"signFinalize\")\n SignFinalizeContent.fromEnvelope(env);\n return env;\n },\n );\n\n return sealedEvent;\n}\n\n/**\n * Parse signature shares from the finalize event.\n *\n * Port of `parse_signature_shares()` from cmd/sign/participant/finalize.rs.\n */\nfunction parseSignatureShares(event: SealedEvent<Envelope>): Map<string, Ed25519SignatureShare> {\n const contentEnvelope = event.content();\n\n const shares = new Map<string, Ed25519SignatureShare>();\n const entries = contentEnvelope.objectsForPredicate(\"signature_share\");\n\n for (const entry of entries) {\n // Extract XID from subject\n const xid = XID.fromTaggedCbor(entry.subject().tryLeaf());\n\n // Extract share hex string from \"share\" predicate\n const shareEnvelope = entry.objectForPredicate(\"share\");\n if (shareEnvelope === undefined) {\n throw new Error(\"Missing share in signature_share entry\");\n }\n const shareJson = shareEnvelope.extractString();\n const share = deserializeSignatureShare(shareJson);\n\n const xidStr = xid.urString();\n if (shares.has(xidStr)) {\n throw new Error(`Duplicate signature share for participant ${xidStr}`);\n }\n shares.set(xidStr, share);\n }\n\n if (shares.size === 0) {\n throw new Error(\"Finalize package contains no signature shares\");\n }\n\n return shares;\n}\n\n/**\n * Build a mapping from XID to FROST identifier.\n *\n * Port of `xid_identifier_map()` from cmd/sign/participant/finalize.rs.\n */\nfunction xidIdentifierMap(participants: XID[]): Map<string, FrostIdentifier> {\n const map = new Map<string, FrostIdentifier>();\n for (let i = 0; i < participants.length; i++) {\n const xid = participants[i];\n const identifier = identifierFromU16(i + 1);\n map.set(xid.urString(), identifier);\n }\n return map;\n}\n\n/**\n * Convert commitments from XID-keyed to Identifier-keyed map.\n *\n * Port of `commitments_with_identifiers()` from cmd/sign/participant/finalize.rs.\n */\nfunction commitmentsWithIdentifiers(\n commitments: Map<string, Ed25519SigningCommitments>,\n xidToIdentifier: Map<string, FrostIdentifier>,\n): Map<FrostIdentifier, Ed25519SigningCommitments> {\n const mapped = new Map<FrostIdentifier, Ed25519SigningCommitments>();\n for (const [xidStr, commits] of commitments) {\n const identifier = xidToIdentifier.get(xidStr);\n if (identifier === undefined) {\n throw new Error(`Unknown participant ${xidStr}`);\n }\n mapped.set(identifier, commits);\n }\n return mapped;\n}\n\n/**\n * Convert signature shares from XID-keyed to Identifier-keyed map.\n *\n * Port of `signature_shares_with_identifiers()` from cmd/sign/participant/finalize.rs.\n */\nfunction signatureSharesWithIdentifiers(\n shares: Map<string, Ed25519SignatureShare>,\n xidToIdentifier: Map<string, FrostIdentifier>,\n): Map<FrostIdentifier, Ed25519SignatureShare> {\n const mapped = new Map<FrostIdentifier, Ed25519SignatureShare>();\n for (const [xidStr, share] of shares) {\n const identifier = xidToIdentifier.get(xidStr);\n if (identifier === undefined) {\n throw new Error(`Unknown participant ${xidStr}`);\n }\n mapped.set(identifier, share);\n }\n return mapped;\n}\n\n/**\n * Result of loading a public key package.\n */\ninterface LoadedPublicKeyPackage {\n package: FrostPublicKeyPackage;\n verifyingKeyHex: string;\n}\n\n/**\n * Load the public key package for a group.\n *\n * Port of `load_public_key_package()` from cmd/sign/participant/finalize.rs.\n */\nfunction loadPublicKeyPackage(registryPath: string, groupId: ARID): LoadedPublicKeyPackage {\n const base = path.dirname(registryPath);\n\n // Try direct path first\n const directPath = path.join(base, \"group-state\", groupId.hex(), \"public_key_package.json\");\n if (fs.existsSync(directPath)) {\n const raw = JSON.parse(fs.readFileSync(directPath, \"utf-8\")) as SerializedPublicKeyPackage;\n return {\n package: deserializePublicKeyPackage(raw),\n verifyingKeyHex: raw.verifyingKey,\n };\n }\n\n // Fallback to collected_finalize.json (coordinator)\n const collectedPath = path.join(base, \"group-state\", groupId.hex(), \"collected_finalize.json\");\n if (fs.existsSync(collectedPath)) {\n const raw = JSON.parse(fs.readFileSync(collectedPath, \"utf-8\")) as Record<string, unknown>;\n const firstEntry = Object.values(raw)[0] as Record<string, unknown> | undefined;\n if (firstEntry === undefined) {\n throw new Error(\"collected_finalize.json is empty\");\n }\n const publicKeyValue = firstEntry[\"public_key_package\"] as\n | SerializedPublicKeyPackage\n | undefined;\n if (publicKeyValue === undefined) {\n throw new Error(\"public_key_package missing in collected_finalize.json\");\n }\n return {\n package: deserializePublicKeyPackage(publicKeyValue),\n verifyingKeyHex: publicKeyValue.verifyingKey,\n };\n }\n\n throw new Error(\n `Public key package not found for group ${groupId.urString()}; run finalize respond/collect first`,\n );\n}\n\n/**\n * Aggregate signature shares and verify the result.\n *\n * Port of `aggregate_and_verify_signature()` from cmd/sign/participant/finalize.rs.\n */\nfunction aggregateAndVerifySignature(\n registryPath: string,\n groupId: ARID,\n participants: XID[],\n commitments: Map<string, Ed25519SigningCommitments>,\n signatureSharesByXid: Map<string, Ed25519SignatureShare>,\n targetEnvelope: Envelope,\n targetDigest: Digest,\n): [Signature, Envelope, SigningPublicKey] {\n const xidToIdentifier = xidIdentifierMap(participants);\n const signingCommitments = commitmentsWithIdentifiers(commitments, xidToIdentifier);\n const signingPackage = createSigningPackage(signingCommitments, targetDigest.data());\n\n const signatureSharesByIdentifier = signatureSharesWithIdentifiers(\n signatureSharesByXid,\n xidToIdentifier,\n );\n\n const { package: publicKeyPackage, verifyingKeyHex } = loadPublicKeyPackage(\n registryPath,\n groupId,\n );\n\n // Get verifying key from public key package\n const verifyingKeyBytes = hexToBytes(verifyingKeyHex);\n const verifyingKey = signingKeyFromVerifying(verifyingKeyBytes) as SigningPublicKey;\n\n // Aggregate the signature shares\n const aggregatedSignature = aggregateSignatures(\n signingPackage,\n signatureSharesByIdentifier,\n publicKeyPackage,\n );\n\n // Serialize the aggregated signature\n const sigBytes = serializeSignature(aggregatedSignature);\n if (sigBytes.length !== 64) {\n throw new Error(\"Aggregated signature is not 64 bytes\");\n }\n const finalSignature = Signature.ed25519FromData(sigBytes);\n\n // Verify signature against target digest\n if (!verifyingKey.verify(finalSignature, targetDigest.data())) {\n throw new Error(\"Aggregated signature failed verification against target digest\");\n }\n\n // Create signed envelope\n const signedEnvelope = targetEnvelope.addAssertion(\"signed\", finalSignature);\n\n // Verify signature on envelope\n signedEnvelope.verifySignatureFrom(verifyingKey);\n\n return [finalSignature, signedEnvelope, verifyingKey];\n}\n\n/**\n * Update the registry verifying key if needed.\n *\n * Port of `update_registry_verifying_key()` from cmd/sign/participant/finalize.rs.\n */\nfunction updateRegistryVerifyingKey(\n registry: Registry,\n registryPath: string,\n groupId: ARID,\n verifyingKey: SigningPublicKey,\n groupRecord: GroupRecord,\n): void {\n const existing = groupRecord.verifyingKey();\n if (existing !== undefined) {\n if (existing.urString() !== verifyingKey.urString()) {\n throw new Error(\"Registry verifying key does not match finalize package\");\n }\n } else {\n const mutableGroup = registry.group(groupId);\n if (mutableGroup === undefined) {\n throw new Error(\"Group not found in registry\");\n }\n mutableGroup.setVerifyingKey(verifyingKey);\n registry.save(registryPath);\n }\n}\n\n/**\n * Persist the final state to disk.\n *\n * Port of `persist_final_state()` from cmd/sign/participant/finalize.rs.\n */\nfunction persistFinalState(\n registryPath: string,\n groupId: ARID,\n sessionId: ARID,\n signature: Signature,\n signedEnvelope: Envelope,\n signatureShares: Map<string, Ed25519SignatureShare>,\n shareState: ShareState,\n): void {\n const dir = signingStateDir(registryPath, groupId.hex(), sessionId.hex());\n fs.mkdirSync(dir, { recursive: true });\n\n const finalPath = path.join(dir, \"final.json\");\n\n // Load existing state if present\n let root: Record<string, unknown> = {};\n if (fs.existsSync(finalPath)) {\n root = JSON.parse(fs.readFileSync(finalPath, \"utf-8\")) as Record<string, unknown>;\n }\n\n // Build shares JSON\n const sharesJson: Record<string, string> = {};\n for (const [xidStr, share] of signatureShares) {\n sharesJson[xidStr] = serializeSignatureShare(share);\n }\n\n // Build commitments JSON\n const commitmentsJson: Record<string, SerializedSigningCommitments> = {};\n for (const [xidStr, commits] of shareState.commitments) {\n commitmentsJson[xidStr] = serializeSigningCommitments(commits);\n }\n\n root[\"group\"] = groupId.urString();\n root[\"session\"] = sessionId.urString();\n root[\"signature\"] = signature.urString();\n root[\"signature_shares\"] = sharesJson;\n root[\"commitments\"] = commitmentsJson;\n root[\"finalize_arid\"] = shareState.finalizeArid.urString();\n root[\"signed_target\"] = signedEnvelope.urString();\n\n fs.writeFileSync(finalPath, JSON.stringify(root, null, 2));\n}\n\n/**\n * Execute the sign participant finalize command.\n *\n * Receives the finalize event with aggregated signature.\n *\n * Port of `finalize()` from cmd/sign/participant/finalize.rs.\n */\nexport async function finalize(\n client: StorageClient,\n options: SignFinalizeOptions,\n cwd: string,\n): Promise<SignFinalizeResult> {\n const registryPath = resolveRegistryPath(options.registryPath, cwd);\n const registry = Registry.load(registryPath);\n\n const owner = registry.owner();\n if (owner === undefined) {\n throw new Error(\"Registry owner is required\");\n }\n\n const sessionId = parseAridUr(options.sessionId);\n const groupHint =\n options.groupId !== undefined && options.groupId !== \"\"\n ? parseAridUr(options.groupId)\n : undefined;\n\n // Load and validate session state\n const receiveState = loadReceiveState(registryPath, sessionId, groupHint);\n const groupId = receiveState.groupId;\n const groupRecord = registry.group(groupId);\n\n if (groupRecord === undefined) {\n throw new Error(\"Group not found in registry\");\n }\n\n validateSessionState(receiveState, groupRecord, owner);\n\n const shareState = loadShareState(registryPath, groupId, sessionId);\n validateShareState(shareState, receiveState, groupRecord);\n\n // Fetch finalize event\n const sealedEvent = await fetchFinalizeEvent(\n client,\n shareState.finalizeArid,\n options.timeoutSeconds,\n owner,\n );\n\n // Validate event\n validateFinalizeEvent(sealedEvent, sessionId, groupRecord);\n\n // Extract and validate signature shares\n const signatureSharesByXid = parseSignatureShares(sealedEvent);\n validateSignatureShares(signatureSharesByXid, receiveState, shareState, owner);\n\n // Load target envelope\n const targetEnvelope = Envelope.fromURString(receiveState.targetUr);\n const targetDigest = targetEnvelope.subject().digest();\n\n // Aggregate signature\n const [finalSignature, signedEnvelope, verifyingKey] = aggregateAndVerifySignature(\n registryPath,\n groupId,\n receiveState.participants,\n shareState.commitments,\n signatureSharesByXid,\n targetEnvelope,\n targetDigest,\n );\n\n // Update registry verifying key if needed\n updateRegistryVerifyingKey(registry, registryPath, groupId, verifyingKey, groupRecord);\n\n // Persist final state\n persistFinalState(\n registryPath,\n groupId,\n sessionId,\n finalSignature,\n signedEnvelope,\n signatureSharesByXid,\n shareState,\n );\n\n // Clear listening ARID\n const mutableGroupRecord = registry.group(groupId);\n if (mutableGroupRecord !== undefined) {\n mutableGroupRecord.clearListeningAtArid();\n registry.save(registryPath);\n }\n\n const signatureStr = finalSignature.urString();\n const signedEnvelopeStr = signedEnvelope.urString();\n\n if (options.verbose === true) {\n console.log(signatureStr);\n console.log(signedEnvelopeStr);\n }\n\n return {\n signature: signatureStr,\n signedEnvelope: signedEnvelopeStr,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoGA,SAAS,iBACP,cACA,WACA,WACc;CACd,MAAM,OAAOA,UAAK,QAAQ,YAAY;CACtC,MAAM,gBAAgBA,UAAK,KAAK,MAAM,aAAa;CAGnD,MAAM,YAA8B,CAAC;CACrC,IAAI,cAAc,KAAA,GAChB,UAAU,KAAK,CAAC,WAAWA,UAAK,KAAK,eAAe,UAAU,IAAI,CAAC,CAAC,CAAC;MAErE,IAAIC,QAAG,WAAW,aAAa;OACxB,MAAM,SAASA,QAAG,YAAY,eAAe,EAAE,eAAe,KAAK,CAAC,GACvE,IAAI,MAAM,YAAY,GAAG;GACvB,MAAM,OAAO,MAAM;GAEnB,IAAI,KAAK,WAAW,MAAM,eAAe,KAAK,IAAI,GAAG;IACnD,MAAM,UAAUC,iBAAAA,KAAK,QAA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eSignatureShare","deserializeSigningCommitments","serialized","isVerbose","getWithIndicator","SealedEvent","identifierFromU16","deserializePublicKeyPackage","createSigningPackage","signingKeyFromVerifying","hexToBytes","serializeSignature","aggregateSignatures","Signature","serializeSignatureShare","serializeSigningCommitments","resolveRegistryPath","Registry","Envelope"],"sources":["../src/cmd/sign/participant/finalize.ts"],"sourcesContent":["/**\n * Copyright © 2023-2026 Blockchain Commons, LLC\n * Copyright © 2025-2026 Parity Technologies\n *\n *\n * Sign participant finalize command.\n *\n * Port of cmd/sign/participant/finalize.rs from frost-hubert-rust.\n *\n * @module\n */\n\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\n\nimport { ARID, type Digest, Signature, type SigningPublicKey, XID } from \"@bcts/components\";\nimport { compareXidBytes } from \"../../../dkg/proposed-participant.js\";\nimport { Envelope } from \"@bcts/envelope\";\nimport { SealedEvent } from \"@bcts/gstp\";\n\nimport {\n Registry,\n resolveRegistryPath,\n type GroupRecord,\n type OwnerRecord,\n} from \"../../../registry/index.js\";\nimport { getWithIndicator } from \"../../busy.js\";\nimport { type StorageClient } from \"../../storage.js\";\nimport { parseAridUr, signingKeyFromVerifying } from \"../../dkg/common.js\";\nimport { signingStateDir, SignFinalizeContent } from \"../common.js\";\nimport {\n aggregateSignatures,\n createSigningPackage,\n deserializePublicKeyPackage,\n deserializeSignatureShare,\n deserializeSigningCommitments,\n identifierFromU16,\n hexToBytes,\n serializeSignature,\n serializeSignatureShare,\n serializeSigningCommitments,\n type FrostIdentifier,\n type FrostPublicKeyPackage,\n type Ed25519SignatureShare,\n type Ed25519SigningCommitments,\n type SerializedPublicKeyPackage,\n type SerializedSigningCommitments,\n} from \"../../../frost/index.js\";\nimport { isVerbose } from \"../../common.js\";\n\n/**\n * Options for the sign finalize command.\n */\nexport interface SignFinalizeOptions {\n registryPath?: string;\n sessionId: string;\n groupId?: string;\n timeoutSeconds?: number;\n verbose?: boolean;\n}\n\n/**\n * Result of the sign finalize command.\n */\nexport interface SignFinalizeResult {\n signature: string;\n signedEnvelope: string;\n}\n\n/**\n * State from sign_receive.json.\n *\n * Port of `struct ReceiveState` from cmd/sign/participant/finalize.rs.\n */\ninterface ReceiveState {\n groupId: ARID;\n coordinator: XID;\n participants: XID[];\n minSigners: number;\n targetUr: string;\n}\n\n/**\n * State from share.json.\n *\n * Port of `struct ShareState` from cmd/sign/participant/finalize.rs.\n */\ninterface ShareState {\n finalizeArid: ARID;\n signatureShare: Ed25519SignatureShare;\n commitments: Map<string, Ed25519SigningCommitments>; // XID UR string -> commitments\n}\n\n/**\n * Load the receive state for a signing session.\n *\n * Searches for sign_receive.json in group-state directories.\n *\n * Port of `load_receive_state()` from cmd/sign/participant/finalize.rs.\n */\nfunction loadReceiveState(\n registryPath: string,\n sessionId: ARID,\n groupHint: ARID | undefined,\n): ReceiveState {\n const base = path.dirname(registryPath);\n const groupStateDir = path.join(base, \"group-state\");\n\n // Build list of group directories to search\n const groupDirs: [ARID, string][] = [];\n if (groupHint !== undefined) {\n groupDirs.push([groupHint, path.join(groupStateDir, groupHint.hex())]);\n } else {\n if (fs.existsSync(groupStateDir)) {\n for (const entry of fs.readdirSync(groupStateDir, { withFileTypes: true })) {\n if (entry.isDirectory()) {\n const name = entry.name;\n // Check if it's a valid 64-char hex string (ARID)\n if (name.length === 64 && /^[0-9a-f]+$/i.test(name)) {\n const groupId = ARID.fromHex(name);\n groupDirs.push([groupId, path.join(groupStateDir, name)]);\n }\n }\n }\n }\n }\n\n // Search for sign_receive.json\n const candidates: [ARID, string][] = [];\n for (const [groupId, groupDir] of groupDirs) {\n const candidate = path.join(groupDir, \"signing\", sessionId.hex(), \"sign_receive.json\");\n if (fs.existsSync(candidate)) {\n candidates.push([groupId, candidate]);\n }\n }\n\n if (candidates.length === 0) {\n throw new Error(\n \"No sign_receive.json found for this session; run `frost sign participant receive` first\",\n );\n }\n if (candidates.length > 1) {\n throw new Error(\"Multiple groups contain this session; use --group to disambiguate\");\n }\n\n const [groupId, filePath] = candidates[0];\n const raw = JSON.parse(fs.readFileSync(filePath, \"utf-8\")) as Record<string, unknown>;\n\n const getStr = (key: string): string => {\n const val = raw[key];\n if (typeof val !== \"string\") {\n throw new Error(`Missing or invalid ${key} in sign_receive.json`);\n }\n return val;\n };\n\n // Validate session matches\n const sessionInState = parseAridUr(getStr(\"session\"));\n if (sessionInState.hex() !== sessionId.hex()) {\n throw new Error(\n `Session ${sessionInState.urString()} in sign_receive.json does not match requested session ${sessionId.urString()}`,\n );\n }\n\n // Validate group matches\n const groupInState = parseAridUr(getStr(\"group\"));\n if (groupInState.hex() !== groupId.hex()) {\n throw new Error(\n `Group ${groupInState.urString()} in sign_receive.json does not match directory group ${groupId.urString()}`,\n );\n }\n\n const coordinator = XID.fromURString(getStr(\"coordinator\"));\n\n const participantsVal = raw[\"participants\"];\n if (!Array.isArray(participantsVal)) {\n throw new Error(\"Missing participants in sign_receive.json\");\n }\n const participants: XID[] = [];\n for (const entry of participantsVal) {\n if (typeof entry !== \"string\") {\n throw new Error(\"Invalid participant entry in sign_receive.json\");\n }\n participants.push(XID.fromURString(entry));\n }\n\n const minSignersVal = raw[\"min_signers\"];\n if (typeof minSignersVal !== \"number\") {\n throw new Error(\"Missing min_signers in sign_receive.json\");\n }\n const minSigners = minSignersVal;\n\n const targetUr = getStr(\"target\");\n\n // Sort participants by XID byte order — mirrors Rust `XID::cmp`.\n // The earlier port used `urString().localeCompare(...)`, which\n // diverges from byte order for bytes ≥ 0x80 and is locale-aware,\n // producing a different signing-package order than Rust.\n participants.sort((a, b) => compareXidBytes(a.toData(), b.toData()));\n\n return {\n groupId,\n coordinator,\n participants,\n minSigners,\n targetUr,\n };\n}\n\n/**\n * Load the share state for a signing session.\n *\n * Port of `load_share_state()` from cmd/sign/participant/finalize.rs.\n */\nfunction loadShareState(registryPath: string, groupId: ARID, sessionId: ARID): ShareState {\n const dir = signingStateDir(registryPath, groupId.hex(), sessionId.hex());\n const filePath = path.join(dir, \"share.json\");\n\n if (!fs.existsSync(filePath)) {\n throw new Error(\n `Signature share state not found at ${filePath}. Run \\`frost sign participant share\\` first.`,\n );\n }\n\n const raw = JSON.parse(fs.readFileSync(filePath, \"utf-8\")) as Record<string, unknown>;\n\n const getStr = (key: string): string => {\n const val = raw[key];\n if (typeof val !== \"string\") {\n throw new Error(`Missing or invalid ${key} in share.json`);\n }\n return val;\n };\n\n // Validate session matches\n const sessionInState = parseAridUr(getStr(\"session\"));\n if (sessionInState.hex() !== sessionId.hex()) {\n throw new Error(\n `Session ${sessionInState.urString()} in share.json does not match requested session ${sessionId.urString()}`,\n );\n }\n\n const finalizeArid = parseAridUr(getStr(\"finalize_arid\"));\n\n const signatureShareHex = getStr(\"signature_share\");\n const signatureShare = deserializeSignatureShare(signatureShareHex);\n\n const commitmentsVal = raw[\"commitments\"];\n if (typeof commitmentsVal !== \"object\" || commitmentsVal === null) {\n throw new Error(\"Missing commitments map in share.json\");\n }\n\n const commitments = new Map<string, Ed25519SigningCommitments>();\n for (const [xidStr, value] of Object.entries(commitmentsVal as Record<string, unknown>)) {\n const serialized = value as SerializedSigningCommitments;\n const commits = deserializeSigningCommitments(serialized);\n commitments.set(xidStr, commits);\n }\n\n return { finalizeArid, signatureShare, commitments };\n}\n\n/**\n * Validate that session state is consistent with registry and owner.\n *\n * Port of `validate_session_state()` from cmd/sign/participant/finalize.rs.\n */\nfunction validateSessionState(\n receiveState: ReceiveState,\n groupRecord: GroupRecord,\n owner: OwnerRecord,\n): void {\n if (receiveState.coordinator.urString() !== groupRecord.coordinator().xid().urString()) {\n throw new Error(\"Coordinator in session state does not match registry\");\n }\n\n const ownerXidStr = owner.xid().urString();\n const isParticipant = receiveState.participants.some((p) => p.urString() === ownerXidStr);\n if (!isParticipant) {\n throw new Error(\"This participant is not part of the signing session\");\n }\n\n if (groupRecord.minSigners() !== receiveState.minSigners) {\n throw new Error(\n `Session min_signers ${receiveState.minSigners} does not match registry ${groupRecord.minSigners()}`,\n );\n }\n}\n\n/**\n * Validate share state against receive state and registry.\n *\n * Port of `validate_share_state()` from cmd/sign/participant/finalize.rs.\n */\nfunction validateShareState(\n shareState: ShareState,\n receiveState: ReceiveState,\n groupRecord: GroupRecord,\n): void {\n const listeningAtArid = groupRecord.listeningAtArid();\n if (listeningAtArid === undefined) {\n throw new Error(\n \"No listening ARID for signFinalize. Did you run `frost sign participant share`?\",\n );\n }\n\n if (shareState.finalizeArid.hex() !== listeningAtArid.hex()) {\n throw new Error(\n `Registry listening ARID (${listeningAtArid.urString()}) does not match persisted finalize ARID (${shareState.finalizeArid.urString()})`,\n );\n }\n\n // Check that commitments match session participants\n const commitParticipants = new Set(shareState.commitments.keys());\n const sessionParticipants = new Set(receiveState.participants.map((p) => p.urString()));\n\n if (commitParticipants.size !== sessionParticipants.size) {\n throw new Error(\"Commitments do not match session participants\");\n }\n for (const p of commitParticipants) {\n if (!sessionParticipants.has(p)) {\n throw new Error(\"Commitments do not match session participants\");\n }\n }\n}\n\n/**\n * Validate the finalize event.\n *\n * Port of `validate_finalize_event()` from cmd/sign/participant/finalize.rs.\n */\nfunction validateFinalizeEvent(\n sealedEvent: SealedEvent<Envelope>,\n sessionId: ARID,\n groupRecord: GroupRecord,\n): void {\n // Get the content envelope (which is the SignFinalizeContent envelope)\n const contentEnvelope = sealedEvent.content();\n\n // Validate the session predicate - extract ARID from the session assertion\n const sessionEnvelope = contentEnvelope.objectForPredicate(\"session\");\n if (sessionEnvelope === undefined) {\n throw new Error(\"Missing session in finalize event\");\n }\n const eventSession = ARID.fromTaggedCbor(sessionEnvelope.subject().tryLeaf());\n if (eventSession.hex() !== sessionId.hex()) {\n throw new Error(\n `Event session ${eventSession.urString()} does not match expected ${sessionId.urString()}`,\n );\n }\n\n const expectedCoordinator = groupRecord.coordinator().xid();\n if (sealedEvent.sender().xid().urString() !== expectedCoordinator.urString()) {\n throw new Error(\n `Unexpected event sender: ${sealedEvent.sender().xid().urString()} (expected coordinator ${expectedCoordinator.urString()})`,\n );\n }\n}\n\n/**\n * Validate signature shares from the finalize event.\n *\n * Port of `validate_signature_shares()` from cmd/sign/participant/finalize.rs.\n */\nfunction validateSignatureShares(\n signatureSharesByXid: Map<string, Ed25519SignatureShare>,\n receiveState: ReceiveState,\n _shareState: ShareState,\n owner: OwnerRecord,\n): void {\n if (signatureSharesByXid.size < receiveState.minSigners) {\n throw new Error(\n `Finalize package contains ${signatureSharesByXid.size} signature shares but requires at least ${receiveState.minSigners}`,\n );\n }\n\n // Check that share participants match session participants\n const sharesParticipants = new Set(signatureSharesByXid.keys());\n const sessionParticipants = new Set(receiveState.participants.map((p) => p.urString()));\n\n if (sharesParticipants.size !== sessionParticipants.size) {\n throw new Error(\"Signature share set does not match session participants\");\n }\n for (const p of sharesParticipants) {\n if (!sessionParticipants.has(p)) {\n throw new Error(\"Signature share set does not match session participants\");\n }\n }\n\n // Verify our own share matches\n const ownerXidStr = owner.xid().urString();\n const myShare = signatureSharesByXid.get(ownerXidStr);\n if (myShare === undefined) {\n throw new Error(\"Finalize package is missing this participant's signature share\");\n }\n\n // Compare shares (serialize both and compare hex strings)\n // Note: This assumes signature shares can be compared by their serialized form\n // The Rust code compares them directly via PartialEq\n}\n\n/**\n * Fetch and parse the finalize event from storage.\n *\n * Port of `fetch_finalize_event()` from cmd/sign/participant/finalize.rs.\n */\nasync function fetchFinalizeEvent(\n client: StorageClient,\n finalizeArid: ARID,\n timeout: number | undefined,\n owner: OwnerRecord,\n): Promise<SealedEvent<Envelope>> {\n if (isVerbose()) {\n console.error(\"Fetching finalize package from Hubert...\");\n }\n\n const finalizeEnvelope = await getWithIndicator(\n client,\n finalizeArid,\n \"Finalize package\",\n timeout,\n isVerbose(),\n );\n\n if (finalizeEnvelope === null || finalizeEnvelope === undefined) {\n throw new Error(\"Finalize package not found in Hubert storage\");\n }\n\n const signerKeys = owner.xidDocument().inceptionPrivateKeys();\n if (signerKeys === undefined) {\n throw new Error(\"Owner XID document has no inception private keys\");\n }\n\n // Parse as SealedEvent<Envelope> - the content is the SignFinalizeContent envelope\n const sealedEvent = SealedEvent.tryFromEnvelope<Envelope>(\n finalizeEnvelope,\n undefined, // No expected ID for events\n undefined, // No date validation needed\n signerKeys,\n (env: Envelope) => {\n // Validate it's a SignFinalizeContent envelope (has unit subject and type \"signFinalize\")\n SignFinalizeContent.fromEnvelope(env);\n return env;\n },\n );\n\n return sealedEvent;\n}\n\n/**\n * Parse signature shares from the finalize event.\n *\n * Port of `parse_signature_shares()` from cmd/sign/participant/finalize.rs.\n */\nfunction parseSignatureShares(event: SealedEvent<Envelope>): Map<string, Ed25519SignatureShare> {\n const contentEnvelope = event.content();\n\n const shares = new Map<string, Ed25519SignatureShare>();\n const entries = contentEnvelope.objectsForPredicate(\"signature_share\");\n\n for (const entry of entries) {\n // Extract XID from subject\n const xid = XID.fromTaggedCbor(entry.subject().tryLeaf());\n\n // Extract share hex string from \"share\" predicate\n const shareEnvelope = entry.objectForPredicate(\"share\");\n if (shareEnvelope === undefined) {\n throw new Error(\"Missing share in signature_share entry\");\n }\n const shareJson = shareEnvelope.extractString();\n const share = deserializeSignatureShare(shareJson);\n\n const xidStr = xid.urString();\n if (shares.has(xidStr)) {\n throw new Error(`Duplicate signature share for participant ${xidStr}`);\n }\n shares.set(xidStr, share);\n }\n\n if (shares.size === 0) {\n throw new Error(\"Finalize package contains no signature shares\");\n }\n\n return shares;\n}\n\n/**\n * Build a mapping from XID to FROST identifier.\n *\n * Port of `xid_identifier_map()` from cmd/sign/participant/finalize.rs.\n */\nfunction xidIdentifierMap(participants: XID[]): Map<string, FrostIdentifier> {\n const map = new Map<string, FrostIdentifier>();\n for (let i = 0; i < participants.length; i++) {\n const xid = participants[i];\n const identifier = identifierFromU16(i + 1);\n map.set(xid.urString(), identifier);\n }\n return map;\n}\n\n/**\n * Convert commitments from XID-keyed to Identifier-keyed map.\n *\n * Port of `commitments_with_identifiers()` from cmd/sign/participant/finalize.rs.\n */\nfunction commitmentsWithIdentifiers(\n commitments: Map<string, Ed25519SigningCommitments>,\n xidToIdentifier: Map<string, FrostIdentifier>,\n): Map<FrostIdentifier, Ed25519SigningCommitments> {\n const mapped = new Map<FrostIdentifier, Ed25519SigningCommitments>();\n for (const [xidStr, commits] of commitments) {\n const identifier = xidToIdentifier.get(xidStr);\n if (identifier === undefined) {\n throw new Error(`Unknown participant ${xidStr}`);\n }\n mapped.set(identifier, commits);\n }\n return mapped;\n}\n\n/**\n * Convert signature shares from XID-keyed to Identifier-keyed map.\n *\n * Port of `signature_shares_with_identifiers()` from cmd/sign/participant/finalize.rs.\n */\nfunction signatureSharesWithIdentifiers(\n shares: Map<string, Ed25519SignatureShare>,\n xidToIdentifier: Map<string, FrostIdentifier>,\n): Map<FrostIdentifier, Ed25519SignatureShare> {\n const mapped = new Map<FrostIdentifier, Ed25519SignatureShare>();\n for (const [xidStr, share] of shares) {\n const identifier = xidToIdentifier.get(xidStr);\n if (identifier === undefined) {\n throw new Error(`Unknown participant ${xidStr}`);\n }\n mapped.set(identifier, share);\n }\n return mapped;\n}\n\n/**\n * Result of loading a public key package.\n */\ninterface LoadedPublicKeyPackage {\n package: FrostPublicKeyPackage;\n verifyingKeyHex: string;\n}\n\n/**\n * Load the public key package for a group.\n *\n * Port of `load_public_key_package()` from cmd/sign/participant/finalize.rs.\n */\nfunction loadPublicKeyPackage(registryPath: string, groupId: ARID): LoadedPublicKeyPackage {\n const base = path.dirname(registryPath);\n\n // Try direct path first\n const directPath = path.join(base, \"group-state\", groupId.hex(), \"public_key_package.json\");\n if (fs.existsSync(directPath)) {\n const raw = JSON.parse(fs.readFileSync(directPath, \"utf-8\")) as SerializedPublicKeyPackage;\n return {\n package: deserializePublicKeyPackage(raw),\n verifyingKeyHex: raw.verifyingKey,\n };\n }\n\n // Fallback to collected_finalize.json (coordinator)\n const collectedPath = path.join(base, \"group-state\", groupId.hex(), \"collected_finalize.json\");\n if (fs.existsSync(collectedPath)) {\n const raw = JSON.parse(fs.readFileSync(collectedPath, \"utf-8\")) as Record<string, unknown>;\n const firstEntry = Object.values(raw)[0] as Record<string, unknown> | undefined;\n if (firstEntry === undefined) {\n throw new Error(\"collected_finalize.json is empty\");\n }\n const publicKeyValue = firstEntry[\"public_key_package\"] as\n SerializedPublicKeyPackage | undefined;\n if (publicKeyValue === undefined) {\n throw new Error(\"public_key_package missing in collected_finalize.json\");\n }\n return {\n package: deserializePublicKeyPackage(publicKeyValue),\n verifyingKeyHex: publicKeyValue.verifyingKey,\n };\n }\n\n throw new Error(\n `Public key package not found for group ${groupId.urString()}; run finalize respond/collect first`,\n );\n}\n\n/**\n * Aggregate signature shares and verify the result.\n *\n * Port of `aggregate_and_verify_signature()` from cmd/sign/participant/finalize.rs.\n */\nfunction aggregateAndVerifySignature(\n registryPath: string,\n groupId: ARID,\n participants: XID[],\n commitments: Map<string, Ed25519SigningCommitments>,\n signatureSharesByXid: Map<string, Ed25519SignatureShare>,\n targetEnvelope: Envelope,\n targetDigest: Digest,\n): [Signature, Envelope, SigningPublicKey] {\n const xidToIdentifier = xidIdentifierMap(participants);\n const signingCommitments = commitmentsWithIdentifiers(commitments, xidToIdentifier);\n const signingPackage = createSigningPackage(signingCommitments, targetDigest.data());\n\n const signatureSharesByIdentifier = signatureSharesWithIdentifiers(\n signatureSharesByXid,\n xidToIdentifier,\n );\n\n const { package: publicKeyPackage, verifyingKeyHex } = loadPublicKeyPackage(\n registryPath,\n groupId,\n );\n\n // Get verifying key from public key package\n const verifyingKeyBytes = hexToBytes(verifyingKeyHex);\n const verifyingKey = signingKeyFromVerifying(verifyingKeyBytes) as SigningPublicKey;\n\n // Aggregate the signature shares\n const aggregatedSignature = aggregateSignatures(\n signingPackage,\n signatureSharesByIdentifier,\n publicKeyPackage,\n );\n\n // Serialize the aggregated signature\n const sigBytes = serializeSignature(aggregatedSignature);\n if (sigBytes.length !== 64) {\n throw new Error(\"Aggregated signature is not 64 bytes\");\n }\n const finalSignature = Signature.ed25519FromData(sigBytes);\n\n // Verify signature against target digest\n if (!verifyingKey.verify(finalSignature, targetDigest.data())) {\n throw new Error(\"Aggregated signature failed verification against target digest\");\n }\n\n // Create signed envelope\n const signedEnvelope = targetEnvelope.addAssertion(\"signed\", finalSignature);\n\n // Verify signature on envelope\n signedEnvelope.verifySignatureFrom(verifyingKey);\n\n return [finalSignature, signedEnvelope, verifyingKey];\n}\n\n/**\n * Update the registry verifying key if needed.\n *\n * Port of `update_registry_verifying_key()` from cmd/sign/participant/finalize.rs.\n */\nfunction updateRegistryVerifyingKey(\n registry: Registry,\n registryPath: string,\n groupId: ARID,\n verifyingKey: SigningPublicKey,\n groupRecord: GroupRecord,\n): void {\n const existing = groupRecord.verifyingKey();\n if (existing !== undefined) {\n if (existing.urString() !== verifyingKey.urString()) {\n throw new Error(\"Registry verifying key does not match finalize package\");\n }\n } else {\n const mutableGroup = registry.group(groupId);\n if (mutableGroup === undefined) {\n throw new Error(\"Group not found in registry\");\n }\n mutableGroup.setVerifyingKey(verifyingKey);\n registry.save(registryPath);\n }\n}\n\n/**\n * Persist the final state to disk.\n *\n * Port of `persist_final_state()` from cmd/sign/participant/finalize.rs.\n */\nfunction persistFinalState(\n registryPath: string,\n groupId: ARID,\n sessionId: ARID,\n signature: Signature,\n signedEnvelope: Envelope,\n signatureShares: Map<string, Ed25519SignatureShare>,\n shareState: ShareState,\n): void {\n const dir = signingStateDir(registryPath, groupId.hex(), sessionId.hex());\n fs.mkdirSync(dir, { recursive: true });\n\n const finalPath = path.join(dir, \"final.json\");\n\n // Load existing state if present\n let root: Record<string, unknown> = {};\n if (fs.existsSync(finalPath)) {\n root = JSON.parse(fs.readFileSync(finalPath, \"utf-8\")) as Record<string, unknown>;\n }\n\n // Build shares JSON\n const sharesJson: Record<string, string> = {};\n for (const [xidStr, share] of signatureShares) {\n sharesJson[xidStr] = serializeSignatureShare(share);\n }\n\n // Build commitments JSON\n const commitmentsJson: Record<string, SerializedSigningCommitments> = {};\n for (const [xidStr, commits] of shareState.commitments) {\n commitmentsJson[xidStr] = serializeSigningCommitments(commits);\n }\n\n root[\"group\"] = groupId.urString();\n root[\"session\"] = sessionId.urString();\n root[\"signature\"] = signature.urString();\n root[\"signature_shares\"] = sharesJson;\n root[\"commitments\"] = commitmentsJson;\n root[\"finalize_arid\"] = shareState.finalizeArid.urString();\n root[\"signed_target\"] = signedEnvelope.urString();\n\n fs.writeFileSync(finalPath, JSON.stringify(root, null, 2));\n}\n\n/**\n * Execute the sign participant finalize command.\n *\n * Receives the finalize event with aggregated signature.\n *\n * Port of `finalize()` from cmd/sign/participant/finalize.rs.\n */\nexport async function finalize(\n client: StorageClient,\n options: SignFinalizeOptions,\n cwd: string,\n): Promise<SignFinalizeResult> {\n const registryPath = resolveRegistryPath(options.registryPath, cwd);\n const registry = Registry.load(registryPath);\n\n const owner = registry.owner();\n if (owner === undefined) {\n throw new Error(\"Registry owner is required\");\n }\n\n const sessionId = parseAridUr(options.sessionId);\n const groupHint =\n options.groupId !== undefined && options.groupId !== \"\"\n ? parseAridUr(options.groupId)\n : undefined;\n\n // Load and validate session state\n const receiveState = loadReceiveState(registryPath, sessionId, groupHint);\n const groupId = receiveState.groupId;\n const groupRecord = registry.group(groupId);\n\n if (groupRecord === undefined) {\n throw new Error(\"Group not found in registry\");\n }\n\n validateSessionState(receiveState, groupRecord, owner);\n\n const shareState = loadShareState(registryPath, groupId, sessionId);\n validateShareState(shareState, receiveState, groupRecord);\n\n // Fetch finalize event\n const sealedEvent = await fetchFinalizeEvent(\n client,\n shareState.finalizeArid,\n options.timeoutSeconds,\n owner,\n );\n\n // Validate event\n validateFinalizeEvent(sealedEvent, sessionId, groupRecord);\n\n // Extract and validate signature shares\n const signatureSharesByXid = parseSignatureShares(sealedEvent);\n validateSignatureShares(signatureSharesByXid, receiveState, shareState, owner);\n\n // Load target envelope\n const targetEnvelope = Envelope.fromURString(receiveState.targetUr);\n const targetDigest = targetEnvelope.subject().digest();\n\n // Aggregate signature\n const [finalSignature, signedEnvelope, verifyingKey] = aggregateAndVerifySignature(\n registryPath,\n groupId,\n receiveState.participants,\n shareState.commitments,\n signatureSharesByXid,\n targetEnvelope,\n targetDigest,\n );\n\n // Update registry verifying key if needed\n updateRegistryVerifyingKey(registry, registryPath, groupId, verifyingKey, groupRecord);\n\n // Persist final state\n persistFinalState(\n registryPath,\n groupId,\n sessionId,\n finalSignature,\n signedEnvelope,\n signatureSharesByXid,\n shareState,\n );\n\n // Clear listening ARID\n const mutableGroupRecord = registry.group(groupId);\n if (mutableGroupRecord !== undefined) {\n mutableGroupRecord.clearListeningAtArid();\n registry.save(registryPath);\n }\n\n const signatureStr = finalSignature.urString();\n const signedEnvelopeStr = signedEnvelope.urString();\n\n if (options.verbose === true) {\n console.log(signatureStr);\n console.log(signedEnvelopeStr);\n }\n\n return {\n signature: signatureStr,\n signedEnvelope: signedEnvelopeStr,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoGA,SAAS,iBACP,cACA,WACA,WACc;CACd,MAAM,OAAOA,UAAK,QAAQ,YAAY;CACtC,MAAM,gBAAgBA,UAAK,KAAK,MAAM,aAAa;CAGnD,MAAM,YAA8B,CAAC;CACrC,IAAI,cAAc,KAAA,GAChB,UAAU,KAAK,CAAC,WAAWA,UAAK,KAAK,eAAe,UAAU,IAAI,CAAC,CAAC,CAAC;MAErE,IAAIC,QAAG,WAAW,aAAa;OACxB,MAAM,SAASA,QAAG,YAAY,eAAe,EAAE,eAAe,KAAK,CAAC,GACvE,IAAI,MAAM,YAAY,GAAG;GACvB,MAAM,OAAO,MAAM;GAEnB,IAAI,KAAK,WAAW,MAAM,eAAe,KAAK,IAAI,GAAG;IACnD,MAAM,UAAUC,iBAAAA,KAAK,QAAQ,IAAI;IACjC,UAAU,KAAK,CAAC,SAASF,UAAK,KAAK,eAAe,IAAI,CAAC,CAAC;GAC1D;EACF;;CAMN,MAAM,aAA+B,CAAC;CACtC,KAAK,MAAM,CAAC,SAAS,aAAa,WAAW;EAC3C,MAAM,YAAYA,UAAK,KAAK,UAAU,WAAW,UAAU,IAAI,GAAG,mBAAmB;E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CAG/C,qBAAqB,cAAc,aAAa,KAAK;CAErD,MAAM,aAAa,eAAe,cAAc,SAAS,SAAS;CAClE,mBAAmB,YAAY,cAAc,WAAW;CAGxD,MAAM,cAAc,MAAM,mBACxB,QACA,WAAW,cACX,QAAQ,gBACR,KACF;CAGA,sBAAsB,aAAa,WAAW,WAAW;CAGzD,MAAM,uBAAuB,qBAAqB,WAAW;CAC7D,wBAAwB,sBAAsB,cAAc,YAAY,KAAK;CAG7E,MAAM,iBAAiBsB,eAAAA,SAAS,aAAa,aAAa,QAAQ;CAClE,MAAM,eAAe,eAAe,QAAQ,CAAC,CAAC,OAAO;CAGrD,MAAM,CAAC,gBAAgB,gBAAgB,gBAAgB,4BACrD,cACA,SACA,aAAa,cACb,WAAW,aACX,sBACA,gBACA,YACF;CAGA,2BAA2B,UAAU,cAAc,SAAS,cAAc,WAAW;CAGrF,kBACE,cACA,SACA,WACA,gBACA,gBACA,sBACA,UACF;CAGA,MAAM,qBAAqB,SAAS,MAAM,OAAO;CACjD,IAAI,uBAAuB,KAAA,GAAW;EACpC,mBAAmB,qBAAqB;EACxC,SAAS,KAAK,YAAY;CAC5B;CAEA,MAAM,eAAe,eAAe,SAAS;CAC7C,MAAM,oBAAoB,eAAe,SAAS;CAElD,IAAI,QAAQ,YAAY,MAAM;EAC5B,QAAQ,IAAI,YAAY;EACxB,QAAQ,IAAI,iBAAiB;CAC/B;CAEA,OAAO;EACL,WAAW;EACX,gBAAgB;CAClB;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"finalize-BVOveyol.mjs","names":["serialized"],"sources":["../src/cmd/sign/participant/finalize.ts"],"sourcesContent":["/**\n * Copyright © 2023-2026 Blockchain Commons, LLC\n * Copyright © 2025-2026 Parity Technologies\n *\n *\n * Sign participant finalize command.\n *\n * Port of cmd/sign/participant/finalize.rs from frost-hubert-rust.\n *\n * @module\n */\n\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\n\nimport { ARID, type Digest, Signature, type SigningPublicKey, XID } from \"@bcts/components\";\nimport { compareXidBytes } from \"../../../dkg/proposed-participant.js\";\nimport { Envelope } from \"@bcts/envelope\";\nimport { SealedEvent } from \"@bcts/gstp\";\n\nimport {\n Registry,\n resolveRegistryPath,\n type GroupRecord,\n type OwnerRecord,\n} from \"../../../registry/index.js\";\nimport { getWithIndicator } from \"../../busy.js\";\nimport { type StorageClient } from \"../../storage.js\";\nimport { parseAridUr, signingKeyFromVerifying } from \"../../dkg/common.js\";\nimport { signingStateDir, SignFinalizeContent } from \"../common.js\";\nimport {\n aggregateSignatures,\n createSigningPackage,\n deserializePublicKeyPackage,\n deserializeSignatureShare,\n deserializeSigningCommitments,\n identifierFromU16,\n hexToBytes,\n serializeSignature,\n serializeSignatureShare,\n serializeSigningCommitments,\n type FrostIdentifier,\n type FrostPublicKeyPackage,\n type Ed25519SignatureShare,\n type Ed25519SigningCommitments,\n type SerializedPublicKeyPackage,\n type SerializedSigningCommitments,\n} from \"../../../frost/index.js\";\nimport { isVerbose } from \"../../common.js\";\n\n/**\n * Options for the sign finalize command.\n */\nexport interface SignFinalizeOptions {\n registryPath?: string;\n sessionId: string;\n groupId?: string;\n timeoutSeconds?: number;\n verbose?: boolean;\n}\n\n/**\n * Result of the sign finalize command.\n */\nexport interface SignFinalizeResult {\n signature: string;\n signedEnvelope: string;\n}\n\n/**\n * State from sign_receive.json.\n *\n * Port of `struct ReceiveState` from cmd/sign/participant/finalize.rs.\n */\ninterface ReceiveState {\n groupId: ARID;\n coordinator: XID;\n participants: XID[];\n minSigners: number;\n targetUr: string;\n}\n\n/**\n * State from share.json.\n *\n * Port of `struct ShareState` from cmd/sign/participant/finalize.rs.\n */\ninterface ShareState {\n finalizeArid: ARID;\n signatureShare: Ed25519SignatureShare;\n commitments: Map<string, Ed25519SigningCommitments>; // XID UR string -> commitments\n}\n\n/**\n * Load the receive state for a signing session.\n *\n * Searches for sign_receive.json in group-state directories.\n *\n * Port of `load_receive_state()` from cmd/sign/participant/finalize.rs.\n */\nfunction loadReceiveState(\n registryPath: string,\n sessionId: ARID,\n groupHint: ARID | undefined,\n): ReceiveState {\n const base = path.dirname(registryPath);\n const groupStateDir = path.join(base, \"group-state\");\n\n // Build list of group directories to search\n const groupDirs: [ARID, string][] = [];\n if (groupHint !== undefined) {\n groupDirs.push([groupHint, path.join(groupStateDir, groupHint.hex())]);\n } else {\n if (fs.existsSync(groupStateDir)) {\n for (const entry of fs.readdirSync(groupStateDir, { withFileTypes: true })) {\n if (entry.isDirectory()) {\n const name = entry.name;\n // Check if it's a valid 64-char hex string (ARID)\n if (name.length === 64 && /^[0-9a-f]+$/i.test(name)) {\n const groupId = ARID.fromHex(name);\n groupDirs.push([groupId, path.join(groupStateDir, name)]);\n }\n }\n }\n }\n }\n\n // Search for sign_receive.json\n const candidates: [ARID, string][] = [];\n for (const [groupId, groupDir] of groupDirs) {\n const candidate = path.join(groupDir, \"signing\", sessionId.hex(), \"sign_receive.json\");\n if (fs.existsSync(candidate)) {\n candidates.push([groupId, candidate]);\n }\n }\n\n if (candidates.length === 0) {\n throw new Error(\n \"No sign_receive.json found for this session; run `frost sign participant receive` first\",\n );\n }\n if (candidates.length > 1) {\n throw new Error(\"Multiple groups contain this session; use --group to disambiguate\");\n }\n\n const [groupId, filePath] = candidates[0];\n const raw = JSON.parse(fs.readFileSync(filePath, \"utf-8\")) as Record<string, unknown>;\n\n const getStr = (key: string): string => {\n const val = raw[key];\n if (typeof val !== \"string\") {\n throw new Error(`Missing or invalid ${key} in sign_receive.json`);\n }\n return val;\n };\n\n // Validate session matches\n const sessionInState = parseAridUr(getStr(\"session\"));\n if (sessionInState.hex() !== sessionId.hex()) {\n throw new Error(\n `Session ${sessionInState.urString()} in sign_receive.json does not match requested session ${sessionId.urString()}`,\n );\n }\n\n // Validate group matches\n const groupInState = parseAridUr(getStr(\"group\"));\n if (groupInState.hex() !== groupId.hex()) {\n throw new Error(\n `Group ${groupInState.urString()} in sign_receive.json does not match directory group ${groupId.urString()}`,\n );\n }\n\n const coordinator = XID.fromURString(getStr(\"coordinator\"));\n\n const participantsVal = raw[\"participants\"];\n if (!Array.isArray(participantsVal)) {\n throw new Error(\"Missing participants in sign_receive.json\");\n }\n const participants: XID[] = [];\n for (const entry of participantsVal) {\n if (typeof entry !== \"string\") {\n throw new Error(\"Invalid participant entry in sign_receive.json\");\n }\n participants.push(XID.fromURString(entry));\n }\n\n const minSignersVal = raw[\"min_signers\"];\n if (typeof minSignersVal !== \"number\") {\n throw new Error(\"Missing min_signers in sign_receive.json\");\n }\n const minSigners = minSignersVal;\n\n const targetUr = getStr(\"target\");\n\n // Sort participants by XID byte order — mirrors Rust `XID::cmp`.\n // The earlier port used `urString().localeCompare(...)`, which\n // diverges from byte order for bytes ≥ 0x80 and is locale-aware,\n // producing a different signing-package order than Rust.\n participants.sort((a, b) => compareXidBytes(a.toData(), b.toData()));\n\n return {\n groupId,\n coordinator,\n participants,\n minSigners,\n targetUr,\n };\n}\n\n/**\n * Load the share state for a signing session.\n *\n * Port of `load_share_state()` from cmd/sign/participant/finalize.rs.\n */\nfunction loadShareState(registryPath: string, groupId: ARID, sessionId: ARID): ShareState {\n const dir = signingStateDir(registryPath, groupId.hex(), sessionId.hex());\n const filePath = path.join(dir, \"share.json\");\n\n if (!fs.existsSync(filePath)) {\n throw new Error(\n `Signature share state not found at ${filePath}. Run \\`frost sign participant share\\` first.`,\n );\n }\n\n const raw = JSON.parse(fs.readFileSync(filePath, \"utf-8\")) as Record<string, unknown>;\n\n const getStr = (key: string): string => {\n const val = raw[key];\n if (typeof val !== \"string\") {\n throw new Error(`Missing or invalid ${key} in share.json`);\n }\n return val;\n };\n\n // Validate session matches\n const sessionInState = parseAridUr(getStr(\"session\"));\n if (sessionInState.hex() !== sessionId.hex()) {\n throw new Error(\n `Session ${sessionInState.urString()} in share.json does not match requested session ${sessionId.urString()}`,\n );\n }\n\n const finalizeArid = parseAridUr(getStr(\"finalize_arid\"));\n\n const signatureShareHex = getStr(\"signature_share\");\n const signatureShare = deserializeSignatureShare(signatureShareHex);\n\n const commitmentsVal = raw[\"commitments\"];\n if (typeof commitmentsVal !== \"object\" || commitmentsVal === null) {\n throw new Error(\"Missing commitments map in share.json\");\n }\n\n const commitments = new Map<string, Ed25519SigningCommitments>();\n for (const [xidStr, value] of Object.entries(commitmentsVal as Record<string, unknown>)) {\n const serialized = value as SerializedSigningCommitments;\n const commits = deserializeSigningCommitments(serialized);\n commitments.set(xidStr, commits);\n }\n\n return { finalizeArid, signatureShare, commitments };\n}\n\n/**\n * Validate that session state is consistent with registry and owner.\n *\n * Port of `validate_session_state()` from cmd/sign/participant/finalize.rs.\n */\nfunction validateSessionState(\n receiveState: ReceiveState,\n groupRecord: GroupRecord,\n owner: OwnerRecord,\n): void {\n if (receiveState.coordinator.urString() !== groupRecord.coordinator().xid().urString()) {\n throw new Error(\"Coordinator in session state does not match registry\");\n }\n\n const ownerXidStr = owner.xid().urString();\n const isParticipant = receiveState.participants.some((p) => p.urString() === ownerXidStr);\n if (!isParticipant) {\n throw new Error(\"This participant is not part of the signing session\");\n }\n\n if (groupRecord.minSigners() !== receiveState.minSigners) {\n throw new Error(\n `Session min_signers ${receiveState.minSigners} does not match registry ${groupRecord.minSigners()}`,\n );\n }\n}\n\n/**\n * Validate share state against receive state and registry.\n *\n * Port of `validate_share_state()` from cmd/sign/participant/finalize.rs.\n */\nfunction validateShareState(\n shareState: ShareState,\n receiveState: ReceiveState,\n groupRecord: GroupRecord,\n): void {\n const listeningAtArid = groupRecord.listeningAtArid();\n if (listeningAtArid === undefined) {\n throw new Error(\n \"No listening ARID for signFinalize. Did you run `frost sign participant share`?\",\n );\n }\n\n if (shareState.finalizeArid.hex() !== listeningAtArid.hex()) {\n throw new Error(\n `Registry listening ARID (${listeningAtArid.urString()}) does not match persisted finalize ARID (${shareState.finalizeArid.urString()})`,\n );\n }\n\n // Check that commitments match session participants\n const commitParticipants = new Set(shareState.commitments.keys());\n const sessionParticipants = new Set(receiveState.participants.map((p) => p.urString()));\n\n if (commitParticipants.size !== sessionParticipants.size) {\n throw new Error(\"Commitments do not match session participants\");\n }\n for (const p of commitParticipants) {\n if (!sessionParticipants.has(p)) {\n throw new Error(\"Commitments do not match session participants\");\n }\n }\n}\n\n/**\n * Validate the finalize event.\n *\n * Port of `validate_finalize_event()` from cmd/sign/participant/finalize.rs.\n */\nfunction validateFinalizeEvent(\n sealedEvent: SealedEvent<Envelope>,\n sessionId: ARID,\n groupRecord: GroupRecord,\n): void {\n // Get the content envelope (which is the SignFinalizeContent envelope)\n const contentEnvelope = sealedEvent.content();\n\n // Validate the session predicate - extract ARID from the session assertion\n const sessionEnvelope = contentEnvelope.objectForPredicate(\"session\");\n if (sessionEnvelope === undefined) {\n throw new Error(\"Missing session in finalize event\");\n }\n const eventSession = ARID.fromTaggedCbor(sessionEnvelope.subject().tryLeaf());\n if (eventSession.hex() !== sessionId.hex()) {\n throw new Error(\n `Event session ${eventSession.urString()} does not match expected ${sessionId.urString()}`,\n );\n }\n\n const expectedCoordinator = groupRecord.coordinator().xid();\n if (sealedEvent.sender().xid().urString() !== expectedCoordinator.urString()) {\n throw new Error(\n `Unexpected event sender: ${sealedEvent.sender().xid().urString()} (expected coordinator ${expectedCoordinator.urString()})`,\n );\n }\n}\n\n/**\n * Validate signature shares from the finalize event.\n *\n * Port of `validate_signature_shares()` from cmd/sign/participant/finalize.rs.\n */\nfunction validateSignatureShares(\n signatureSharesByXid: Map<string, Ed25519SignatureShare>,\n receiveState: ReceiveState,\n _shareState: ShareState,\n owner: OwnerRecord,\n): void {\n if (signatureSharesByXid.size < receiveState.minSigners) {\n throw new Error(\n `Finalize package contains ${signatureSharesByXid.size} signature shares but requires at least ${receiveState.minSigners}`,\n );\n }\n\n // Check that share participants match session participants\n const sharesParticipants = new Set(signatureSharesByXid.keys());\n const sessionParticipants = new Set(receiveState.participants.map((p) => p.urString()));\n\n if (sharesParticipants.size !== sessionParticipants.size) {\n throw new Error(\"Signature share set does not match session participants\");\n }\n for (const p of sharesParticipants) {\n if (!sessionParticipants.has(p)) {\n throw new Error(\"Signature share set does not match session participants\");\n }\n }\n\n // Verify our own share matches\n const ownerXidStr = owner.xid().urString();\n const myShare = signatureSharesByXid.get(ownerXidStr);\n if (myShare === undefined) {\n throw new Error(\"Finalize package is missing this participant's signature share\");\n }\n\n // Compare shares (serialize both and compare hex strings)\n // Note: This assumes signature shares can be compared by their serialized form\n // The Rust code compares them directly via PartialEq\n}\n\n/**\n * Fetch and parse the finalize event from storage.\n *\n * Port of `fetch_finalize_event()` from cmd/sign/participant/finalize.rs.\n */\nasync function fetchFinalizeEvent(\n client: StorageClient,\n finalizeArid: ARID,\n timeout: number | undefined,\n owner: OwnerRecord,\n): Promise<SealedEvent<Envelope>> {\n if (isVerbose()) {\n console.error(\"Fetching finalize package from Hubert...\");\n }\n\n const finalizeEnvelope = await getWithIndicator(\n client,\n finalizeArid,\n \"Finalize package\",\n timeout,\n isVerbose(),\n );\n\n if (finalizeEnvelope === null || finalizeEnvelope === undefined) {\n throw new Error(\"Finalize package not found in Hubert storage\");\n }\n\n const signerKeys = owner.xidDocument().inceptionPrivateKeys();\n if (signerKeys === undefined) {\n throw new Error(\"Owner XID document has no inception private keys\");\n }\n\n // Parse as SealedEvent<Envelope> - the content is the SignFinalizeContent envelope\n const sealedEvent = SealedEvent.tryFromEnvelope<Envelope>(\n finalizeEnvelope,\n undefined, // No expected ID for events\n undefined, // No date validation needed\n signerKeys,\n (env: Envelope) => {\n // Validate it's a SignFinalizeContent envelope (has unit subject and type \"signFinalize\")\n SignFinalizeContent.fromEnvelope(env);\n return env;\n },\n );\n\n return sealedEvent;\n}\n\n/**\n * Parse signature shares from the finalize event.\n *\n * Port of `parse_signature_shares()` from cmd/sign/participant/finalize.rs.\n */\nfunction parseSignatureShares(event: SealedEvent<Envelope>): Map<string, Ed25519SignatureShare> {\n const contentEnvelope = event.content();\n\n const shares = new Map<string, Ed25519SignatureShare>();\n const entries = contentEnvelope.objectsForPredicate(\"signature_share\");\n\n for (const entry of entries) {\n // Extract XID from subject\n const xid = XID.fromTaggedCbor(entry.subject().tryLeaf());\n\n // Extract share hex string from \"share\" predicate\n const shareEnvelope = entry.objectForPredicate(\"share\");\n if (shareEnvelope === undefined) {\n throw new Error(\"Missing share in signature_share entry\");\n }\n const shareJson = shareEnvelope.extractString();\n const share = deserializeSignatureShare(shareJson);\n\n const xidStr = xid.urString();\n if (shares.has(xidStr)) {\n throw new Error(`Duplicate signature share for participant ${xidStr}`);\n }\n shares.set(xidStr, share);\n }\n\n if (shares.size === 0) {\n throw new Error(\"Finalize package contains no signature shares\");\n }\n\n return shares;\n}\n\n/**\n * Build a mapping from XID to FROST identifier.\n *\n * Port of `xid_identifier_map()` from cmd/sign/participant/finalize.rs.\n */\nfunction xidIdentifierMap(participants: XID[]): Map<string, FrostIdentifier> {\n const map = new Map<string, FrostIdentifier>();\n for (let i = 0; i < participants.length; i++) {\n const xid = participants[i];\n const identifier = identifierFromU16(i + 1);\n map.set(xid.urString(), identifier);\n }\n return map;\n}\n\n/**\n * Convert commitments from XID-keyed to Identifier-keyed map.\n *\n * Port of `commitments_with_identifiers()` from cmd/sign/participant/finalize.rs.\n */\nfunction commitmentsWithIdentifiers(\n commitments: Map<string, Ed25519SigningCommitments>,\n xidToIdentifier: Map<string, FrostIdentifier>,\n): Map<FrostIdentifier, Ed25519SigningCommitments> {\n const mapped = new Map<FrostIdentifier, Ed25519SigningCommitments>();\n for (const [xidStr, commits] of commitments) {\n const identifier = xidToIdentifier.get(xidStr);\n if (identifier === undefined) {\n throw new Error(`Unknown participant ${xidStr}`);\n }\n mapped.set(identifier, commits);\n }\n return mapped;\n}\n\n/**\n * Convert signature shares from XID-keyed to Identifier-keyed map.\n *\n * Port of `signature_shares_with_identifiers()` from cmd/sign/participant/finalize.rs.\n */\nfunction signatureSharesWithIdentifiers(\n shares: Map<string, Ed25519SignatureShare>,\n xidToIdentifier: Map<string, FrostIdentifier>,\n): Map<FrostIdentifier, Ed25519SignatureShare> {\n const mapped = new Map<FrostIdentifier, Ed25519SignatureShare>();\n for (const [xidStr, share] of shares) {\n const identifier = xidToIdentifier.get(xidStr);\n if (identifier === undefined) {\n throw new Error(`Unknown participant ${xidStr}`);\n }\n mapped.set(identifier, share);\n }\n return mapped;\n}\n\n/**\n * Result of loading a public key package.\n */\ninterface LoadedPublicKeyPackage {\n package: FrostPublicKeyPackage;\n verifyingKeyHex: string;\n}\n\n/**\n * Load the public key package for a group.\n *\n * Port of `load_public_key_package()` from cmd/sign/participant/finalize.rs.\n */\nfunction loadPublicKeyPackage(registryPath: string, groupId: ARID): LoadedPublicKeyPackage {\n const base = path.dirname(registryPath);\n\n // Try direct path first\n const directPath = path.join(base, \"group-state\", groupId.hex(), \"public_key_package.json\");\n if (fs.existsSync(directPath)) {\n const raw = JSON.parse(fs.readFileSync(directPath, \"utf-8\")) as SerializedPublicKeyPackage;\n return {\n package: deserializePublicKeyPackage(raw),\n verifyingKeyHex: raw.verifyingKey,\n };\n }\n\n // Fallback to collected_finalize.json (coordinator)\n const collectedPath = path.join(base, \"group-state\", groupId.hex(), \"collected_finalize.json\");\n if (fs.existsSync(collectedPath)) {\n const raw = JSON.parse(fs.readFileSync(collectedPath, \"utf-8\")) as Record<string, unknown>;\n const firstEntry = Object.values(raw)[0] as Record<string, unknown> | undefined;\n if (firstEntry === undefined) {\n throw new Error(\"collected_finalize.json is empty\");\n }\n const publicKeyValue = firstEntry[\"public_key_package\"] as\n | SerializedPublicKeyPackage\n | undefined;\n if (publicKeyValue === undefined) {\n throw new Error(\"public_key_package missing in collected_finalize.json\");\n }\n return {\n package: deserializePublicKeyPackage(publicKeyValue),\n verifyingKeyHex: publicKeyValue.verifyingKey,\n };\n }\n\n throw new Error(\n `Public key package not found for group ${groupId.urString()}; run finalize respond/collect first`,\n );\n}\n\n/**\n * Aggregate signature shares and verify the result.\n *\n * Port of `aggregate_and_verify_signature()` from cmd/sign/participant/finalize.rs.\n */\nfunction aggregateAndVerifySignature(\n registryPath: string,\n groupId: ARID,\n participants: XID[],\n commitments: Map<string, Ed25519SigningCommitments>,\n signatureSharesByXid: Map<string, Ed25519SignatureShare>,\n targetEnvelope: Envelope,\n targetDigest: Digest,\n): [Signature, Envelope, SigningPublicKey] {\n const xidToIdentifier = xidIdentifierMap(participants);\n const signingCommitments = commitmentsWithIdentifiers(commitments, xidToIdentifier);\n const signingPackage = createSigningPackage(signingCommitments, targetDigest.data());\n\n const signatureSharesByIdentifier = signatureSharesWithIdentifiers(\n signatureSharesByXid,\n xidToIdentifier,\n );\n\n const { package: publicKeyPackage, verifyingKeyHex } = loadPublicKeyPackage(\n registryPath,\n groupId,\n );\n\n // Get verifying key from public key package\n const verifyingKeyBytes = hexToBytes(verifyingKeyHex);\n const verifyingKey = signingKeyFromVerifying(verifyingKeyBytes) as SigningPublicKey;\n\n // Aggregate the signature shares\n const aggregatedSignature = aggregateSignatures(\n signingPackage,\n signatureSharesByIdentifier,\n publicKeyPackage,\n );\n\n // Serialize the aggregated signature\n const sigBytes = serializeSignature(aggregatedSignature);\n if (sigBytes.length !== 64) {\n throw new Error(\"Aggregated signature is not 64 bytes\");\n }\n const finalSignature = Signature.ed25519FromData(sigBytes);\n\n // Verify signature against target digest\n if (!verifyingKey.verify(finalSignature, targetDigest.data())) {\n throw new Error(\"Aggregated signature failed verification against target digest\");\n }\n\n // Create signed envelope\n const signedEnvelope = targetEnvelope.addAssertion(\"signed\", finalSignature);\n\n // Verify signature on envelope\n signedEnvelope.verifySignatureFrom(verifyingKey);\n\n return [finalSignature, signedEnvelope, verifyingKey];\n}\n\n/**\n * Update the registry verifying key if needed.\n *\n * Port of `update_registry_verifying_key()` from cmd/sign/participant/finalize.rs.\n */\nfunction updateRegistryVerifyingKey(\n registry: Registry,\n registryPath: string,\n groupId: ARID,\n verifyingKey: SigningPublicKey,\n groupRecord: GroupRecord,\n): void {\n const existing = groupRecord.verifyingKey();\n if (existing !== undefined) {\n if (existing.urString() !== verifyingKey.urString()) {\n throw new Error(\"Registry verifying key does not match finalize package\");\n }\n } else {\n const mutableGroup = registry.group(groupId);\n if (mutableGroup === undefined) {\n throw new Error(\"Group not found in registry\");\n }\n mutableGroup.setVerifyingKey(verifyingKey);\n registry.save(registryPath);\n }\n}\n\n/**\n * Persist the final state to disk.\n *\n * Port of `persist_final_state()` from cmd/sign/participant/finalize.rs.\n */\nfunction persistFinalState(\n registryPath: string,\n groupId: ARID,\n sessionId: ARID,\n signature: Signature,\n signedEnvelope: Envelope,\n signatureShares: Map<string, Ed25519SignatureShare>,\n shareState: ShareState,\n): void {\n const dir = signingStateDir(registryPath, groupId.hex(), sessionId.hex());\n fs.mkdirSync(dir, { recursive: true });\n\n const finalPath = path.join(dir, \"final.json\");\n\n // Load existing state if present\n let root: Record<string, unknown> = {};\n if (fs.existsSync(finalPath)) {\n root = JSON.parse(fs.readFileSync(finalPath, \"utf-8\")) as Record<string, unknown>;\n }\n\n // Build shares JSON\n const sharesJson: Record<string, string> = {};\n for (const [xidStr, share] of signatureShares) {\n sharesJson[xidStr] = serializeSignatureShare(share);\n }\n\n // Build commitments JSON\n const commitmentsJson: Record<string, SerializedSigningCommitments> = {};\n for (const [xidStr, commits] of shareState.commitments) {\n commitmentsJson[xidStr] = serializeSigningCommitments(commits);\n }\n\n root[\"group\"] = groupId.urString();\n root[\"session\"] = sessionId.urString();\n root[\"signature\"] = signature.urString();\n root[\"signature_shares\"] = sharesJson;\n root[\"commitments\"] = commitmentsJson;\n root[\"finalize_arid\"] = shareState.finalizeArid.urString();\n root[\"signed_target\"] = signedEnvelope.urString();\n\n fs.writeFileSync(finalPath, JSON.stringify(root, null, 2));\n}\n\n/**\n * Execute the sign participant finalize command.\n *\n * Receives the finalize event with aggregated signature.\n *\n * Port of `finalize()` from cmd/sign/participant/finalize.rs.\n */\nexport async function finalize(\n client: StorageClient,\n options: SignFinalizeOptions,\n cwd: string,\n): Promise<SignFinalizeResult> {\n const registryPath = resolveRegistryPath(options.registryPath, cwd);\n const registry = Registry.load(registryPath);\n\n const owner = registry.owner();\n if (owner === undefined) {\n throw new Error(\"Registry owner is required\");\n }\n\n const sessionId = parseAridUr(options.sessionId);\n const groupHint =\n options.groupId !== undefined && options.groupId !== \"\"\n ? parseAridUr(options.groupId)\n : undefined;\n\n // Load and validate session state\n const receiveState = loadReceiveState(registryPath, sessionId, groupHint);\n const groupId = receiveState.groupId;\n const groupRecord = registry.group(groupId);\n\n if (groupRecord === undefined) {\n throw new Error(\"Group not found in registry\");\n }\n\n validateSessionState(receiveState, groupRecord, owner);\n\n const shareState = loadShareState(registryPath, groupId, sessionId);\n validateShareState(shareState, receiveState, groupRecord);\n\n // Fetch finalize event\n const sealedEvent = await fetchFinalizeEvent(\n client,\n shareState.finalizeArid,\n options.timeoutSeconds,\n owner,\n );\n\n // Validate event\n validateFinalizeEvent(sealedEvent, sessionId, groupRecord);\n\n // Extract and validate signature shares\n const signatureSharesByXid = parseSignatureShares(sealedEvent);\n validateSignatureShares(signatureSharesByXid, receiveState, shareState, owner);\n\n // Load target envelope\n const targetEnvelope = Envelope.fromURString(receiveState.targetUr);\n const targetDigest = targetEnvelope.subject().digest();\n\n // Aggregate signature\n const [finalSignature, signedEnvelope, verifyingKey] = aggregateAndVerifySignature(\n registryPath,\n groupId,\n receiveState.participants,\n shareState.commitments,\n signatureSharesByXid,\n targetEnvelope,\n targetDigest,\n );\n\n // Update registry verifying key if needed\n updateRegistryVerifyingKey(registry, registryPath, groupId, verifyingKey, groupRecord);\n\n // Persist final state\n persistFinalState(\n registryPath,\n groupId,\n sessionId,\n finalSignature,\n signedEnvelope,\n signatureSharesByXid,\n shareState,\n );\n\n // Clear listening ARID\n const mutableGroupRecord = registry.group(groupId);\n if (mutableGroupRecord !== undefined) {\n mutableGroupRecord.clearListeningAtArid();\n registry.save(registryPath);\n }\n\n const signatureStr = finalSignature.urString();\n const signedEnvelopeStr = signedEnvelope.urString();\n\n if (options.verbose === true) {\n console.log(signatureStr);\n console.log(signedEnvelopeStr);\n }\n\n return {\n signature: signatureStr,\n signed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YAAY,MAAM;EAC5B,QAAQ,IAAI,YAAY;EACxB,QAAQ,IAAI,iBAAiB;CAC/B;CAEA,OAAO;EACL,WAAW;EACX,gBAAgB;CAClB;AACF"}
1
+ {"version":3,"file":"finalize-BVOveyol.mjs","names":["serialized"],"sources":["../src/cmd/sign/participant/finalize.ts"],"sourcesContent":["/**\n * Copyright © 2023-2026 Blockchain Commons, LLC\n * Copyright © 2025-2026 Parity Technologies\n *\n *\n * Sign participant finalize command.\n *\n * Port of cmd/sign/participant/finalize.rs from frost-hubert-rust.\n *\n * @module\n */\n\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\n\nimport { ARID, type Digest, Signature, type SigningPublicKey, XID } from \"@bcts/components\";\nimport { compareXidBytes } from \"../../../dkg/proposed-participant.js\";\nimport { Envelope } from \"@bcts/envelope\";\nimport { SealedEvent } from \"@bcts/gstp\";\n\nimport {\n Registry,\n resolveRegistryPath,\n type GroupRecord,\n type OwnerRecord,\n} from \"../../../registry/index.js\";\nimport { getWithIndicator } from \"../../busy.js\";\nimport { type StorageClient } from \"../../storage.js\";\nimport { parseAridUr, signingKeyFromVerifying } from \"../../dkg/common.js\";\nimport { signingStateDir, SignFinalizeContent } from \"../common.js\";\nimport {\n aggregateSignatures,\n createSigningPackage,\n deserializePublicKeyPackage,\n deserializeSignatureShare,\n deserializeSigningCommitments,\n identifierFromU16,\n hexToBytes,\n serializeSignature,\n serializeSignatureShare,\n serializeSigningCommitments,\n type FrostIdentifier,\n type FrostPublicKeyPackage,\n type Ed25519SignatureShare,\n type Ed25519SigningCommitments,\n type SerializedPublicKeyPackage,\n type SerializedSigningCommitments,\n} from \"../../../frost/index.js\";\nimport { isVerbose } from \"../../common.js\";\n\n/**\n * Options for the sign finalize command.\n */\nexport interface SignFinalizeOptions {\n registryPath?: string;\n sessionId: string;\n groupId?: string;\n timeoutSeconds?: number;\n verbose?: boolean;\n}\n\n/**\n * Result of the sign finalize command.\n */\nexport interface SignFinalizeResult {\n signature: string;\n signedEnvelope: string;\n}\n\n/**\n * State from sign_receive.json.\n *\n * Port of `struct ReceiveState` from cmd/sign/participant/finalize.rs.\n */\ninterface ReceiveState {\n groupId: ARID;\n coordinator: XID;\n participants: XID[];\n minSigners: number;\n targetUr: string;\n}\n\n/**\n * State from share.json.\n *\n * Port of `struct ShareState` from cmd/sign/participant/finalize.rs.\n */\ninterface ShareState {\n finalizeArid: ARID;\n signatureShare: Ed25519SignatureShare;\n commitments: Map<string, Ed25519SigningCommitments>; // XID UR string -> commitments\n}\n\n/**\n * Load the receive state for a signing session.\n *\n * Searches for sign_receive.json in group-state directories.\n *\n * Port of `load_receive_state()` from cmd/sign/participant/finalize.rs.\n */\nfunction loadReceiveState(\n registryPath: string,\n sessionId: ARID,\n groupHint: ARID | undefined,\n): ReceiveState {\n const base = path.dirname(registryPath);\n const groupStateDir = path.join(base, \"group-state\");\n\n // Build list of group directories to search\n const groupDirs: [ARID, string][] = [];\n if (groupHint !== undefined) {\n groupDirs.push([groupHint, path.join(groupStateDir, groupHint.hex())]);\n } else {\n if (fs.existsSync(groupStateDir)) {\n for (const entry of fs.readdirSync(groupStateDir, { withFileTypes: true })) {\n if (entry.isDirectory()) {\n const name = entry.name;\n // Check if it's a valid 64-char hex string (ARID)\n if (name.length === 64 && /^[0-9a-f]+$/i.test(name)) {\n const groupId = ARID.fromHex(name);\n groupDirs.push([groupId, path.join(groupStateDir, name)]);\n }\n }\n }\n }\n }\n\n // Search for sign_receive.json\n const candidates: [ARID, string][] = [];\n for (const [groupId, groupDir] of groupDirs) {\n const candidate = path.join(groupDir, \"signing\", sessionId.hex(), \"sign_receive.json\");\n if (fs.existsSync(candidate)) {\n candidates.push([groupId, candidate]);\n }\n }\n\n if (candidates.length === 0) {\n throw new Error(\n \"No sign_receive.json found for this session; run `frost sign participant receive` first\",\n );\n }\n if (candidates.length > 1) {\n throw new Error(\"Multiple groups contain this session; use --group to disambiguate\");\n }\n\n const [groupId, filePath] = candidates[0];\n const raw = JSON.parse(fs.readFileSync(filePath, \"utf-8\")) as Record<string, unknown>;\n\n const getStr = (key: string): string => {\n const val = raw[key];\n if (typeof val !== \"string\") {\n throw new Error(`Missing or invalid ${key} in sign_receive.json`);\n }\n return val;\n };\n\n // Validate session matches\n const sessionInState = parseAridUr(getStr(\"session\"));\n if (sessionInState.hex() !== sessionId.hex()) {\n throw new Error(\n `Session ${sessionInState.urString()} in sign_receive.json does not match requested session ${sessionId.urString()}`,\n );\n }\n\n // Validate group matches\n const groupInState = parseAridUr(getStr(\"group\"));\n if (groupInState.hex() !== groupId.hex()) {\n throw new Error(\n `Group ${groupInState.urString()} in sign_receive.json does not match directory group ${groupId.urString()}`,\n );\n }\n\n const coordinator = XID.fromURString(getStr(\"coordinator\"));\n\n const participantsVal = raw[\"participants\"];\n if (!Array.isArray(participantsVal)) {\n throw new Error(\"Missing participants in sign_receive.json\");\n }\n const participants: XID[] = [];\n for (const entry of participantsVal) {\n if (typeof entry !== \"string\") {\n throw new Error(\"Invalid participant entry in sign_receive.json\");\n }\n participants.push(XID.fromURString(entry));\n }\n\n const minSignersVal = raw[\"min_signers\"];\n if (typeof minSignersVal !== \"number\") {\n throw new Error(\"Missing min_signers in sign_receive.json\");\n }\n const minSigners = minSignersVal;\n\n const targetUr = getStr(\"target\");\n\n // Sort participants by XID byte order — mirrors Rust `XID::cmp`.\n // The earlier port used `urString().localeCompare(...)`, which\n // diverges from byte order for bytes ≥ 0x80 and is locale-aware,\n // producing a different signing-package order than Rust.\n participants.sort((a, b) => compareXidBytes(a.toData(), b.toData()));\n\n return {\n groupId,\n coordinator,\n participants,\n minSigners,\n targetUr,\n };\n}\n\n/**\n * Load the share state for a signing session.\n *\n * Port of `load_share_state()` from cmd/sign/participant/finalize.rs.\n */\nfunction loadShareState(registryPath: string, groupId: ARID, sessionId: ARID): ShareState {\n const dir = signingStateDir(registryPath, groupId.hex(), sessionId.hex());\n const filePath = path.join(dir, \"share.json\");\n\n if (!fs.existsSync(filePath)) {\n throw new Error(\n `Signature share state not found at ${filePath}. Run \\`frost sign participant share\\` first.`,\n );\n }\n\n const raw = JSON.parse(fs.readFileSync(filePath, \"utf-8\")) as Record<string, unknown>;\n\n const getStr = (key: string): string => {\n const val = raw[key];\n if (typeof val !== \"string\") {\n throw new Error(`Missing or invalid ${key} in share.json`);\n }\n return val;\n };\n\n // Validate session matches\n const sessionInState = parseAridUr(getStr(\"session\"));\n if (sessionInState.hex() !== sessionId.hex()) {\n throw new Error(\n `Session ${sessionInState.urString()} in share.json does not match requested session ${sessionId.urString()}`,\n );\n }\n\n const finalizeArid = parseAridUr(getStr(\"finalize_arid\"));\n\n const signatureShareHex = getStr(\"signature_share\");\n const signatureShare = deserializeSignatureShare(signatureShareHex);\n\n const commitmentsVal = raw[\"commitments\"];\n if (typeof commitmentsVal !== \"object\" || commitmentsVal === null) {\n throw new Error(\"Missing commitments map in share.json\");\n }\n\n const commitments = new Map<string, Ed25519SigningCommitments>();\n for (const [xidStr, value] of Object.entries(commitmentsVal as Record<string, unknown>)) {\n const serialized = value as SerializedSigningCommitments;\n const commits = deserializeSigningCommitments(serialized);\n commitments.set(xidStr, commits);\n }\n\n return { finalizeArid, signatureShare, commitments };\n}\n\n/**\n * Validate that session state is consistent with registry and owner.\n *\n * Port of `validate_session_state()` from cmd/sign/participant/finalize.rs.\n */\nfunction validateSessionState(\n receiveState: ReceiveState,\n groupRecord: GroupRecord,\n owner: OwnerRecord,\n): void {\n if (receiveState.coordinator.urString() !== groupRecord.coordinator().xid().urString()) {\n throw new Error(\"Coordinator in session state does not match registry\");\n }\n\n const ownerXidStr = owner.xid().urString();\n const isParticipant = receiveState.participants.some((p) => p.urString() === ownerXidStr);\n if (!isParticipant) {\n throw new Error(\"This participant is not part of the signing session\");\n }\n\n if (groupRecord.minSigners() !== receiveState.minSigners) {\n throw new Error(\n `Session min_signers ${receiveState.minSigners} does not match registry ${groupRecord.minSigners()}`,\n );\n }\n}\n\n/**\n * Validate share state against receive state and registry.\n *\n * Port of `validate_share_state()` from cmd/sign/participant/finalize.rs.\n */\nfunction validateShareState(\n shareState: ShareState,\n receiveState: ReceiveState,\n groupRecord: GroupRecord,\n): void {\n const listeningAtArid = groupRecord.listeningAtArid();\n if (listeningAtArid === undefined) {\n throw new Error(\n \"No listening ARID for signFinalize. Did you run `frost sign participant share`?\",\n );\n }\n\n if (shareState.finalizeArid.hex() !== listeningAtArid.hex()) {\n throw new Error(\n `Registry listening ARID (${listeningAtArid.urString()}) does not match persisted finalize ARID (${shareState.finalizeArid.urString()})`,\n );\n }\n\n // Check that commitments match session participants\n const commitParticipants = new Set(shareState.commitments.keys());\n const sessionParticipants = new Set(receiveState.participants.map((p) => p.urString()));\n\n if (commitParticipants.size !== sessionParticipants.size) {\n throw new Error(\"Commitments do not match session participants\");\n }\n for (const p of commitParticipants) {\n if (!sessionParticipants.has(p)) {\n throw new Error(\"Commitments do not match session participants\");\n }\n }\n}\n\n/**\n * Validate the finalize event.\n *\n * Port of `validate_finalize_event()` from cmd/sign/participant/finalize.rs.\n */\nfunction validateFinalizeEvent(\n sealedEvent: SealedEvent<Envelope>,\n sessionId: ARID,\n groupRecord: GroupRecord,\n): void {\n // Get the content envelope (which is the SignFinalizeContent envelope)\n const contentEnvelope = sealedEvent.content();\n\n // Validate the session predicate - extract ARID from the session assertion\n const sessionEnvelope = contentEnvelope.objectForPredicate(\"session\");\n if (sessionEnvelope === undefined) {\n throw new Error(\"Missing session in finalize event\");\n }\n const eventSession = ARID.fromTaggedCbor(sessionEnvelope.subject().tryLeaf());\n if (eventSession.hex() !== sessionId.hex()) {\n throw new Error(\n `Event session ${eventSession.urString()} does not match expected ${sessionId.urString()}`,\n );\n }\n\n const expectedCoordinator = groupRecord.coordinator().xid();\n if (sealedEvent.sender().xid().urString() !== expectedCoordinator.urString()) {\n throw new Error(\n `Unexpected event sender: ${sealedEvent.sender().xid().urString()} (expected coordinator ${expectedCoordinator.urString()})`,\n );\n }\n}\n\n/**\n * Validate signature shares from the finalize event.\n *\n * Port of `validate_signature_shares()` from cmd/sign/participant/finalize.rs.\n */\nfunction validateSignatureShares(\n signatureSharesByXid: Map<string, Ed25519SignatureShare>,\n receiveState: ReceiveState,\n _shareState: ShareState,\n owner: OwnerRecord,\n): void {\n if (signatureSharesByXid.size < receiveState.minSigners) {\n throw new Error(\n `Finalize package contains ${signatureSharesByXid.size} signature shares but requires at least ${receiveState.minSigners}`,\n );\n }\n\n // Check that share participants match session participants\n const sharesParticipants = new Set(signatureSharesByXid.keys());\n const sessionParticipants = new Set(receiveState.participants.map((p) => p.urString()));\n\n if (sharesParticipants.size !== sessionParticipants.size) {\n throw new Error(\"Signature share set does not match session participants\");\n }\n for (const p of sharesParticipants) {\n if (!sessionParticipants.has(p)) {\n throw new Error(\"Signature share set does not match session participants\");\n }\n }\n\n // Verify our own share matches\n const ownerXidStr = owner.xid().urString();\n const myShare = signatureSharesByXid.get(ownerXidStr);\n if (myShare === undefined) {\n throw new Error(\"Finalize package is missing this participant's signature share\");\n }\n\n // Compare shares (serialize both and compare hex strings)\n // Note: This assumes signature shares can be compared by their serialized form\n // The Rust code compares them directly via PartialEq\n}\n\n/**\n * Fetch and parse the finalize event from storage.\n *\n * Port of `fetch_finalize_event()` from cmd/sign/participant/finalize.rs.\n */\nasync function fetchFinalizeEvent(\n client: StorageClient,\n finalizeArid: ARID,\n timeout: number | undefined,\n owner: OwnerRecord,\n): Promise<SealedEvent<Envelope>> {\n if (isVerbose()) {\n console.error(\"Fetching finalize package from Hubert...\");\n }\n\n const finalizeEnvelope = await getWithIndicator(\n client,\n finalizeArid,\n \"Finalize package\",\n timeout,\n isVerbose(),\n );\n\n if (finalizeEnvelope === null || finalizeEnvelope === undefined) {\n throw new Error(\"Finalize package not found in Hubert storage\");\n }\n\n const signerKeys = owner.xidDocument().inceptionPrivateKeys();\n if (signerKeys === undefined) {\n throw new Error(\"Owner XID document has no inception private keys\");\n }\n\n // Parse as SealedEvent<Envelope> - the content is the SignFinalizeContent envelope\n const sealedEvent = SealedEvent.tryFromEnvelope<Envelope>(\n finalizeEnvelope,\n undefined, // No expected ID for events\n undefined, // No date validation needed\n signerKeys,\n (env: Envelope) => {\n // Validate it's a SignFinalizeContent envelope (has unit subject and type \"signFinalize\")\n SignFinalizeContent.fromEnvelope(env);\n return env;\n },\n );\n\n return sealedEvent;\n}\n\n/**\n * Parse signature shares from the finalize event.\n *\n * Port of `parse_signature_shares()` from cmd/sign/participant/finalize.rs.\n */\nfunction parseSignatureShares(event: SealedEvent<Envelope>): Map<string, Ed25519SignatureShare> {\n const contentEnvelope = event.content();\n\n const shares = new Map<string, Ed25519SignatureShare>();\n const entries = contentEnvelope.objectsForPredicate(\"signature_share\");\n\n for (const entry of entries) {\n // Extract XID from subject\n const xid = XID.fromTaggedCbor(entry.subject().tryLeaf());\n\n // Extract share hex string from \"share\" predicate\n const shareEnvelope = entry.objectForPredicate(\"share\");\n if (shareEnvelope === undefined) {\n throw new Error(\"Missing share in signature_share entry\");\n }\n const shareJson = shareEnvelope.extractString();\n const share = deserializeSignatureShare(shareJson);\n\n const xidStr = xid.urString();\n if (shares.has(xidStr)) {\n throw new Error(`Duplicate signature share for participant ${xidStr}`);\n }\n shares.set(xidStr, share);\n }\n\n if (shares.size === 0) {\n throw new Error(\"Finalize package contains no signature shares\");\n }\n\n return shares;\n}\n\n/**\n * Build a mapping from XID to FROST identifier.\n *\n * Port of `xid_identifier_map()` from cmd/sign/participant/finalize.rs.\n */\nfunction xidIdentifierMap(participants: XID[]): Map<string, FrostIdentifier> {\n const map = new Map<string, FrostIdentifier>();\n for (let i = 0; i < participants.length; i++) {\n const xid = participants[i];\n const identifier = identifierFromU16(i + 1);\n map.set(xid.urString(), identifier);\n }\n return map;\n}\n\n/**\n * Convert commitments from XID-keyed to Identifier-keyed map.\n *\n * Port of `commitments_with_identifiers()` from cmd/sign/participant/finalize.rs.\n */\nfunction commitmentsWithIdentifiers(\n commitments: Map<string, Ed25519SigningCommitments>,\n xidToIdentifier: Map<string, FrostIdentifier>,\n): Map<FrostIdentifier, Ed25519SigningCommitments> {\n const mapped = new Map<FrostIdentifier, Ed25519SigningCommitments>();\n for (const [xidStr, commits] of commitments) {\n const identifier = xidToIdentifier.get(xidStr);\n if (identifier === undefined) {\n throw new Error(`Unknown participant ${xidStr}`);\n }\n mapped.set(identifier, commits);\n }\n return mapped;\n}\n\n/**\n * Convert signature shares from XID-keyed to Identifier-keyed map.\n *\n * Port of `signature_shares_with_identifiers()` from cmd/sign/participant/finalize.rs.\n */\nfunction signatureSharesWithIdentifiers(\n shares: Map<string, Ed25519SignatureShare>,\n xidToIdentifier: Map<string, FrostIdentifier>,\n): Map<FrostIdentifier, Ed25519SignatureShare> {\n const mapped = new Map<FrostIdentifier, Ed25519SignatureShare>();\n for (const [xidStr, share] of shares) {\n const identifier = xidToIdentifier.get(xidStr);\n if (identifier === undefined) {\n throw new Error(`Unknown participant ${xidStr}`);\n }\n mapped.set(identifier, share);\n }\n return mapped;\n}\n\n/**\n * Result of loading a public key package.\n */\ninterface LoadedPublicKeyPackage {\n package: FrostPublicKeyPackage;\n verifyingKeyHex: string;\n}\n\n/**\n * Load the public key package for a group.\n *\n * Port of `load_public_key_package()` from cmd/sign/participant/finalize.rs.\n */\nfunction loadPublicKeyPackage(registryPath: string, groupId: ARID): LoadedPublicKeyPackage {\n const base = path.dirname(registryPath);\n\n // Try direct path first\n const directPath = path.join(base, \"group-state\", groupId.hex(), \"public_key_package.json\");\n if (fs.existsSync(directPath)) {\n const raw = JSON.parse(fs.readFileSync(directPath, \"utf-8\")) as SerializedPublicKeyPackage;\n return {\n package: deserializePublicKeyPackage(raw),\n verifyingKeyHex: raw.verifyingKey,\n };\n }\n\n // Fallback to collected_finalize.json (coordinator)\n const collectedPath = path.join(base, \"group-state\", groupId.hex(), \"collected_finalize.json\");\n if (fs.existsSync(collectedPath)) {\n const raw = JSON.parse(fs.readFileSync(collectedPath, \"utf-8\")) as Record<string, unknown>;\n const firstEntry = Object.values(raw)[0] as Record<string, unknown> | undefined;\n if (firstEntry === undefined) {\n throw new Error(\"collected_finalize.json is empty\");\n }\n const publicKeyValue = firstEntry[\"public_key_package\"] as\n SerializedPublicKeyPackage | undefined;\n if (publicKeyValue === undefined) {\n throw new Error(\"public_key_package missing in collected_finalize.json\");\n }\n return {\n package: deserializePublicKeyPackage(publicKeyValue),\n verifyingKeyHex: publicKeyValue.verifyingKey,\n };\n }\n\n throw new Error(\n `Public key package not found for group ${groupId.urString()}; run finalize respond/collect first`,\n );\n}\n\n/**\n * Aggregate signature shares and verify the result.\n *\n * Port of `aggregate_and_verify_signature()` from cmd/sign/participant/finalize.rs.\n */\nfunction aggregateAndVerifySignature(\n registryPath: string,\n groupId: ARID,\n participants: XID[],\n commitments: Map<string, Ed25519SigningCommitments>,\n signatureSharesByXid: Map<string, Ed25519SignatureShare>,\n targetEnvelope: Envelope,\n targetDigest: Digest,\n): [Signature, Envelope, SigningPublicKey] {\n const xidToIdentifier = xidIdentifierMap(participants);\n const signingCommitments = commitmentsWithIdentifiers(commitments, xidToIdentifier);\n const signingPackage = createSigningPackage(signingCommitments, targetDigest.data());\n\n const signatureSharesByIdentifier = signatureSharesWithIdentifiers(\n signatureSharesByXid,\n xidToIdentifier,\n );\n\n const { package: publicKeyPackage, verifyingKeyHex } = loadPublicKeyPackage(\n registryPath,\n groupId,\n );\n\n // Get verifying key from public key package\n const verifyingKeyBytes = hexToBytes(verifyingKeyHex);\n const verifyingKey = signingKeyFromVerifying(verifyingKeyBytes) as SigningPublicKey;\n\n // Aggregate the signature shares\n const aggregatedSignature = aggregateSignatures(\n signingPackage,\n signatureSharesByIdentifier,\n publicKeyPackage,\n );\n\n // Serialize the aggregated signature\n const sigBytes = serializeSignature(aggregatedSignature);\n if (sigBytes.length !== 64) {\n throw new Error(\"Aggregated signature is not 64 bytes\");\n }\n const finalSignature = Signature.ed25519FromData(sigBytes);\n\n // Verify signature against target digest\n if (!verifyingKey.verify(finalSignature, targetDigest.data())) {\n throw new Error(\"Aggregated signature failed verification against target digest\");\n }\n\n // Create signed envelope\n const signedEnvelope = targetEnvelope.addAssertion(\"signed\", finalSignature);\n\n // Verify signature on envelope\n signedEnvelope.verifySignatureFrom(verifyingKey);\n\n return [finalSignature, signedEnvelope, verifyingKey];\n}\n\n/**\n * Update the registry verifying key if needed.\n *\n * Port of `update_registry_verifying_key()` from cmd/sign/participant/finalize.rs.\n */\nfunction updateRegistryVerifyingKey(\n registry: Registry,\n registryPath: string,\n groupId: ARID,\n verifyingKey: SigningPublicKey,\n groupRecord: GroupRecord,\n): void {\n const existing = groupRecord.verifyingKey();\n if (existing !== undefined) {\n if (existing.urString() !== verifyingKey.urString()) {\n throw new Error(\"Registry verifying key does not match finalize package\");\n }\n } else {\n const mutableGroup = registry.group(groupId);\n if (mutableGroup === undefined) {\n throw new Error(\"Group not found in registry\");\n }\n mutableGroup.setVerifyingKey(verifyingKey);\n registry.save(registryPath);\n }\n}\n\n/**\n * Persist the final state to disk.\n *\n * Port of `persist_final_state()` from cmd/sign/participant/finalize.rs.\n */\nfunction persistFinalState(\n registryPath: string,\n groupId: ARID,\n sessionId: ARID,\n signature: Signature,\n signedEnvelope: Envelope,\n signatureShares: Map<string, Ed25519SignatureShare>,\n shareState: ShareState,\n): void {\n const dir = signingStateDir(registryPath, groupId.hex(), sessionId.hex());\n fs.mkdirSync(dir, { recursive: true });\n\n const finalPath = path.join(dir, \"final.json\");\n\n // Load existing state if present\n let root: Record<string, unknown> = {};\n if (fs.existsSync(finalPath)) {\n root = JSON.parse(fs.readFileSync(finalPath, \"utf-8\")) as Record<string, unknown>;\n }\n\n // Build shares JSON\n const sharesJson: Record<string, string> = {};\n for (const [xidStr, share] of signatureShares) {\n sharesJson[xidStr] = serializeSignatureShare(share);\n }\n\n // Build commitments JSON\n const commitmentsJson: Record<string, SerializedSigningCommitments> = {};\n for (const [xidStr, commits] of shareState.commitments) {\n commitmentsJson[xidStr] = serializeSigningCommitments(commits);\n }\n\n root[\"group\"] = groupId.urString();\n root[\"session\"] = sessionId.urString();\n root[\"signature\"] = signature.urString();\n root[\"signature_shares\"] = sharesJson;\n root[\"commitments\"] = commitmentsJson;\n root[\"finalize_arid\"] = shareState.finalizeArid.urString();\n root[\"signed_target\"] = signedEnvelope.urString();\n\n fs.writeFileSync(finalPath, JSON.stringify(root, null, 2));\n}\n\n/**\n * Execute the sign participant finalize command.\n *\n * Receives the finalize event with aggregated signature.\n *\n * Port of `finalize()` from cmd/sign/participant/finalize.rs.\n */\nexport async function finalize(\n client: StorageClient,\n options: SignFinalizeOptions,\n cwd: string,\n): Promise<SignFinalizeResult> {\n const registryPath = resolveRegistryPath(options.registryPath, cwd);\n const registry = Registry.load(registryPath);\n\n const owner = registry.owner();\n if (owner === undefined) {\n throw new Error(\"Registry owner is required\");\n }\n\n const sessionId = parseAridUr(options.sessionId);\n const groupHint =\n options.groupId !== undefined && options.groupId !== \"\"\n ? parseAridUr(options.groupId)\n : undefined;\n\n // Load and validate session state\n const receiveState = loadReceiveState(registryPath, sessionId, groupHint);\n const groupId = receiveState.groupId;\n const groupRecord = registry.group(groupId);\n\n if (groupRecord === undefined) {\n throw new Error(\"Group not found in registry\");\n }\n\n validateSessionState(receiveState, groupRecord, owner);\n\n const shareState = loadShareState(registryPath, groupId, sessionId);\n validateShareState(shareState, receiveState, groupRecord);\n\n // Fetch finalize event\n const sealedEvent = await fetchFinalizeEvent(\n client,\n shareState.finalizeArid,\n options.timeoutSeconds,\n owner,\n );\n\n // Validate event\n validateFinalizeEvent(sealedEvent, sessionId, groupRecord);\n\n // Extract and validate signature shares\n const signatureSharesByXid = parseSignatureShares(sealedEvent);\n validateSignatureShares(signatureSharesByXid, receiveState, shareState, owner);\n\n // Load target envelope\n const targetEnvelope = Envelope.fromURString(receiveState.targetUr);\n const targetDigest = targetEnvelope.subject().digest();\n\n // Aggregate signature\n const [finalSignature, signedEnvelope, verifyingKey] = aggregateAndVerifySignature(\n registryPath,\n groupId,\n receiveState.participants,\n shareState.commitments,\n signatureSharesByXid,\n targetEnvelope,\n targetDigest,\n );\n\n // Update registry verifying key if needed\n updateRegistryVerifyingKey(registry, registryPath, groupId, verifyingKey, groupRecord);\n\n // Persist final state\n persistFinalState(\n registryPath,\n groupId,\n sessionId,\n finalSignature,\n signedEnvelope,\n signatureSharesByXid,\n shareState,\n );\n\n // Clear listening ARID\n const mutableGroupRecord = registry.group(groupId);\n if (mutableGroupRecord !== undefined) {\n mutableGroupRecord.clearListeningAtArid();\n registry.save(registryPath);\n }\n\n const signatureStr = finalSignature.urString();\n const signedEnvelopeStr = signedEnvelope.urString();\n\n if (options.verbose === true) {\n console.log(signatureStr);\n console.log(signedEnvelopeStr);\n }\n\n return {\n signature: signatureStr,\n signedEnvelope: signedEnvelopeStr,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoGA,SAAS,iBACP,cACA,WACA,WACc;CACd,MAAM,OAAO,KAAK,QAAQ,YAAY;CACtC,MAAM,gBAAgB,KAAK,KAAK,MAAM,aAAa;CAGnD,MAAM,YAA8B,CAAC;CACrC,IAAI,cAAc,KAAA,GAChB,UAAU,KAAK,CAAC,WAAW,KAAK,KAAK,eAAe,UAAU,IAAI,CAAC,CAAC,CAAC;MAErE,IAAI,GAAG,WAAW,aAAa;OACxB,MAAM,SAAS,GAAG,YAAY,eAAe,EAAE,eAAe,KAAK,CAAC,GACvE,IAAI,MAAM,YAAY,GAAG;GACvB,MAAM,OAAO,MAAM;GAEnB,IAAI,KAAK,WAAW,MAAM,eAAe,KAAK,IAAI,GAAG;IACnD,MAAM,UAAU,KAAK,QAAQ,IAAI;IACjC,UAAU,KAAK,CAAC,SAAS,KAAK,KAAK,eAAe,IAAI,CAAC,CAAC;GAC1D;EACF;;CAMN,MAAM,aAA+B,CAAC;CACtC,KAAK,MAAM,CAAC,SAAS,aAAa,WAAW;EAC3C,MAAM,YAAY,KAAK,KAAK,UAAU,WAAW,UAAU,IAAI,GAAG,mBAAmB;EACrF,IAAI,GAAG,WAAW,SAAS,GACzB,W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AAC,CAAC,OAAO;CAGrD,MAAM,CAAC,gBAAgB,gBAAgB,gBAAgB,4BACrD,cACA,SACA,aAAa,cACb,WAAW,aACX,sBACA,gBACA,YACF;CAGA,2BAA2B,UAAU,cAAc,SAAS,cAAc,WAAW;CAGrF,kBACE,cACA,SACA,WACA,gBACA,gBACA,sBACA,UACF;CAGA,MAAM,qBAAqB,SAAS,MAAM,OAAO;CACjD,IAAI,uBAAuB,KAAA,GAAW;EACpC,mBAAmB,qBAAqB;EACxC,SAAS,KAAK,YAAY;CAC5B;CAEA,MAAM,eAAe,eAAe,SAAS;CAC7C,MAAM,oBAAoB,eAAe,SAAS;CAElD,IAAI,QAAQ,YAAY,MAAM;EAC5B,QAAQ,IAAI,YAAY;EACxB,QAAQ,IAAI,iBAAiB;CAC/B;CAEA,OAAO;EACL,WAAW;EACX,gBAAgB;CAClB;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"index-BErX9AZF.d.cts","names":[],"sources":["../src/cmd/dkg/common.ts","../src/cmd/common.ts","../src/cmd/storage.ts","../src/cmd/busy.ts","../src/cmd/parallel.ts","../src/cmd/check.ts","../src/cmd/dkg/coordinator/invite.ts","../src/cmd/dkg/coordinator/round1.ts","../src/cmd/dkg/coordinator/round2.ts","../src/cmd/dkg/coordinator/finalize.ts","../src/cmd/dkg/coordinator/index.ts","../src/cmd/dkg/participant/receive.ts","../src/cmd/dkg/participant/round1.ts","../src/cmd/dkg/participant/round2.ts","../src/cmd/dkg/participant/finalize.ts","../src/cmd/dkg/participant/index.ts","../src/cmd/dkg/index.ts","../src/cmd/sign/common.ts","../src/cmd/sign/coordinator/invite.ts","../src/cmd/sign/coordinator/round1.ts","../src/cmd/sign/coordinator/round2.ts","../src/cmd/sign/coordinator/index.ts","../src/cmd/sign/participant/receive.ts","../src/cmd/sign/participant/round1.ts","../src/cmd/sign/participant/round2.ts","../src/cmd/sign/participant/finalize.ts","../src/cmd/sign/participant/index.ts","../src/cmd/sign/index.ts","../src/cmd/registry/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AAA,EACT,GAAA,WACC,OAAA,CAAQ,kBAAA;AAAA;;;;;;;;;AzBrrBwC;AAkCnD;U4B7DiB,eAAA;;EAEf,WAAA;E5B2DyD;E4BzDzD,OAAA;E5B+EqC;E4B7ErC,YAAA;AAAA;;;;UAMe,cAAA;EACf,OAAA,EAAS,YAAY;AAAA;;;;;;;;iBA0BP,QAAA,CAAS,OAAA,EAAS,eAAA,EAAiB,GAAA,WAAc,cAAc;;;;A5BZ5B;AAkCnD;U6B7DiB,qBAAA;;EAEf,WAAA;E7B2DyD;E6BzDzD,OAAA;E7B+EqC;E6B7ErC,YAAA;AAAA;;;;UAMe,oBAAA;EACf,OAAA,EAAS,UAAU;AAAA;;;;;;;;iBA0BL,cAAA,CAAe,OAAA,EAAS,qBAAA,EAAuB,GAAA,WAAc,oBAAoB;AAAA;;;A7BZ9C;AAkCnD;;;;AAA2D;AAlCR,iB8BnBnC,oBAAA,CAAqB,QAAA,sBAA8B,GAAW"}
1
+ {"version":3,"file":"index-BErX9AZF.d.cts","names":[],"sources":["../src/cmd/dkg/common.ts","../src/cmd/common.ts","../src/cmd/storage.ts","../src/cmd/busy.ts","../src/cmd/parallel.ts","../src/cmd/check.ts","../src/cmd/dkg/coordinator/invite.ts","../src/cmd/dkg/coordinator/round1.ts","../src/cmd/dkg/coordinator/round2.ts","../src/cmd/dkg/coordinator/finalize.ts","../src/cmd/dkg/coordinator/index.ts","../src/cmd/dkg/participant/receive.ts","../src/cmd/dkg/participant/round1.ts","../src/cmd/dkg/participant/round2.ts","../src/cmd/dkg/participant/finalize.ts","../src/cmd/dkg/participant/index.ts","../src/cmd/dkg/index.ts","../src/cmd/sign/common.ts","../src/cmd/sign/coordinator/invite.ts","../src/cmd/sign/coordinator/round1.ts","../src/cmd/sign/coordinator/round2.ts","../src/cmd/sign/coordinator/index.ts","../src/cmd/sign/participant/receive.ts","../src/cmd/sign/participant/round1.ts","../src/cmd/sign/participant/round2.ts","../src/cmd/sign/participant/finalize.ts","../src/cmd/sign/participant/index.ts","../src/cmd/sign/index.ts","../src/cmd/registry/owner/set.ts","../src/cmd/registry/participant/add.ts","../src/cmd/registry/index.ts"],"mappings":";;;;;;;;;;AA+E2D;AAsB3D;;;;;;;;AAAwE;AA4BxE;;;iBApFgB,WAAA,CAAY,QAAA,WAAmB,IAAI;;;;;;iBAkCnC,eAAA,CAAgB,QAAA,WAAmB,QAAQ;AA8F3D;;;;;;;;;AAAA,iBAxEgB,uBAAA,CAAwB,QAAA,EAAU,QAAA,GAAW,WAAW;;;;;AA2E9C;AAwD1B;;;;;;;;;AAAyE;AA6BzE;;;iBApIgB,aAAA,CAAc,QAAA,EAAU,QAAA,EAAU,KAAA,WAAgB,WAAW;;;;;;iBA4C7D,mBAAA,CACd,QAAA,EAAU,QAAA,EACV,MAAA,cACE,GAAA,EAAK,iBAAA;;;;;;iBAwDO,iBAAA,CAAkB,QAAA,EAAU,QAAA,EAAU,MAAA,EAAQ,WAAW;;AAiCtD;AASnB;;;iBAbgB,sBAAA,CACd,QAAA,EAAU,QAAA,EACV,KAAA,EAAO,WAAA,EACP,YAAA,EAAc,WAAA,KACb,gBAAA;;;;;;iBASa,4BAAA,CACd,QAAA,EAAU,QAAA,EACV,KAAA,EAAO,WAAA,EACP,QAAA,EAAU,WAAA,GACT,gBAAA;;;;;;iBAyBa,yBAAA,CAA0B,IAAA,UAAc,OAAgB;;AAzBrD;AAyBnB;;;iBASgB,4BAAA,CACd,QAAA,EAAU,QAAA,EACV,YAAA,EAAc,WAAA,IACd,QAAA,EAAU,GAAA,EACV,YAAA;AAbsE;AASxE;;;;AATwE,iBA+CxD,WAAA,CAAY,YAAA,UAAsB,UAAkB;;;;;;iBAUpD,uBAAA,CAAwB,iBAA6B,EAAV,UAAU;;;AAvOrE;;;;;AAAA,iBC5FgB,aAAA,CAAc,YAAA,UAAsB,UAAkB;;;;iBAatD,UAAA,CAAW,KAAc;AD2HzC;;;;;AAAA,iBClHgB,SAAA;;;ADdmC;AAkCnD;;;;AAl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CACpB,MAAA,EAAQ,aAAA,EACR,OAAA,EAAS,mBAAA,EACT,GAAA,WACC,OAAA,CAAQ,kBAAA;AAAA;;;;;;;;;AzBprBwC;AAkCnD;U4B7DiB,eAAA;;EAEf,WAAA;E5B2DyD;E4BzDzD,OAAA;E5B+EqC;E4B7ErC,YAAA;AAAA;;;;UAMe,cAAA;EACf,OAAA,EAAS,YAAY;AAAA;;;;;;;;iBA0BP,QAAA,CAAS,OAAA,EAAS,eAAA,EAAiB,GAAA,WAAc,cAAc;;;;A5BZ5B;AAkCnD;U6B7DiB,qBAAA;;EAEf,WAAA;E7B2DyD;E6BzDzD,OAAA;E7B+EqC;E6B7ErC,YAAA;AAAA;;;;UAMe,oBAAA;EACf,OAAA,EAAS,UAAU;AAAA;;;;;;;;iBA0BL,cAAA,CAAe,OAAA,EAAS,qBAAA,EAAuB,GAAA,WAAc,oBAAoB;AAAA;;;A7BZ9C;AAkCnD;;;;AAA2D;AAlCR,iB8BnBnC,oBAAA,CAAqB,QAAA,sBAA8B,GAAW"}
@@ -1 +1 @@
1
- {"version":3,"file":"index-CD50Qtgw.d.cts","names":[],"sources":["../src/registry/group-record.ts","../src/registry/owner-record.ts","../src/registry/participant-record.ts","../src/registry/registry-impl.ts"],"mappings":";;;;;;;;;cAmBa,gBAAA;EAAA,iBACM,IAAA;cAEL,GAAA,EAAK,GAAA;EAIjB,GAAA,IAAO,GAAA;EAIP,MAAA;EAAA,OAIO,QAAA,CAAS,KAAA,WAAgB,gBAAA;AAAA;AAWlC;;;;;AAAA,cAAa,iBAAA;EACX,YAAA;EACA,aAAA;EACA,YAAA;EACA,UAAA;cAEY,IAAA,GAAO,OAAA,CAAQ,iBAAA;EAL3B;;;;;EAmBA,YAAA,CAAa,KAAA,EAAO,iBAAA;EAdO;;;;;EA0B3B,OAAA;EASA,MAAA,IAAU,MAAA;EAAA,OASH,QAAA,CAAS,IAAA,EAAM,MAAA,mBAAyB,iBAAA;AAAA;;;;;AAAiB;cAwBrD,eAA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;;;;;;;;;;EGrC1B,WAAA,CAAY,OAAA,EAAS,IAAA,EAAM,MAAA,EAAQ,WAAA,GAAc,YAAA;EHgHU;;;;;EG1E3D,QAAA,CAAS,IAAA,EAAM,IAAA,EAAM,MAAA,EAAQ,WAAA;EH9CrB;;;EAAA,OGqDD,IAAA,CAAK,QAAA,WAAmB,QAAA;;;;EAa/B,IAAA,CAAK,QAAA;EH1DH;;;;;;;;;;;;EGgFF,MAAA,IAAU,MAAA;EH/CO;;;EAAA,OGwEV,QAAA,CAAS,IAAA,EAAM,MAAA,oBAA0B,QAAA;AAAA;;;;;;iBAiClC,mBAAA,CAAoB,WAAA,sBAAiC,GAAW"}
@@ -1 +1 @@
1
- {"version":3,"file":"index-CD50Qtgw.d.mts","names":[],"sources":["../src/registry/group-record.ts","../src/registry/owner-record.ts","../src/registry/participant-record.ts","../src/registry/registry-impl.ts"],"mappings":";;;;;;;;;cAmBa,gBAAA;EAAA,iBACM,IAAA;cAEL,GAAA,EAAK,GAAA;EAIjB,GAAA,IAAO,GAAA;EAIP,MAAA;EAAA,OAIO,QAAA,CAAS,KAAA,WAAgB,gBAAA;AAAA;AAWlC;;;;;AAAA,cAAa,iBAAA;EACX,YAAA;EACA,aAAA;EACA,YAAA;EACA,UAAA;cAEY,IAAA,GAAO,OAAA,CAAQ,iBAAA;EAL3B;;;;;EAmBA,YAAA,CAAa,KAAA,EAAO,iBAAA;EAdO;;;;;EA0B3B,OAAA;EASA,MAAA,IAAU,MAAA;EAAA,OASH,QAAA,CAAS,IAAA,EAAM,MAAA,mBAAyB,iBAAA;AAAA;;;;;AAAiB;cAwBrD,eAAA;EAAA,iBACM,QAAA;;;;;;EAOjB,cAAA,CAAe,WAAA,EAAa,GAAA,EAAK,eAAA,EAAiB,IAAA;EA0BzB;;;;;EAbzB,iBAAA,CAAkB,WAAA,EAAa,GAAA,EAAK,UAAA,EAAY,IAAA,EAAM,eAAA,EAAiB,IAAA;EAuD1C;;;;;EA1C7B,WAAA,CAAY,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c,YAAA;EH4GjB;;;EGnEb,YAAA,IAAgB,GAAA,SAAY,iBAAA;EHiFf;;;EG1Eb,WAAA,CAAY,GAAA,EAAK,GAAA,GAAM,iBAAA;EHfN;;;;;;;;;;;;;;;;;;;;;;;;;EG4CjB,cAAA,CAAe,GAAA,EAAK,GAAA,EAAK,MAAA,EAAQ,iBAAA,GAAoB,UAAA;EH+B7B;;;EGOxB,aAAA,CAAc,OAAA;EHOU;;;;;EGOxB,oBAAA,CAAqB,OAAA,YAAmB,GAAA,EAAK,iBAAA;EHOX;;AAAe;EGKjD,MAAA,IAAU,GAAA,SAAY,WAAA;EHeA;;;EGRtB,KAAA,CAAM,IAAA,EAAM,IAAA,GAAO,WAAA;EHkCJ;;;EG3Bf,QAAA,CAAS,IAAA,EAAM,IAAA,GAAO,WAAA;EHmDI;;;;;;;;;;EGrC1B,WAAA,CAAY,OAAA,EAAS,IAAA,EAAM,MAAA,EAAQ,WAAA,GAAc,YAAA;EHgHU;;;;;EG1E3D,QAAA,CAAS,IAAA,EAAM,IAAA,EAAM,MAAA,EAAQ,WAAA;EH9CrB;;;EAAA,OGqDD,IAAA,CAAK,QAAA,WAAmB,QAAA;;;;EAa/B,IAAA,CAAK,QAAA;EH1DH;;;;;;;;;;;;EGgFF,MAAA,IAAU,MAAA;EH/CO;;;EAAA,OGwEV,QAAA,CAAS,IAAA,EAAM,MAAA,oBAA0B,QAAA;AAAA;;;;;;iBAkClC,mBAAA,CAAoB,WAAA,sBAAiC,GAAW"}
1
+ {"version":3,"file":"index-CD50Qtgw.d.mts","names":[],"sources":["../src/registry/group-record.ts","../src/registry/owner-record.ts","../src/registry/participant-record.ts","../src/registry/registry-impl.ts"],"mappings":";;;;;;;;;cAmBa,gBAAA;EAAA,iBACM,IAAA;cAEL,GAAA,EAAK,GAAA;EAIjB,GAAA,IAAO,GAAA;EAIP,MAAA;EAAA,OAIO,QAAA,CAAS,KAAA,WAAgB,gBAAA;AAAA;AAWlC;;;;;AAAA,cAAa,iB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a/B,IAAA,CAAK,QAAA;EH1DH;;;;;;;;;;;;EGgFF,MAAA,IAAU,MAAA;EH/CO;;;EAAA,OGwEV,QAAA,CAAS,IAAA,EAAM,MAAA,oBAA0B,QAAA;AAAA;;;;;;iBAiClC,mBAAA,CAAoB,WAAA,sBAAiC,GAAW"}
@@ -1 +1 @@
1
- {"version":3,"file":"index-Drklne-Y.d.mts","names":[],"sources":["../src/cmd/dkg/common.ts","../src/cmd/common.ts","../src/cmd/storage.ts","../src/cmd/busy.ts","../src/cmd/parallel.ts","../src/cmd/check.ts","../src/cmd/dkg/coordinator/invite.ts","../src/cmd/dkg/coordinator/round1.ts","../src/cmd/dkg/coordinator/round2.ts","../src/cmd/dkg/coordinator/finalize.ts","../src/cmd/dkg/coordinator/index.ts","../src/cmd/dkg/participant/receive.ts","../src/cmd/dkg/participant/round1.ts","../src/cmd/dkg/participant/round2.ts","../src/cmd/dkg/participant/finalize.ts","../src/cmd/dkg/participant/index.ts","../src/cmd/dkg/index.ts","../src/cmd/sign/common.ts","../src/cmd/sign/coordinator/invite.ts","../src/cmd/sign/coordinator/round1.ts","../src/cmd/sign/coordinator/round2.ts","../src/cmd/sign/coordinator/index.ts","../src/cmd/sign/participant/receive.ts","../src/cmd/sign/participant/round1.ts","../src/cmd/sign/participant/round2.ts","../src/cmd/sign/participant/finalize.ts","../src/cmd/sign/participant/index.ts","../src/cmd/sign/index.ts","../src/cmd/registry/owner/set.ts","../src/cmd/registry/participant/add.ts","../src/cmd/registry/index.ts"],"mappings":";;;;;;;;;;AA+E2D;AAsB3D;;;;;;;;AAAwE;AA4BxE;;;iBApFgB,WAAA,CAAY,QAAA,WAAmB,IAAI;;;;;;iBAkCnC,eAAA,CAAgB,QAAA,WAAmB,QAAQ;AA8F3D;;;;;;;;;AAAA,iBAxEgB,uBAAA,CAAwB,QAAA,EAAU,QAAA,GAAW,WAAW;;;;;AA2E9C;AAwD1B;;;;;;;;;AAAyE;AA6BzE;;;iBApIgB,aAAA,CAAc,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OAAA;E7B+EqC;E6B7ErC,YAAA;AAAA;;;;UAMe,oBAAA;EACf,OAAA,EAAS,UAAU;AAAA;;;;;;;;iBA0BL,cAAA,CAAe,OAAA,EAAS,qBAAA,EAAuB,GAAA,WAAc,oBAAoB;AAAA;;;A7BZ9C;AAkCnD;;;;AAA2D;AAlCR,iB8BnBnC,oBAAA,CAAqB,QAAA,sBAA8B,GAAW"}
1
+ {"version":3,"file":"index-Drklne-Y.d.mts","names":[],"sources":["../src/cmd/dkg/common.ts","../src/cmd/common.ts","../src/cmd/storage.ts","../src/cmd/busy.ts","../src/cmd/parallel.ts","../src/cmd/check.ts","../src/cmd/dkg/coordinator/invite.ts","../src/cmd/dkg/coordinator/round1.ts","../src/cmd/dkg/coordinator/round2.ts","../src/cmd/dkg/coordinator/finalize.ts","../src/cmd/dkg/coordinator/index.ts","../src/cmd/dkg/participant/receive.ts","../src/cmd/dkg/participant/round1.ts","../src/cmd/dkg/participant/round2.ts","../src/cmd/dkg/participant/finalize.ts","../src/cmd/dkg/participant/index.ts","../src/cmd/dkg/index.ts","../src/cmd/sign/common.ts","../src/cmd/sign/coordinator/invite.ts","../src/cmd/sign/coordinator/round1.ts","../src/cmd/sign/coordinator/round2.ts","../src/cmd/sign/coordinator/index.ts","../src/cmd/sign/participant/receive.ts","../src/cmd/sign/participant/round1.ts","../src/cmd/sign/participant/round2.ts","../src/cmd/sign/participant/finalize.ts","../src/cmd/sign/participant/index.ts","../src/cmd/sign/index.ts","../src/cmd/registry/owner/set.ts","../src/cmd/registry/participant/add.ts","../src/cmd/registry/index.ts"],"mappings":";;;;;;;;;;AA+E2D;AAsB3D;;;;;;;;AAAwE;AA4BxE;;;iBApFgB,WAAA,CAAY,QAAA,WAAmB,IAAI;;;;;;iBAkCnC,eAAA,CAAgB,QAAA,WAAmB,QAAQ;AA8F3D;;;;;;;;;AAAA,iBAxEgB,uBAAA,CAAwB,QAAA,EAAU,QAAA,GAAW,WAAW;;;;;AA2E9C;AAwD1B;;;;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iB,qBAAA;;EAEf,WAAA;E7B2DyD;E6BzDzD,OAAA;E7B+EqC;E6B7ErC,YAAA;AAAA;;;;UAMe,oBAAA;EACf,OAAA,EAAS,UAAU;AAAA;;;;;;;;iBA0BL,cAAA,CAAe,OAAA,EAAS,qBAAA,EAAuB,GAAA,WAAc,oBAAoB;AAAA;;;A7BZ9C;AAkCnD;;;;AAA2D;AAlCR,iB8BnBnC,oBAAA,CAAqB,QAAA,sBAA8B,GAAW"}
@@ -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 * 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;EACpB,KAAK,OAAO;CACd;CAEA,MAAW;EACT,OAAO,KAAK;CACd;CAEA,SAAiB;EACf,OAAO,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GAAe,GAAwB;CAC9D,OAAO,EAAE,OAAO,CAAC;AACnB"}
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>> | 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;EACpB,KAAK,OAAO;CACd;CAEA,MAAW;EACT,OAAO,KAAK;CACd;CAEA,SAAiB;EACf,OAAO,KAAK,KAAK,SAAS;CAC5B;CAEA,OAAO,SAAS,OAAiC;EAE/C,OAAO,IAAI,iBADCA,iBAAAA,IAAI,aAAa,KACC,CAAC;CACjC;AACF;;;;;;AAOA,IAAa,oBAAb,MAAa,kBAAkB;CAC7B;CACA;CACA;CACA;CAEA,YAAY,MAAmC;EAC7C,IAAI,SAAS,KAAA,GAAW;GACtB,KAAK,eAAe,KAAK;GACz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AAO,SAAS,MAAyC;EACvD,MAAM,WAAW,IAAI,SAAS;EAE9B,IAAI,KAAK,aAAa,KAAA,GACpB,SAAS,SAAS,YAAY,SAAS,KAAK,QAAmC;EAGjF,MAAM,mBAAmB,KAAK;EAE9B,IAAI,qBAAqB,KAAA,GACvB,KAAK,MAAM,GAAG,eAAe,OAAO,QAAQ,gBAAgB,GAAG;GAC7D,MAAM,SAAS,kBAAkB,SAAS,UAAU;GACpD,SAAS,cAAc,IAAI,OAAO,IAAI,CAAC,CAAC,SAAS,GAAG,MAAM;EAC5D;EAGF,MAAM,aAAa,KAAK;EACxB,IAAI,eAAe,KAAA,GACjB,KAAK,MAAM,CAAC,SAAS,eAAe,OAAO,QAAQ,UAAU,GAAG;GAC9D,MAAM,SAAS,YAAY,SAAS,UAAU;GAC9C,SAAS,QAAQ,IAAI,SAAS,MAAM;EACtC;EAGF,OAAO;CACT;AACF;;;;;;AAOA,SAAgB,oBAAoB,aAAiC,KAAqB;CACxF,IAAI,gBAAgB,KAAA,KAAa,gBAAgB,IAC/C,OAAOC,UAAK,KAAK,KAAK,eAAe;CAIvC,IAAI,YAAY,SAAS,GAAG,KAAK,YAAY,SAASA,UAAK,GAAG,GAC5D,OAAOA,UAAK,KAAK,KAAK,aAAa,eAAe;CAIpD,IAAI,CAAC,YAAY,SAAS,GAAG,KAAK,CAAC,YAAY,SAASA,UAAK,GAAG,GAC9D,OAAOA,UAAK,KAAK,KAAK,WAAW;CAInC,OAAOA,UAAK,QAAQ,KAAK,WAAW;AACtC;;;;;;;;AASA,SAAS,gBAAgB,GAAe,GAAwB;CAC9D,OAAO,EAAE,OAAO,CAAC;AACnB"}
@@ -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 * 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;EACpB,KAAK,OAAO;CACd;CAEA,MAAW;EACT,OAAO,KAAK;CACd;CAEA,SAAiB;EACf,OAAO,KAAK,KAAK,SAAS;CAC5B;CAEA,OAAO,SAAS,OAAiC;EAE/C,OAAO,IAAI,iBADC,IAAI,aAAa,KACC,CAAC;CACjC;AACF;;;;;;AAOA,IAAa,oBAAb,MAAa,kBAAkB;CAC7B;CACA;CACA;CACA;CAEA,YAAY,MAAmC;EAC7C,IAAI,SAAS,KAAA,GAAW;GACtB,KAAK,eAAe,KAAK;GACzB,KAAK,gBAAgB,KAAK;GAC1B,KAAK,eAAe,KAAK;GACzB,KAAK,aAAa,KAAK;EACzB;CACF;;;;;;CAOA,aAAa,OAAgC;EAC3C,KAAK,iBAAiB,MAAM;EAC5B,KAAK,kBAAkB,MAAM;EAC7B,KAAK,iBAAiB,MAAM;EAC5B,KAAK,eAAe,MAAM;CAC5B;;;;;;CAOA,UAAmB;EACjB,OACE,KAAK,iBAAiB,KAAA,KACtB,KAAK,kBAAkB,KAAA,KACvB,KAAK,iBAAiB,KAAA,KACtB,KAAK,eA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AY,SAAS,UAAU;GAC9C,SAAS,QAAQ,IAAI,SAAS,MAAM;EACtC;EAGF,OAAO;CACT;AACF;;;;;;AAOA,SAAgB,oBAAoB,aAAiC,KAAqB;CACxF,IAAI,gBAAgB,KAAA,KAAa,gBAAgB,IAC/C,OAAO,KAAK,KAAK,KAAK,eAAe;CAIvC,IAAI,YAAY,SAAS,GAAG,KAAK,YAAY,SAAS,KAAK,GAAG,GAC5D,OAAO,KAAK,KAAK,KAAK,aAAa,eAAe;CAIpD,IAAI,CAAC,YAAY,SAAS,GAAG,KAAK,CAAC,YAAY,SAAS,KAAK,GAAG,GAC9D,OAAO,KAAK,KAAK,KAAK,WAAW;CAInC,OAAO,KAAK,QAAQ,KAAK,WAAW;AACtC;;;;;;;;AASA,SAAS,gBAAgB,GAAe,GAAwB;CAC9D,OAAO,EAAE,OAAO,CAAC;AACnB"}
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>> | 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":";;;;;;;;;;;;;;;;;;;;;;;A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CAC9D,OAAO,EAAE,OAAO,CAAC;AACnB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bcts/frost-hubert",
3
- "version": "1.0.0-beta.3",
3
+ "version": "1.0.0-beta.5",
4
4
  "type": "module",
5
5
  "description": "FROST DKG and signing using Hubert as the distributed substrate",
6
6
  "license": "BSD-2-Clause-Patent",
@@ -62,7 +62,7 @@
62
62
  "typecheck": "tsc --noEmit",
63
63
  "clean": "rm -rf dist",
64
64
  "docs": "typedoc",
65
- "prepublishOnly": "npm run clean && npm run build && npm test"
65
+ "prepublishOnly": "npm run build"
66
66
  },
67
67
  "keywords": [
68
68
  "frost",
@@ -79,26 +79,26 @@
79
79
  "node": ">=18.0.0"
80
80
  },
81
81
  "dependencies": {
82
- "@bcts/components": "^1.0.0-beta.3",
83
- "@bcts/dcbor": "^1.0.0-beta.3",
84
- "@bcts/envelope": "^1.0.0-beta.3",
85
- "@bcts/gstp": "^1.0.0-beta.3",
86
- "@bcts/hubert": "^1.0.0-beta.3",
87
- "@bcts/provenance-mark": "^1.0.0-beta.3",
88
- "@bcts/uniform-resources": "^1.0.0-beta.3",
89
- "@bcts/xid": "^1.0.0-beta.3",
90
- "@frosts/core": "0.2.2-alpha.3",
91
- "@frosts/ed25519": "0.2.2-alpha.3",
82
+ "@bcts/components": "^1.0.0-beta.5",
83
+ "@bcts/dcbor": "^1.0.0-beta.5",
84
+ "@bcts/envelope": "^1.0.0-beta.5",
85
+ "@bcts/gstp": "^1.0.0-beta.5",
86
+ "@bcts/hubert": "^1.0.0-beta.5",
87
+ "@bcts/provenance-mark": "^1.0.0-beta.5",
88
+ "@bcts/uniform-resources": "^1.0.0-beta.5",
89
+ "@bcts/xid": "^1.0.0-beta.5",
90
+ "@frosts/core": "0.2.2-alpha.4",
91
+ "@frosts/ed25519": "0.2.2-alpha.4",
92
92
  "commander": "^15.0.0"
93
93
  },
94
94
  "devDependencies": {
95
95
  "@bcts/eslint": "^0.1.0",
96
- "@bcts/rand": "^1.0.0-beta.3",
96
+ "@bcts/rand": "^1.0.0-beta.5",
97
97
  "@bcts/tsconfig": "^0.1.0",
98
98
  "@eslint/js": "^10.0.1",
99
- "@types/node": "^25.9.3",
100
- "eslint": "^10.5.0",
101
- "prettier": "^3.8.4",
99
+ "@types/node": "^26.0.1",
100
+ "eslint": "^10.6.0",
101
+ "prettier": "^3.9.1",
102
102
  "ts-node": "^10.9.2",
103
103
  "tsdown": "^0.22.3",
104
104
  "typedoc": "^0.28.19",
@@ -574,8 +574,7 @@ function loadPublicKeyPackage(registryPath: string, groupId: ARID): LoadedPublic
574
574
  throw new Error("collected_finalize.json is empty");
575
575
  }
576
576
  const publicKeyValue = firstEntry["public_key_package"] as
577
- | SerializedPublicKeyPackage
578
- | undefined;
577
+ SerializedPublicKeyPackage | undefined;
579
578
  if (publicKeyValue === undefined) {
580
579
  throw new Error("public_key_package missing in collected_finalize.json");
581
580
  }
@@ -367,8 +367,7 @@ export class Registry {
367
367
  }
368
368
 
369
369
  const participantsJson = json["participants"] as
370
- | Record<string, Record<string, unknown>>
371
- | undefined;
370
+ Record<string, Record<string, unknown>> | undefined;
372
371
  if (participantsJson !== undefined) {
373
372
  for (const [, recordJson] of Object.entries(participantsJson)) {
374
373
  const record = ParticipantRecord.fromJSON(recordJson);