Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions modules/bitgo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
"@bitgo/utxo-lib": "^11.24.4",
"@types/superagent": "^4.1.3",
"bignumber.js": "^9.1.1",
"cbor-x": "1.5.9",
"lodash": "^4.18.0",
"openpgp": "5.11.3",
"stellar-sdk": "^10.0.1",
Expand Down

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions modules/sdk-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"@bitgo/sdk-lib-mpc": "^10.18.0",
"@bitgo/secp256k1": "^1.11.1",
"@bitgo/sjcl": "^1.1.0",
"cbor-x": "1.5.9",
"@bitgo/statics": "^59.12.0",
"@bitgo/utxo-lib": "^11.24.4",
"@noble/curves": "1.8.1",
Expand Down
9 changes: 8 additions & 1 deletion modules/sdk-core/src/bitgo/keychain/keychains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,14 @@ export class Keychains implements IKeychains {
if (this.baseCoin.getMPCAlgorithm() === 'eddsa') {
MpcUtils = isMPCv2 ? EDDSAUtils.EddsaMPCv2Utils : EDDSAUtils.default;
} else {
MpcUtils = isMPCv2 ? ECDSAUtils.EcdsaMPCv2Utils : ECDSAUtils.EcdsaUtils;
// A safeId on a keygen ceremony selects the VRF variant, which additionally runs the
// VRF DKG alongside the signing DKG. Ordinary TSS wallet creation never sets safeId
// and keeps the plain MPCv2 flow.
MpcUtils = isMPCv2
? params.safeId
? ECDSAUtils.EcdsaVrfMPCv2Utils
: ECDSAUtils.EcdsaMPCv2Utils
: ECDSAUtils.EcdsaUtils;
}

const mpcUtils = new MpcUtils(this.bitgo, this.baseCoin);
Expand Down
549 changes: 549 additions & 0 deletions modules/sdk-core/src/bitgo/utils/tss/ecdsa/ecdsaVrfMPCv2.ts

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions modules/sdk-core/src/bitgo/utils/tss/ecdsa/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from './ecdsa';
export * from './ecdsaMPCv2';
export * from './ecdsaVrfMPCv2';
export * from './types';
export * from './typesMPCv2';
export * from './SMC/utils';
Expand Down
24 changes: 21 additions & 3 deletions modules/sdk-core/src/bitgo/utils/tss/ecdsa/typesMPCv2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,30 @@ export const generateMPCv2KeyRequestBody = t.union([
MPCv2KeyGenRound3Request,
]);

export type GenerateMPCv2KeyRequestBody = t.TypeOf<typeof generateMPCv2KeyRequestBody>;

export const generateMPCv2KeyRequestResponse = t.union([
MPCv2KeyGenRound1Response,
MPCv2KeyGenRound2Response,
MPCv2KeyGenRound3Response,
]);

export type GenerateMPCv2KeyRequestResponse = t.TypeOf<typeof generateMPCv2KeyRequestResponse>;
/**
* Optional VRF DKG message fields carried on the MPCv2-R1/R2 keygen round payloads as
* opaque base64 blobs. Only set when the ceremony runs the VRF DKG alongside the
* signing DKG (safe root keys); ordinary TSS wallet creation payloads are unchanged.
*/
export type MpcV2VrfKeyGenRequestFields = {
userVrfMsg1?: string;
backupVrfMsg1?: string;
userVrfMsg2?: string;
backupVrfMsg2?: string;
};

export type MpcV2VrfKeyGenResponseFields = {
bitgoVrfMsg1?: string;
bitgoVrfMsg2?: string;
};

export type GenerateMPCv2KeyRequestBody = t.TypeOf<typeof generateMPCv2KeyRequestBody> & MpcV2VrfKeyGenRequestFields;

export type GenerateMPCv2KeyRequestResponse = t.TypeOf<typeof generateMPCv2KeyRequestResponse> &
MpcV2VrfKeyGenResponseFields;
4 changes: 2 additions & 2 deletions modules/sdk-lib-mpc/src/tss/dkls-vrf/dkg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ export class VrfDkg {
.filter((m) => m.to_id === undefined)
.map((m) => ({ payload: new Uint8Array(m.payload), from: m.from_id }));
nextRoundDeserializedMessages.p2pMessages = nextRoundMessages
.filter((m) => m.to_id !== undefined)
.map((m) => ({ payload: new Uint8Array(m.payload), from: m.from_id, to: m.to_id! }));
.filter((m): m is VrfWasmMessage & { to_id: number } => m.to_id !== undefined)
.map((m) => ({ payload: new Uint8Array(m.payload), from: m.from_id, to: m.to_id }));
return nextRoundDeserializedMessages;
} catch (e) {
throw Error(`Error while creating VRF messages from party ${this.partyIdx}, state ${this.vrfState}: ${e}`);
Expand Down
Loading