@ocap/mpc-hsm 0.0.0-stage → 1.33.6

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.
@@ -0,0 +1,76 @@
1
+ //#region src/constants.d.ts
2
+ /**
3
+ * Protocol, curve, domain-separation, and 3D envelope constants for `@ocap/mpc-hsm`.
4
+ *
5
+ * Security invariants:
6
+ * - Virtual root secret `x_root` and child secret `x_child = (x_root + t_tweak) mod n` are NEVER
7
+ * materialized on any online machine, and zero secret-key export methods exist in this package.
8
+ * - All Fiat-Shamir challenges, NUMS generators, tweaks, OT row pads, presignature IDs, and
9
+ * Groth-Shoup re-randomization scalars use explicit versioned domain-separation tags.
10
+ */
11
+ declare const MPC_PROTOCOL_VERSION: 2;
12
+ declare const DEFAULT_ONLINE_THRESHOLD: 3;
13
+ declare const DEFAULT_ONLINE_PARTIES: 5;
14
+ declare const DEFAULT_COLD_THRESHOLD: 2;
15
+ declare const DEFAULT_COLD_GUARDIANS: 3;
16
+ declare const MAX_MPC_CLUSTER_NODES: 7;
17
+ declare const BSGS_M: 680;
18
+ declare const OT_KAPPA_BITS: 128;
19
+ declare const OT_KAPPA_BYTES: 16;
20
+ declare const OT_BASE_PARTIAL_BITS: 256;
21
+ declare const OT_LHL_EXTRA_BITS: 512;
22
+ declare const OT_GADGET_BITS: 768;
23
+ declare const OT_SACRIFICE_BITS: 256;
24
+ declare const OT_EXTENSION_ROWS: 1024;
25
+ declare const OT_COLUMN_BYTES: 128;
26
+ declare const MAX_MPC_SIGN_REQUEST_BYTES: 262144;
27
+ declare const MAX_MPC_PEER_MESSAGE_BYTES: 524288;
28
+ declare const MAX_RECOVERY_PACKAGE_BYTES: 2097152;
29
+ declare const MAX_RULE_YAML_BYTES: 16384;
30
+ declare const MAX_RULE_DAG_NODES: 128;
31
+ declare const MAX_ON_DEMAND_SILENCE_SECONDS: 604800;
32
+ declare const ESCAPE_DRILL_MAX_AGE_SECONDS: 2592000;
33
+ declare const SECP256K1_P = 115792089237316195423570985008687907853269984665640564039457584007908834671663n;
34
+ declare const SECP256K1_N = 115792089237316195423570985008687907852837564279074904382605163141518161494337n;
35
+ declare const SECP256K1_HALF_N = 57896044618658097711785492504343953926418782139537452191302581570759080747168n;
36
+ declare const PEDERSEN_H_MESSAGE: "ARC-MPC-SECP256K1-PEDERSEN-H-V1";
37
+ declare const PEDERSEN_H_DST: "ARC-MPC-H2C-SECP256K1-XMD:SHA-256_SSWU_RO_-V1";
38
+ declare const PEDERSEN_H_COMPRESSED_HEX: "03b7e44a654b748045cabc6886533d219403b0666f20cec024e4988e3896598eb4";
39
+ declare const DST_RULE_TWEAK_V1: "ARC-MPC-RULE-TWEAK-V1";
40
+ declare const DST_CHILD_TWEAK_V1: "ARC-MPC-CHILD-TWEAK-V1";
41
+ declare const DST_DKG_CTX_V2: "ARC-MPC-DKG-CTX-V2";
42
+ declare const DST_DKG_STEP1_AUTH_V1: "ARC-MPC-DKG-STEP1-AUTH-V1";
43
+ declare const DST_DKG_COM_V2: "ARC-MPC-DKG-COM-V2";
44
+ declare const DST_DKG_POK_V2: "ARC-MPC-DKG-POK-V2";
45
+ declare const DST_DKG_SHARE_AAD_V2: "ARC-MPC-DKG-SHARE-V2";
46
+ declare const DST_DKG_X25519_HKDF_V2: "ARC-MPC-DKG-X25519-HKDF-V2";
47
+ declare const DST_DKG_TRANSCRIPT_V2: "ARC-MPC-DKG-TRANSCRIPT-V2";
48
+ declare const DST_DKG_ECHO_V2: "ARC-MPC-DKG-ECHO-V2";
49
+ declare const DST_DKG_SELFTEST_V2: "ARC-MPC-DKG-SELFTEST-V2";
50
+ declare const DST_BASEOT_S_POK_V1: "ARC-MPC-BASEOT-S-POK-V1";
51
+ declare const DST_BASEOT_KEY_V1: "ARC-MPC-BASEOT-KEY-V1";
52
+ declare const DST_OT_CTR_IV_V1: "ARC-MPC-OT-CTR-IV-V1";
53
+ declare const DST_KOS15_CHI_V1: "ARC-MPC-KOS15-CHI-V1";
54
+ declare const DST_LHL_GADGET_V1: "ARC-MPC-LHL-GADGET-V1";
55
+ declare const DST_COT_ROW_V1: "ARC-MPC-COT-ROW-V1";
56
+ declare const DST_MTA_ETA_V1: "ARC-MPC-MTA-ETA-V1";
57
+ declare const DST_PRESIG_COM_V1: "ARC-MPC-PRESIG-COM-V1";
58
+ declare const DST_PRESIG_ID_V1: "ARC-MPC-PRESIG-ID-V1";
59
+ declare const DST_PRESIG_POK_GAMMA_V1: "ARC-MPC-PRESIG-POK-GAMMA-V1";
60
+ declare const DST_PRESIG_POK_B_V1: "ARC-MPC-PRESIG-POK-B-V1";
61
+ declare const DST_PRESIG_POK_CK_V1: "ARC-MPC-PRESIG-POK-CK-V1";
62
+ declare const DST_PRESIG_ZETA_HKDF_V1: "ARC-MPC-PRESIG-ZETA-HKDF-V1";
63
+ declare const DST_PRESIG_ZETA_V1: "ARC-MPC-PRESIG-ZETA-V1";
64
+ declare const DST_PRESIG_PI_LIN_K_V1: "ARC-MPC-PRESIG-PI-LIN-K-V1";
65
+ declare const DST_PRESIG_PI_POK_Z_V1: "ARC-MPC-PRESIG-PI-POK-Z-V1";
66
+ declare const DST_PRESIG_RERAND_V1: "ARC-MPC-PRESIG-RERAND-V1";
67
+ declare const FORBIDDEN_ONLINE_ROLE_ESCAPE_CANARY: "escape-canary";
68
+ type MpcRootLifecycleState = 'INITIALIZING' | 'PROVISIONED_UNDRILLED' | 'ACTIVE' | 'FROZEN_PANIC';
69
+ type MpcErrorCode = 'INVALID_SCALAR' | 'INVALID_POINT' | 'INVALID_PARAMETER' | 'INVALID_ETH_ADDRESS' | 'FORBIDDEN_ONLINE_ROLE' | 'DEGENERATE_TWEAK' | 'DKG_INVALID_CONFIG' | 'DKG_COMMITMENT_MISMATCH' | 'DKG_POK_INVALID' | 'DKG_SHARE_DECRYPT_FAILED' | 'DKG_FELDMAN_VERIFY_FAILED' | 'DKG_DEGENERATE_KEY' | 'DKG_COLD_PLUGIN_FAILED' | 'DKG_ECHO_LOCK_CONFLICT' | 'DKG_ECHO_INVALID' | 'DKG_SELFTEST_FAILED' | 'BASE_OT_INVALID_PROOF' | 'BASE_OT_INVALID_POINT' | 'OT_STATE_INVALIDATED' | 'OT_NONCE_REUSE' | 'KOS15_CORRELATION_CHECK_FAILED' | 'MTA_COMMITMENT_MISMATCH' | 'MTA_CONSISTENCY_CHECK_FAILED' | 'PRESIG_INVALID_SUBSET' | 'PRESIG_COMMITMENT_MISMATCH' | 'PRESIG_POK_INVALID' | 'PRESIG_ROUND3_E_MISMATCH' | 'PRESIG_DEGENERATE_NONCE' | 'PRESIG_PI_LIN_K_INVALID' | 'PRESIG_PI_POK_Z_INVALID' | 'PRESIG_GLOBAL_SUM_MISMATCH' | 'PRESIG_STATE_VIOLATION' | 'PRESIG_ALREADY_CONSUMED' | 'PRESIG_SUBSET_MISMATCH' | 'PRESIG_RERAND_BURN_RETRY' | 'SIGN_SHARE_VERIFICATION_FAILED' | 'SIGN_AGGREGATION_FAILED';
70
+ declare class MpcProtocolError extends Error {
71
+ readonly code: MpcErrorCode;
72
+ readonly culpritSlot?: number;
73
+ constructor(code: MpcErrorCode, message: string, culpritSlot?: number);
74
+ }
75
+ //#endregion
76
+ export { BSGS_M, DEFAULT_COLD_GUARDIANS, DEFAULT_COLD_THRESHOLD, DEFAULT_ONLINE_PARTIES, DEFAULT_ONLINE_THRESHOLD, DST_BASEOT_KEY_V1, DST_BASEOT_S_POK_V1, DST_CHILD_TWEAK_V1, DST_COT_ROW_V1, DST_DKG_COM_V2, DST_DKG_CTX_V2, DST_DKG_ECHO_V2, DST_DKG_POK_V2, DST_DKG_SELFTEST_V2, DST_DKG_SHARE_AAD_V2, DST_DKG_STEP1_AUTH_V1, DST_DKG_TRANSCRIPT_V2, DST_DKG_X25519_HKDF_V2, DST_KOS15_CHI_V1, DST_LHL_GADGET_V1, DST_MTA_ETA_V1, DST_OT_CTR_IV_V1, DST_PRESIG_COM_V1, DST_PRESIG_ID_V1, DST_PRESIG_PI_LIN_K_V1, DST_PRESIG_PI_POK_Z_V1, DST_PRESIG_POK_B_V1, DST_PRESIG_POK_CK_V1, DST_PRESIG_POK_GAMMA_V1, DST_PRESIG_RERAND_V1, DST_PRESIG_ZETA_HKDF_V1, DST_PRESIG_ZETA_V1, DST_RULE_TWEAK_V1, ESCAPE_DRILL_MAX_AGE_SECONDS, FORBIDDEN_ONLINE_ROLE_ESCAPE_CANARY, MAX_MPC_CLUSTER_NODES, MAX_MPC_PEER_MESSAGE_BYTES, MAX_MPC_SIGN_REQUEST_BYTES, MAX_ON_DEMAND_SILENCE_SECONDS, MAX_RECOVERY_PACKAGE_BYTES, MAX_RULE_DAG_NODES, MAX_RULE_YAML_BYTES, MPC_PROTOCOL_VERSION, MpcErrorCode, MpcProtocolError, MpcRootLifecycleState, OT_BASE_PARTIAL_BITS, OT_COLUMN_BYTES, OT_EXTENSION_ROWS, OT_GADGET_BITS, OT_KAPPA_BITS, OT_KAPPA_BYTES, OT_LHL_EXTRA_BITS, OT_SACRIFICE_BITS, PEDERSEN_H_COMPRESSED_HEX, PEDERSEN_H_DST, PEDERSEN_H_MESSAGE, SECP256K1_HALF_N, SECP256K1_N, SECP256K1_P };
@@ -0,0 +1,78 @@
1
+ //#region src/constants.ts
2
+ /**
3
+ * Protocol, curve, domain-separation, and 3D envelope constants for `@ocap/mpc-hsm`.
4
+ *
5
+ * Security invariants:
6
+ * - Virtual root secret `x_root` and child secret `x_child = (x_root + t_tweak) mod n` are NEVER
7
+ * materialized on any online machine, and zero secret-key export methods exist in this package.
8
+ * - All Fiat-Shamir challenges, NUMS generators, tweaks, OT row pads, presignature IDs, and
9
+ * Groth-Shoup re-randomization scalars use explicit versioned domain-separation tags.
10
+ */
11
+ const MPC_PROTOCOL_VERSION = 2;
12
+ const DEFAULT_ONLINE_THRESHOLD = 3;
13
+ const DEFAULT_ONLINE_PARTIES = 5;
14
+ const DEFAULT_COLD_THRESHOLD = 2;
15
+ const DEFAULT_COLD_GUARDIANS = 3;
16
+ const MAX_MPC_CLUSTER_NODES = 7;
17
+ const BSGS_M = 680;
18
+ const OT_KAPPA_BITS = 128;
19
+ const OT_KAPPA_BYTES = 16;
20
+ const OT_BASE_PARTIAL_BITS = 256;
21
+ const OT_LHL_EXTRA_BITS = 512;
22
+ const OT_GADGET_BITS = 768;
23
+ const OT_SACRIFICE_BITS = 256;
24
+ const OT_EXTENSION_ROWS = 1024;
25
+ const OT_COLUMN_BYTES = 128;
26
+ const MAX_MPC_SIGN_REQUEST_BYTES = 262144;
27
+ const MAX_MPC_PEER_MESSAGE_BYTES = 524288;
28
+ const MAX_RECOVERY_PACKAGE_BYTES = 2097152;
29
+ const MAX_RULE_YAML_BYTES = 16384;
30
+ const MAX_RULE_DAG_NODES = 128;
31
+ const MAX_ON_DEMAND_SILENCE_SECONDS = 604800;
32
+ const ESCAPE_DRILL_MAX_AGE_SECONDS = 2592e3;
33
+ const SECP256K1_P = 115792089237316195423570985008687907853269984665640564039457584007908834671663n;
34
+ const SECP256K1_N = 115792089237316195423570985008687907852837564279074904382605163141518161494337n;
35
+ const SECP256K1_HALF_N = 57896044618658097711785492504343953926418782139537452191302581570759080747168n;
36
+ const PEDERSEN_H_MESSAGE = "ARC-MPC-SECP256K1-PEDERSEN-H-V1";
37
+ const PEDERSEN_H_DST = "ARC-MPC-H2C-SECP256K1-XMD:SHA-256_SSWU_RO_-V1";
38
+ const PEDERSEN_H_COMPRESSED_HEX = "03b7e44a654b748045cabc6886533d219403b0666f20cec024e4988e3896598eb4";
39
+ const DST_RULE_TWEAK_V1 = "ARC-MPC-RULE-TWEAK-V1";
40
+ const DST_CHILD_TWEAK_V1 = "ARC-MPC-CHILD-TWEAK-V1";
41
+ const DST_DKG_CTX_V2 = "ARC-MPC-DKG-CTX-V2";
42
+ const DST_DKG_STEP1_AUTH_V1 = "ARC-MPC-DKG-STEP1-AUTH-V1";
43
+ const DST_DKG_COM_V2 = "ARC-MPC-DKG-COM-V2";
44
+ const DST_DKG_POK_V2 = "ARC-MPC-DKG-POK-V2";
45
+ const DST_DKG_SHARE_AAD_V2 = "ARC-MPC-DKG-SHARE-V2";
46
+ const DST_DKG_X25519_HKDF_V2 = "ARC-MPC-DKG-X25519-HKDF-V2";
47
+ const DST_DKG_TRANSCRIPT_V2 = "ARC-MPC-DKG-TRANSCRIPT-V2";
48
+ const DST_DKG_ECHO_V2 = "ARC-MPC-DKG-ECHO-V2";
49
+ const DST_DKG_SELFTEST_V2 = "ARC-MPC-DKG-SELFTEST-V2";
50
+ const DST_BASEOT_S_POK_V1 = "ARC-MPC-BASEOT-S-POK-V1";
51
+ const DST_BASEOT_KEY_V1 = "ARC-MPC-BASEOT-KEY-V1";
52
+ const DST_OT_CTR_IV_V1 = "ARC-MPC-OT-CTR-IV-V1";
53
+ const DST_KOS15_CHI_V1 = "ARC-MPC-KOS15-CHI-V1";
54
+ const DST_LHL_GADGET_V1 = "ARC-MPC-LHL-GADGET-V1";
55
+ const DST_COT_ROW_V1 = "ARC-MPC-COT-ROW-V1";
56
+ const DST_MTA_ETA_V1 = "ARC-MPC-MTA-ETA-V1";
57
+ const DST_PRESIG_COM_V1 = "ARC-MPC-PRESIG-COM-V1";
58
+ const DST_PRESIG_ID_V1 = "ARC-MPC-PRESIG-ID-V1";
59
+ const DST_PRESIG_POK_GAMMA_V1 = "ARC-MPC-PRESIG-POK-GAMMA-V1";
60
+ const DST_PRESIG_POK_B_V1 = "ARC-MPC-PRESIG-POK-B-V1";
61
+ const DST_PRESIG_POK_CK_V1 = "ARC-MPC-PRESIG-POK-CK-V1";
62
+ const DST_PRESIG_ZETA_HKDF_V1 = "ARC-MPC-PRESIG-ZETA-HKDF-V1";
63
+ const DST_PRESIG_ZETA_V1 = "ARC-MPC-PRESIG-ZETA-V1";
64
+ const DST_PRESIG_PI_LIN_K_V1 = "ARC-MPC-PRESIG-PI-LIN-K-V1";
65
+ const DST_PRESIG_PI_POK_Z_V1 = "ARC-MPC-PRESIG-PI-POK-Z-V1";
66
+ const DST_PRESIG_RERAND_V1 = "ARC-MPC-PRESIG-RERAND-V1";
67
+ const FORBIDDEN_ONLINE_ROLE_ESCAPE_CANARY = "escape-canary";
68
+ var MpcProtocolError = class extends Error {
69
+ constructor(code, message, culpritSlot) {
70
+ super(message);
71
+ this.name = "MpcProtocolError";
72
+ this.code = code;
73
+ if (culpritSlot !== void 0) this.culpritSlot = culpritSlot;
74
+ }
75
+ };
76
+
77
+ //#endregion
78
+ export { BSGS_M, DEFAULT_COLD_GUARDIANS, DEFAULT_COLD_THRESHOLD, DEFAULT_ONLINE_PARTIES, DEFAULT_ONLINE_THRESHOLD, DST_BASEOT_KEY_V1, DST_BASEOT_S_POK_V1, DST_CHILD_TWEAK_V1, DST_COT_ROW_V1, DST_DKG_COM_V2, DST_DKG_CTX_V2, DST_DKG_ECHO_V2, DST_DKG_POK_V2, DST_DKG_SELFTEST_V2, DST_DKG_SHARE_AAD_V2, DST_DKG_STEP1_AUTH_V1, DST_DKG_TRANSCRIPT_V2, DST_DKG_X25519_HKDF_V2, DST_KOS15_CHI_V1, DST_LHL_GADGET_V1, DST_MTA_ETA_V1, DST_OT_CTR_IV_V1, DST_PRESIG_COM_V1, DST_PRESIG_ID_V1, DST_PRESIG_PI_LIN_K_V1, DST_PRESIG_PI_POK_Z_V1, DST_PRESIG_POK_B_V1, DST_PRESIG_POK_CK_V1, DST_PRESIG_POK_GAMMA_V1, DST_PRESIG_RERAND_V1, DST_PRESIG_ZETA_HKDF_V1, DST_PRESIG_ZETA_V1, DST_RULE_TWEAK_V1, ESCAPE_DRILL_MAX_AGE_SECONDS, FORBIDDEN_ONLINE_ROLE_ESCAPE_CANARY, MAX_MPC_CLUSTER_NODES, MAX_MPC_PEER_MESSAGE_BYTES, MAX_MPC_SIGN_REQUEST_BYTES, MAX_ON_DEMAND_SILENCE_SECONDS, MAX_RECOVERY_PACKAGE_BYTES, MAX_RULE_DAG_NODES, MAX_RULE_YAML_BYTES, MPC_PROTOCOL_VERSION, MpcProtocolError, OT_BASE_PARTIAL_BITS, OT_COLUMN_BYTES, OT_EXTENSION_ROWS, OT_GADGET_BITS, OT_KAPPA_BITS, OT_KAPPA_BYTES, OT_LHL_EXTRA_BITS, OT_SACRIFICE_BITS, PEDERSEN_H_COMPRESSED_HEX, PEDERSEN_H_DST, PEDERSEN_H_MESSAGE, SECP256K1_HALF_N, SECP256K1_N, SECP256K1_P };
package/esm/dkg.d.mts ADDED
@@ -0,0 +1,279 @@
1
+ import { MPC_PROTOCOL_VERSION, MpcRootLifecycleState } from "./constants.mjs";
2
+ import { RandomBytesFn, SchnorrPokProof } from "./secp256k1-scalar.mjs";
3
+
4
+ //#region src/dkg.d.ts
5
+
6
+ /**
7
+ * 4-Step Commit-Reveal Joint-Feldman DKG Core (`design.md` §4.3):
8
+ * - Commits OCAP consensus anchor + `escapeColdWallet` immutably into `ctx_dkg` & `H_dkg`.
9
+ * - Authenticates Step-1 `(commitment32, ephemeralX25519Pub32)` under roster identity keys BEFORE
10
+ * Step-2 Shamir share encryption.
11
+ * - Persistent, fail-closed, exclusive-file-locked `AppendOnlyDkgEchoLock` (`dkg-echo-lock.json`)
12
+ * written BEFORE emitting `\sigma^{echo}_j` and **NEVER cleared on ceremony abort**.
13
+ * - Enforces non-zero polynomial degree & non-identity points (`P_root != O`, `F_{t-1} != O`,
14
+ * `C^{cold}_{t_c-1} != O`, `X_m != O`, `Y_k != O`).
15
+ * - Pluggable `ColdBackupPlugin` hook for PR 2 Direct Bit-ElGamal VES (`verifyRecoveryPackage`).
16
+ * - Strictly single-node Step-4 promotion (`promoteNodeRecordAfterSelfTests`) verifying all
17
+ * `C(n_parties, t)` subset signatures and `ColdBackupPlugin` without ever concentrating multiple
18
+ * party shares in one process.
19
+ */
20
+ interface OcapConsensusAnchor {
21
+ readonly ocapChainId: string;
22
+ readonly genesisHash: Uint8Array | string;
23
+ readonly initialValidatorEpoch: bigint;
24
+ readonly initialClusterConfigHash: Uint8Array | string;
25
+ readonly quorumRule: string;
26
+ }
27
+ interface DkgRosterEntry {
28
+ readonly slot: number;
29
+ readonly nodeDid: string;
30
+ /** Compressed 33-byte secp256k1 identity key authenticating Step-1 ephemeral keys and Step-3 echoes. */
31
+ readonly echoVerifyPublicKeyComp33: Uint8Array;
32
+ }
33
+ interface DkgCeremonyConfig {
34
+ readonly protocolVersion: typeof MPC_PROTOCOL_VERSION;
35
+ readonly t: number;
36
+ readonly nParties: number;
37
+ readonly tCold: number;
38
+ readonly nCold: number;
39
+ readonly clusterId: string;
40
+ readonly rootId: string;
41
+ readonly keyEpoch: bigint;
42
+ readonly ceremonyId: string;
43
+ readonly escapeColdWallet: string;
44
+ readonly ocapAnchor: OcapConsensusAnchor;
45
+ readonly roster: ReadonlyArray<DkgRosterEntry>;
46
+ readonly guardianPublicKeysComp33: ReadonlyArray<Uint8Array>;
47
+ readonly requireColdBackupPlugin?: boolean;
48
+ }
49
+ interface ColdBackupDealerInput {
50
+ readonly ctxDkg32: Uint8Array;
51
+ readonly dealerSlot: number;
52
+ readonly coldCommitmentsComp33: ReadonlyArray<Uint8Array>;
53
+ readonly guardianPublicKeysComp33: ReadonlyArray<Uint8Array>;
54
+ /** Dealer `i`'s cold evaluations `y_{i,k} = g_i(k) mod n` (`k = 1..nCold`). */
55
+ readonly coldEvaluationsByGuardian: ReadonlyArray<{
56
+ readonly guardianIndex: number;
57
+ readonly evaluationScalar: bigint;
58
+ readonly guardianPublicKeyComp33: Uint8Array;
59
+ }>;
60
+ }
61
+ interface ColdBackupPlugin {
62
+ createDealerContribution(input: ColdBackupDealerInput): Uint8Array;
63
+ verifyDealerContribution(input: {
64
+ readonly ctxDkg32: Uint8Array;
65
+ readonly dealerSlot: number;
66
+ readonly coldCommitmentsComp33: ReadonlyArray<Uint8Array>;
67
+ readonly guardianPublicKeysComp33: ReadonlyArray<Uint8Array>;
68
+ readonly payload: Uint8Array;
69
+ }): boolean;
70
+ aggregateRecoveryPackage(input: {
71
+ readonly ctxDkg32: Uint8Array;
72
+ readonly hDkg32: Uint8Array;
73
+ readonly rootPublicKeyComp33: Uint8Array;
74
+ readonly aggColdCommitmentsComp33: ReadonlyArray<Uint8Array>;
75
+ readonly guardianColdPublicSharesComp33: ReadonlyArray<Uint8Array>;
76
+ readonly guardianPublicKeysComp33: ReadonlyArray<Uint8Array>;
77
+ readonly dealerPayloads: ReadonlyArray<{
78
+ readonly dealerSlot: number;
79
+ readonly payload: Uint8Array;
80
+ }>;
81
+ }): {
82
+ readonly recoveryPackageBytes: Uint8Array;
83
+ readonly recoveryPackageHash32: Uint8Array;
84
+ };
85
+ verifyRecoveryPackage(recoveryPackageBytes: Uint8Array, expected?: {
86
+ readonly ctxDkg32: Uint8Array;
87
+ readonly rootPublicKeyComp33: Uint8Array;
88
+ readonly aggColdCommitmentsComp33: ReadonlyArray<Uint8Array>;
89
+ readonly guardianPublicKeysComp33: ReadonlyArray<Uint8Array>;
90
+ }): boolean;
91
+ }
92
+ interface DkgEchoLock {
93
+ /**
94
+ * Atomically binds `ceremonyId -> hDkg32` (and optionally `epochScopeKey -> ceremonyId`).
95
+ * - Idempotent if `ceremonyId` is already bound to the exact same `hDkg32`.
96
+ * - Throws `DKG_ECHO_LOCK_CONFLICT` if `ceremonyId` is bound to a different `hDkg32` or if
97
+ * `epochScopeKey` (`clusterId|rootId|keyEpoch`) was already locked to another `ceremonyId`.
98
+ * - NEVER deletes or clears bindings on ceremony abort!
99
+ */
100
+ recordAndVerify(ceremonyId: string, hDkg32: Uint8Array, epochScopeKey?: string): void;
101
+ getLockedTranscriptHex(ceremonyId: string): string | undefined;
102
+ }
103
+ declare function assertSafeCeremonyId(ceremonyId: string): void;
104
+ /**
105
+ * Append-only, fail-closed `DkgEchoLock` supporting in-memory and `0600` exclusive-file-locked
106
+ * atomic `temp+fsync+rename` persisted JSON (`dkg-echo-lock.json`, `design.md` §3.2(3)).
107
+ * Serializes `[ceremonyId, hDkgHex]` tuples (immune to prototype-key collisions) and exposes
108
+ * ZERO delete/clear methods.
109
+ */
110
+ declare class AppendOnlyDkgEchoLock implements DkgEchoLock {
111
+ private readonly entries;
112
+ private readonly epochScopes;
113
+ private readonly filePath?;
114
+ constructor(options?: {
115
+ filePath?: string;
116
+ });
117
+ get size(): number;
118
+ getLockedTranscriptHex(ceremonyId: string): string | undefined;
119
+ private loadAndValidateFromDisk;
120
+ private withExclusiveFileLock;
121
+ recordAndVerify(ceremonyId: string, hDkg32: Uint8Array, epochScopeKey?: string): void;
122
+ private verifyAndCommitInMemory;
123
+ private persistAtomicFsync;
124
+ }
125
+ declare function validateAndComputeDkgContext(config: DkgCeremonyConfig): {
126
+ ctxDkg32: Uint8Array;
127
+ normalizedEscapeColdWallet: string;
128
+ sortedRoster: ReadonlyArray<DkgRosterEntry>;
129
+ };
130
+ declare function computeDkgContextHash32(config: DkgCeremonyConfig): Uint8Array;
131
+ /**
132
+ * Deterministic 32-byte message digest signed by subset `S` during DKG Step-4 self-testing,
133
+ * bound to `(DST_DKG_SELFTEST_V2, ctxDkg32, sortedSubsetBytes(S))`.
134
+ */
135
+ declare function computeDkgSubsetSelfTestDigest32(ctxDkg32: Uint8Array, subset: ReadonlyArray<number>): Uint8Array;
136
+ interface DkgRound1CommitMessage {
137
+ readonly dealerSlot: number;
138
+ readonly commitment32: Uint8Array;
139
+ readonly ephemeralX25519Pub32: Uint8Array;
140
+ /** Authenticates `(ctxDkg32, u32be(dealerSlot), commitment32, ephemeralX25519Pub32)` under roster identity key. */
141
+ readonly step1AuthPok: SchnorrPokProof;
142
+ }
143
+ interface DkgRound2RevealPayload {
144
+ readonly dealerSlot: number;
145
+ readonly comSalt32: Uint8Array;
146
+ readonly ephemeralX25519Pub32: Uint8Array;
147
+ readonly onlineCommitmentsComp33: ReadonlyArray<Uint8Array>;
148
+ readonly coldCommitmentsComp33: ReadonlyArray<Uint8Array>;
149
+ readonly onlineCoeffPoks: ReadonlyArray<SchnorrPokProof>;
150
+ readonly coldExtraCoeffPoks: ReadonlyArray<SchnorrPokProof>;
151
+ readonly coldVesPayload: Uint8Array;
152
+ }
153
+ interface DkgEncryptedShareEnvelope {
154
+ readonly dealerSlot: number;
155
+ readonly recipientSlot: number;
156
+ readonly iv12: Uint8Array;
157
+ readonly ciphertext32: Uint8Array;
158
+ readonly authTag16: Uint8Array;
159
+ }
160
+ interface DkgRound3EchoMessage {
161
+ readonly slot: number;
162
+ readonly hDkg32: Uint8Array;
163
+ readonly echoSignaturePok: SchnorrPokProof;
164
+ }
165
+ interface DkgSubsetSelfTestSignature {
166
+ readonly subset: ReadonlyArray<number>;
167
+ readonly rHex: string;
168
+ readonly sHex: string;
169
+ readonly yParity: 0 | 1;
170
+ }
171
+ interface MpcNodeProvisionedKeyRecord {
172
+ readonly slot: number;
173
+ readonly rootId: string;
174
+ readonly keyEpoch: bigint;
175
+ readonly t: number;
176
+ readonly nParties: number;
177
+ readonly tCold: number;
178
+ readonly nCold: number;
179
+ readonly lifecycleState: MpcRootLifecycleState;
180
+ readonly ctxDkg32: Uint8Array;
181
+ readonly hDkg32: Uint8Array;
182
+ readonly escapeColdWallet: string;
183
+ readonly ocapAnchor: OcapConsensusAnchor;
184
+ readonly rootPublicKeyComp33: Uint8Array;
185
+ readonly rootEthAddress: string;
186
+ readonly onlineFeldmanCommitmentsComp33: ReadonlyArray<Uint8Array>;
187
+ readonly coldFeldmanCommitmentsComp33: ReadonlyArray<Uint8Array>;
188
+ readonly onlinePublicSharesComp33BySlot: ReadonlyMap<number, Uint8Array>;
189
+ readonly guardianColdPublicSharesComp33: ReadonlyArray<Uint8Array>;
190
+ readonly recoveryPackageBytes?: Uint8Array;
191
+ readonly recoveryPackageHash32?: Uint8Array;
192
+ /** Node's own Shamir secret share `x_slot` (`x_root` is NEVER materialized!). */
193
+ readonly secretShareBytes32: Uint8Array;
194
+ }
195
+ declare class DkgParticipantSession {
196
+ readonly slot: number;
197
+ readonly config: DkgCeremonyConfig;
198
+ readonly ctxDkg32: Uint8Array;
199
+ readonly normalizedEscapeColdWallet: string;
200
+ private readonly sortedRoster;
201
+ private readonly echoSigningKeyBytes32;
202
+ private readonly echoLock;
203
+ private readonly coldBackupPlugin?;
204
+ private readonly requireColdBackupPlugin;
205
+ private readonly rng;
206
+ private phase;
207
+ private readonly onlinePolyBytes32;
208
+ private readonly coldPolyBytes32;
209
+ private readonly x25519Secret32;
210
+ private readonly x25519Pub32;
211
+ private ownReveal;
212
+ private step1CommitsBySlot;
213
+ private verifiedRevealsBySlot;
214
+ private hDkg32;
215
+ private accumulatedOwnShareBytes32;
216
+ constructor(params: {
217
+ slot: number;
218
+ config: DkgCeremonyConfig;
219
+ echoSigningSecretBytes32: Uint8Array;
220
+ echoLock: DkgEchoLock;
221
+ coldBackupPlugin?: ColdBackupPlugin;
222
+ requireColdBackupPlugin?: boolean;
223
+ rng?: RandomBytesFn;
224
+ });
225
+ abort(): void;
226
+ private wipeDealerSecrets;
227
+ /**
228
+ * Step 1: Computes Feldman commitments `{A_{i,l}}`, `{C_{i,l}}`, Schnorr PoK `\pi^{pok}_i`,
229
+ * optional `VES_i`, and broadcasts `Com_i` + `epk^{x25519}_i` authenticated under the node's
230
+ * roster identity key (`ARC-MPC-DKG-STEP1-AUTH-V1`).
231
+ */
232
+ step1CreateCommitment(): DkgRound1CommitMessage;
233
+ /**
234
+ * Step 2: Verifies every peer's Step-1 roster authentication signature over
235
+ * `(ctxDkg32, u32be(j), commitment32, ephemeralX25519Pub32)` BEFORE encrypting any Shamir share,
236
+ * then reveals `Reveal_i` and seals `f_i(j) mod n` via `X25519 + HKDF-SHA256 + AES-256-GCM`.
237
+ */
238
+ step2CreateRevealAndShares(allCommitments: ReadonlyArray<DkgRound1CommitMessage>): {
239
+ reveal: DkgRound2RevealPayload;
240
+ encryptedShares: ReadonlyArray<DkgEncryptedShareEnvelope>;
241
+ };
242
+ /**
243
+ * Step 3a: Verifies all `Com_m`, `\pi^{pok}_m`, `A_{m,0} == C_{m,0} != O`, non-zero degree
244
+ * commitments, `VES_m`, and Feldman share equations; appends `ceremonyId -> H_dkg` to the
245
+ * append-only `DkgEchoLock` **before** signing `\sigma^{echo}_j`!
246
+ */
247
+ step3VerifyAndCreateLockedEcho(params: {
248
+ allReveals: ReadonlyArray<DkgRound2RevealPayload>;
249
+ encryptedSharesForMe: ReadonlyArray<DkgEncryptedShareEnvelope>;
250
+ }): DkgRound3EchoMessage;
251
+ /**
252
+ * Step 3b: Requires unanimous authenticated echoes over `H_dkg`, checks non-zero degree and
253
+ * non-identity invariants (`P_root != O`, `F_{t-1} != O`, `C^{cold}_{t_c-1} != O`, `X_m != O`,
254
+ * `Y_k != O`), validates aggregated `recoveryPackageBytes` (`<= MAX_RECOVERY_PACKAGE_BYTES`,
255
+ * `sha256` match, `verifyRecoveryPackage === true`) BEFORE releasing `shareCopy`, and outputs
256
+ * the node's key record in `INITIALIZING` state ready for Step-4 subset self-tests.
257
+ */
258
+ step3FinalizeFromEchoes(allEchoes: ReadonlyArray<DkgRound3EchoMessage>): MpcNodeProvisionedKeyRecord;
259
+ }
260
+ /**
261
+ * Strictly single-node Step-4 promotion (`design.md` §4.3):
262
+ * - Takes ONLY this node's own `INITIALIZING` record (`ownRecord`) — ZERO peer secret shares ever
263
+ * enter this function!
264
+ * - Validates `ownRecord` invariants (`ctxDkg32`, `rootPublicKeyComp33`, `x_slot * G == X_slot`,
265
+ * and fail-closed `ColdBackupPlugin` / `sha256(recoveryPackageBytes)` verification).
266
+ * - Verifies that `subsetSignatures` covers EVERY `C(nParties, t)` canonical subset `S` and
267
+ * cryptographically `ecrecover`s each signature against `ownRecord.rootPublicKeyComp33` over
268
+ * `computeDkgSubsetSelfTestDigest32(ownRecord.ctxDkg32, S)`.
269
+ * - Zeroizes `ownRecord.secretShareBytes32` before rethrowing on ANY failure!
270
+ */
271
+ declare function promoteNodeRecordAfterSelfTests(params: {
272
+ ownRecord: MpcNodeProvisionedKeyRecord;
273
+ config: DkgCeremonyConfig;
274
+ subsetSignatures: ReadonlyArray<DkgSubsetSelfTestSignature>;
275
+ coldBackupPlugin?: ColdBackupPlugin;
276
+ requireColdBackupPlugin?: boolean;
277
+ }): MpcNodeProvisionedKeyRecord;
278
+ //#endregion
279
+ export { AppendOnlyDkgEchoLock, ColdBackupDealerInput, ColdBackupPlugin, DkgCeremonyConfig, DkgEchoLock, DkgEncryptedShareEnvelope, DkgParticipantSession, DkgRosterEntry, DkgRound1CommitMessage, DkgRound2RevealPayload, DkgRound3EchoMessage, DkgSubsetSelfTestSignature, MpcNodeProvisionedKeyRecord, OcapConsensusAnchor, assertSafeCeremonyId, computeDkgContextHash32, computeDkgSubsetSelfTestDigest32, promoteNodeRecordAfterSelfTests, validateAndComputeDkgContext };