@bitgo/public-types 2.32.2 → 2.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/schema/mpcv2/index.d.ts +1 -0
- package/dist/src/schema/mpcv2/index.js +1 -0
- package/dist/src/schema/mpcv2/index.js.map +1 -1
- package/dist/src/schema/mpcv2/smc/index.d.ts +3 -0
- package/dist/src/schema/mpcv2/smc/index.js +20 -0
- package/dist/src/schema/mpcv2/smc/index.js.map +1 -0
- package/dist/src/schema/mpcv2/smc/keygenRound.d.ts +1440 -0
- package/dist/src/schema/mpcv2/smc/keygenRound.js +234 -0
- package/dist/src/schema/mpcv2/smc/keygenRound.js.map +1 -0
- package/dist/src/schema/mpcv2/smc/keygenState.d.ts +18 -0
- package/dist/src/schema/mpcv2/smc/keygenState.js +59 -0
- package/dist/src/schema/mpcv2/smc/keygenState.js.map +1 -0
- package/dist/src/schema/mpcv2/smc/messages/broadcast.d.ts +11 -0
- package/dist/src/schema/mpcv2/smc/messages/broadcast.js +42 -0
- package/dist/src/schema/mpcv2/smc/messages/broadcast.js.map +1 -0
- package/dist/src/schema/mpcv2/smc/messages/p2p.d.ts +12 -0
- package/dist/src/schema/mpcv2/smc/messages/p2p.js +44 -0
- package/dist/src/schema/mpcv2/smc/messages/p2p.js.map +1 -0
- package/dist/src/schema/mpcv2/smc/walletType.d.ts +8 -0
- package/dist/src/schema/mpcv2/smc/walletType.js +35 -0
- package/dist/src/schema/mpcv2/smc/walletType.js.map +1 -0
- package/package.json +1 -1
- package/src/schema/mpcv2/index.ts +1 -0
- package/src/schema/mpcv2/smc/index.ts +3 -0
- package/src/schema/mpcv2/smc/keygenRound.ts +260 -0
- package/src/schema/mpcv2/smc/keygenState.ts +35 -0
- package/src/schema/mpcv2/smc/messages/broadcast.ts +22 -0
- package/src/schema/mpcv2/smc/messages/p2p.ts +24 -0
- package/src/schema/mpcv2/smc/walletType.ts +11 -0
@@ -0,0 +1,260 @@
|
|
1
|
+
import * as t from "io-ts";
|
2
|
+
import { NonEmptyString } from "io-ts-types";
|
3
|
+
|
4
|
+
import { KeyCreationMPCv2State } from "./keygenState";
|
5
|
+
import { WalletType } from "./walletType";
|
6
|
+
import { AuthBroadcastMessage } from "./messages/broadcast";
|
7
|
+
import { AuthEncP2PMessage } from "./messages/p2p";
|
8
|
+
|
9
|
+
export enum OVCIndexEnum {
|
10
|
+
ONE = 1,
|
11
|
+
TWO = 2,
|
12
|
+
}
|
13
|
+
|
14
|
+
const BaseRoundPayload = t.type({
|
15
|
+
tssVersion: NonEmptyString,
|
16
|
+
walletType: WalletType,
|
17
|
+
coin: NonEmptyString,
|
18
|
+
state: KeyCreationMPCv2State,
|
19
|
+
});
|
20
|
+
|
21
|
+
type BaseRoundPayload = t.TypeOf<typeof BaseRoundPayload>;
|
22
|
+
|
23
|
+
export const OVC1ToOVC2Round1Payload = t.intersection([
|
24
|
+
BaseRoundPayload,
|
25
|
+
t.type({
|
26
|
+
ovc: t.type({
|
27
|
+
[OVCIndexEnum.ONE]: t.type({
|
28
|
+
gpgPubKey: NonEmptyString,
|
29
|
+
ovcMsg1: AuthBroadcastMessage,
|
30
|
+
}),
|
31
|
+
}),
|
32
|
+
}),
|
33
|
+
]);
|
34
|
+
|
35
|
+
export type OVC1ToOVC2Round1Payload = t.TypeOf<typeof OVC1ToOVC2Round1Payload>;
|
36
|
+
|
37
|
+
export const OVC2ToBitgoRound1Payload = t.intersection([
|
38
|
+
BaseRoundPayload,
|
39
|
+
t.type({
|
40
|
+
ovc: t.type({
|
41
|
+
[OVCIndexEnum.ONE]: t.type({
|
42
|
+
gpgPubKey: NonEmptyString,
|
43
|
+
ovcMsg1: AuthBroadcastMessage,
|
44
|
+
}),
|
45
|
+
[OVCIndexEnum.TWO]: t.type({
|
46
|
+
gpgPubKey: NonEmptyString,
|
47
|
+
ovcMsg1: AuthBroadcastMessage,
|
48
|
+
}),
|
49
|
+
}),
|
50
|
+
}),
|
51
|
+
]);
|
52
|
+
|
53
|
+
export type OVC2ToBitgoRound1Payload = t.TypeOf<
|
54
|
+
typeof OVC2ToBitgoRound1Payload
|
55
|
+
>;
|
56
|
+
|
57
|
+
export const PlatformRound1Payload = t.type({
|
58
|
+
walletGpgPubKeySigs: NonEmptyString,
|
59
|
+
sessionId: NonEmptyString,
|
60
|
+
bitgoMsg1: AuthBroadcastMessage,
|
61
|
+
ovc: t.type({
|
62
|
+
[OVCIndexEnum.ONE]: t.type({
|
63
|
+
bitgoToOvcMsg2: AuthEncP2PMessage,
|
64
|
+
}),
|
65
|
+
[OVCIndexEnum.TWO]: t.type({
|
66
|
+
bitgoToOvcMsg2: AuthEncP2PMessage,
|
67
|
+
}),
|
68
|
+
}),
|
69
|
+
});
|
70
|
+
|
71
|
+
export type PlatformRound1Payload = t.TypeOf<typeof PlatformRound1Payload>;
|
72
|
+
|
73
|
+
export const BitgoToOVC1Round1Response = t.type({
|
74
|
+
wallet: t.intersection([
|
75
|
+
OVC2ToBitgoRound1Payload,
|
76
|
+
t.type({ platform: PlatformRound1Payload }),
|
77
|
+
]),
|
78
|
+
});
|
79
|
+
|
80
|
+
export type BitgoToOVC1Round1Response = t.TypeOf<
|
81
|
+
typeof BitgoToOVC1Round1Response
|
82
|
+
>;
|
83
|
+
|
84
|
+
export const OVC1ToOVC2Round2Payload = t.intersection([
|
85
|
+
BaseRoundPayload,
|
86
|
+
t.type({
|
87
|
+
ovc: t.type({
|
88
|
+
[OVCIndexEnum.ONE]: t.type({
|
89
|
+
gpgPubKey: NonEmptyString,
|
90
|
+
ovcMsg1: AuthBroadcastMessage,
|
91
|
+
ovcToBitgoMsg2: AuthEncP2PMessage,
|
92
|
+
ovcToOvcMsg2: AuthEncP2PMessage,
|
93
|
+
}),
|
94
|
+
[OVCIndexEnum.TWO]: t.type({
|
95
|
+
gpgPubKey: NonEmptyString,
|
96
|
+
ovcMsg1: AuthBroadcastMessage,
|
97
|
+
}),
|
98
|
+
}),
|
99
|
+
}),
|
100
|
+
]);
|
101
|
+
|
102
|
+
export type OVC1ToOVC2Round2Payload = t.TypeOf<typeof OVC1ToOVC2Round2Payload>;
|
103
|
+
|
104
|
+
export const OVC2ToBitgoRound2Payload = t.intersection([
|
105
|
+
BaseRoundPayload,
|
106
|
+
t.type({
|
107
|
+
ovc: t.type({
|
108
|
+
[OVCIndexEnum.ONE]: t.type({
|
109
|
+
gpgPubKey: NonEmptyString,
|
110
|
+
ovcMsg1: AuthBroadcastMessage,
|
111
|
+
ovcToBitgoMsg2: AuthEncP2PMessage,
|
112
|
+
ovcToOvcMsg2: AuthEncP2PMessage,
|
113
|
+
}),
|
114
|
+
[OVCIndexEnum.TWO]: t.type({
|
115
|
+
gpgPubKey: NonEmptyString,
|
116
|
+
ovcMsg1: AuthBroadcastMessage,
|
117
|
+
ovcToBitgoMsg2: AuthEncP2PMessage,
|
118
|
+
ovcToOvcMsg2: AuthEncP2PMessage,
|
119
|
+
}),
|
120
|
+
}),
|
121
|
+
platform: PlatformRound1Payload,
|
122
|
+
}),
|
123
|
+
]);
|
124
|
+
|
125
|
+
export type OVC2ToBitgoRound2Payload = t.TypeOf<
|
126
|
+
typeof OVC2ToBitgoRound2Payload
|
127
|
+
>;
|
128
|
+
|
129
|
+
export const PlatformRound2Payload = t.type({
|
130
|
+
sessionId: NonEmptyString,
|
131
|
+
bitgoMsg1: AuthBroadcastMessage,
|
132
|
+
bitgoCommitment2: NonEmptyString,
|
133
|
+
ovc: t.type({
|
134
|
+
[OVCIndexEnum.ONE]: t.type({
|
135
|
+
bitgoToOvcMsg2: AuthEncP2PMessage,
|
136
|
+
bitgoToOvcMsg3: AuthEncP2PMessage,
|
137
|
+
}),
|
138
|
+
[OVCIndexEnum.TWO]: t.type({
|
139
|
+
bitgoToOvcMsg2: AuthEncP2PMessage,
|
140
|
+
bitgoToOvcMsg3: AuthEncP2PMessage,
|
141
|
+
}),
|
142
|
+
}),
|
143
|
+
});
|
144
|
+
|
145
|
+
export const BitgoToOVC1Round2Response = t.type({
|
146
|
+
wallet: t.intersection([
|
147
|
+
OVC2ToBitgoRound2Payload,
|
148
|
+
t.type({ platform: PlatformRound2Payload }),
|
149
|
+
]),
|
150
|
+
});
|
151
|
+
|
152
|
+
export type BitgoToOVC1Round2Response = t.TypeOf<
|
153
|
+
typeof BitgoToOVC1Round2Response
|
154
|
+
>;
|
155
|
+
|
156
|
+
export const OVC1ToOVC2Round3Payload = t.intersection([
|
157
|
+
BaseRoundPayload,
|
158
|
+
t.type({
|
159
|
+
ovc: t.type({
|
160
|
+
[OVCIndexEnum.ONE]: t.type({
|
161
|
+
gpgPubKey: NonEmptyString,
|
162
|
+
ovcMsg1: AuthBroadcastMessage,
|
163
|
+
ovcToBitgoMsg2: AuthEncP2PMessage,
|
164
|
+
ovcToOvcMsg2: AuthEncP2PMessage,
|
165
|
+
ovcToBitgoMsg3: AuthEncP2PMessage,
|
166
|
+
ovcToOvcMsg3: AuthEncP2PMessage,
|
167
|
+
}),
|
168
|
+
[OVCIndexEnum.TWO]: t.type({
|
169
|
+
gpgPubKey: NonEmptyString,
|
170
|
+
ovcMsg1: AuthBroadcastMessage,
|
171
|
+
ovcToBitgoMsg2: AuthEncP2PMessage,
|
172
|
+
ovcToOvcMsg2: AuthEncP2PMessage,
|
173
|
+
}),
|
174
|
+
}),
|
175
|
+
platform: PlatformRound2Payload,
|
176
|
+
}),
|
177
|
+
]);
|
178
|
+
|
179
|
+
export type OVC1ToOVC2Round3Payload = t.TypeOf<typeof OVC1ToOVC2Round3Payload>;
|
180
|
+
|
181
|
+
export const OVC2ToOVC1Round3Payload = t.intersection([
|
182
|
+
BaseRoundPayload,
|
183
|
+
t.type({
|
184
|
+
ovc: t.type({
|
185
|
+
[OVCIndexEnum.ONE]: t.type({
|
186
|
+
gpgPubKey: NonEmptyString,
|
187
|
+
ovcMsg1: AuthBroadcastMessage,
|
188
|
+
ovcToBitgoMsg2: AuthEncP2PMessage,
|
189
|
+
ovcToOvcMsg2: AuthEncP2PMessage,
|
190
|
+
ovcToBitgoMsg3: AuthEncP2PMessage,
|
191
|
+
ovcToOvcMsg3: AuthEncP2PMessage,
|
192
|
+
}),
|
193
|
+
[OVCIndexEnum.TWO]: t.type({
|
194
|
+
gpgPubKey: NonEmptyString,
|
195
|
+
ovcMsg1: AuthBroadcastMessage,
|
196
|
+
ovcToBitgoMsg2: AuthEncP2PMessage,
|
197
|
+
ovcToOvcMsg2: AuthEncP2PMessage,
|
198
|
+
ovcToBitgoMsg3: AuthEncP2PMessage,
|
199
|
+
ovcToOvcMsg3: AuthEncP2PMessage,
|
200
|
+
ovcMsg4: AuthBroadcastMessage,
|
201
|
+
}),
|
202
|
+
}),
|
203
|
+
platform: PlatformRound2Payload,
|
204
|
+
}),
|
205
|
+
]);
|
206
|
+
|
207
|
+
export type OVC2ToOVC1Round3Payload = t.TypeOf<typeof OVC2ToOVC1Round3Payload>;
|
208
|
+
|
209
|
+
export const OVC1ToBitgoRound3Payload = t.intersection([
|
210
|
+
BaseRoundPayload,
|
211
|
+
t.type({
|
212
|
+
ovc: t.type({
|
213
|
+
[OVCIndexEnum.ONE]: t.type({
|
214
|
+
gpgPubKey: NonEmptyString,
|
215
|
+
ovcMsg1: AuthBroadcastMessage,
|
216
|
+
ovcToBitgoMsg2: AuthEncP2PMessage,
|
217
|
+
ovcToOvcMsg2: AuthEncP2PMessage,
|
218
|
+
ovcToBitgoMsg3: AuthEncP2PMessage,
|
219
|
+
ovcToOvcMsg3: AuthEncP2PMessage,
|
220
|
+
ovcMsg4: AuthBroadcastMessage,
|
221
|
+
}),
|
222
|
+
[OVCIndexEnum.TWO]: t.type({
|
223
|
+
gpgPubKey: NonEmptyString,
|
224
|
+
ovcMsg1: AuthBroadcastMessage,
|
225
|
+
ovcToBitgoMsg2: AuthEncP2PMessage,
|
226
|
+
ovcToOvcMsg2: AuthEncP2PMessage,
|
227
|
+
ovcToBitgoMsg3: AuthEncP2PMessage,
|
228
|
+
ovcToOvcMsg3: AuthEncP2PMessage,
|
229
|
+
ovcMsg4: AuthBroadcastMessage,
|
230
|
+
}),
|
231
|
+
}),
|
232
|
+
platform: PlatformRound2Payload,
|
233
|
+
}),
|
234
|
+
]);
|
235
|
+
|
236
|
+
export type OVC1ToBitgoRound3Payload = t.TypeOf<
|
237
|
+
typeof OVC1ToBitgoRound3Payload
|
238
|
+
>;
|
239
|
+
|
240
|
+
export const PlatformRound3Payload = t.intersection([
|
241
|
+
PlatformRound2Payload,
|
242
|
+
t.type({
|
243
|
+
commonKeychain: NonEmptyString,
|
244
|
+
bitgoMsg4: AuthBroadcastMessage,
|
245
|
+
}),
|
246
|
+
]);
|
247
|
+
|
248
|
+
export type PlatformRound3Payload = t.TypeOf<typeof PlatformRound3Payload>;
|
249
|
+
|
250
|
+
export const BitgoToOVC1Round3Response = t.type({
|
251
|
+
bitGoKeyId: NonEmptyString,
|
252
|
+
wallet: t.intersection([
|
253
|
+
OVC1ToBitgoRound3Payload,
|
254
|
+
t.type({ platform: PlatformRound3Payload }),
|
255
|
+
]),
|
256
|
+
});
|
257
|
+
|
258
|
+
export type BitgoToOVC1Round3Response = t.TypeOf<
|
259
|
+
typeof BitgoToOVC1Round3Response
|
260
|
+
>;
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import * as t from "io-ts";
|
2
|
+
|
3
|
+
export enum KeyCreationMPCv2StateEnum {
|
4
|
+
WaitingForOVC1Round1Data = -1,
|
5
|
+
WaitingForOVC2Round1Data,
|
6
|
+
WaitingForBitgoRound1Data,
|
7
|
+
WaitingForOVC1Round2Data,
|
8
|
+
WaitingForOVC2Round2Data,
|
9
|
+
WaitingForBitgoRound2Data,
|
10
|
+
WaitingForOVC1Round3aData,
|
11
|
+
WaitingForOVC2Round3Data,
|
12
|
+
WaitingForOVC1Round3bData,
|
13
|
+
WaitingForBitgoRound3Data,
|
14
|
+
WaitingForOVC1GenerateKey,
|
15
|
+
WaitingForOVC2GenerateKey,
|
16
|
+
KeyGenerationComplete,
|
17
|
+
}
|
18
|
+
|
19
|
+
export const KeyCreationMPCv2State = t.union([
|
20
|
+
t.literal(KeyCreationMPCv2StateEnum.WaitingForOVC1Round1Data),
|
21
|
+
t.literal(KeyCreationMPCv2StateEnum.WaitingForOVC2Round1Data),
|
22
|
+
t.literal(KeyCreationMPCv2StateEnum.WaitingForBitgoRound1Data),
|
23
|
+
t.literal(KeyCreationMPCv2StateEnum.WaitingForOVC1Round2Data),
|
24
|
+
t.literal(KeyCreationMPCv2StateEnum.WaitingForOVC2Round2Data),
|
25
|
+
t.literal(KeyCreationMPCv2StateEnum.WaitingForBitgoRound2Data),
|
26
|
+
t.literal(KeyCreationMPCv2StateEnum.WaitingForOVC1Round3aData),
|
27
|
+
t.literal(KeyCreationMPCv2StateEnum.WaitingForOVC2Round3Data),
|
28
|
+
t.literal(KeyCreationMPCv2StateEnum.WaitingForOVC1Round3bData),
|
29
|
+
t.literal(KeyCreationMPCv2StateEnum.WaitingForBitgoRound3Data),
|
30
|
+
t.literal(KeyCreationMPCv2StateEnum.WaitingForOVC1GenerateKey),
|
31
|
+
t.literal(KeyCreationMPCv2StateEnum.WaitingForOVC2GenerateKey),
|
32
|
+
t.literal(KeyCreationMPCv2StateEnum.KeyGenerationComplete),
|
33
|
+
]);
|
34
|
+
|
35
|
+
export type KeyCreationMPCv2State = t.TypeOf<typeof KeyCreationMPCv2State>;
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import * as t from "io-ts";
|
2
|
+
|
3
|
+
import { MPCv2PartyFromStringOrNumber } from "../../common";
|
4
|
+
|
5
|
+
const AuthMessage = t.type({
|
6
|
+
message: t.string,
|
7
|
+
signature: t.string,
|
8
|
+
});
|
9
|
+
|
10
|
+
type AuthMessage = t.TypeOf<typeof AuthMessage>;
|
11
|
+
|
12
|
+
export const AuthBroadcastMessage = t.intersection([
|
13
|
+
t.type({
|
14
|
+
payload: AuthMessage,
|
15
|
+
from: MPCv2PartyFromStringOrNumber,
|
16
|
+
}),
|
17
|
+
t.partial({
|
18
|
+
signatureR: t.string,
|
19
|
+
}),
|
20
|
+
]);
|
21
|
+
|
22
|
+
export type AuthBroadcastMessage = t.TypeOf<typeof AuthBroadcastMessage>;
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import * as t from "io-ts";
|
2
|
+
import { NonEmptyString } from "io-ts-types";
|
3
|
+
|
4
|
+
import { MPCv2PartyFromStringOrNumber } from "../../common";
|
5
|
+
|
6
|
+
const AuthEncMessage = t.type({
|
7
|
+
encryptedMessage: NonEmptyString,
|
8
|
+
signature: NonEmptyString,
|
9
|
+
});
|
10
|
+
|
11
|
+
type AuthEncMessage = t.TypeOf<typeof AuthEncMessage>;
|
12
|
+
|
13
|
+
export const AuthEncP2PMessage = t.intersection([
|
14
|
+
t.type({
|
15
|
+
payload: AuthEncMessage,
|
16
|
+
from: MPCv2PartyFromStringOrNumber,
|
17
|
+
to: MPCv2PartyFromStringOrNumber,
|
18
|
+
}),
|
19
|
+
t.partial({
|
20
|
+
commitment: NonEmptyString,
|
21
|
+
}),
|
22
|
+
]);
|
23
|
+
|
24
|
+
export type AuthEncP2PMessage = t.TypeOf<typeof AuthEncP2PMessage>;
|