From 472e12ba4831fc577d83edeabef16030b7fe36f4 Mon Sep 17 00:00:00 2001 From: Hugh Cunningham Date: Wed, 22 Jan 2025 14:35:48 -0800 Subject: [PATCH 1/2] reads identity from ledger in dkg round1 when running DKG using a Ledger device, the user's identity must match the identity from the Ledger device. rather than reading an identity from the node based on a name we can read the identity directly from the Ledger. reads identity from Ledger in 'wallet:multisig:dkg:round1' and 'wallet:multisig:dkg:create' instead of reading the identity from the node --- .../src/commands/wallet/multisig/dkg/create.ts | 13 ++----------- .../src/commands/wallet/multisig/dkg/round1.ts | 13 +++---------- 2 files changed, 5 insertions(+), 21 deletions(-) diff --git a/ironfish-cli/src/commands/wallet/multisig/dkg/create.ts b/ironfish-cli/src/commands/wallet/multisig/dkg/create.ts index c150ce4854..2adcfcff0f 100644 --- a/ironfish-cli/src/commands/wallet/multisig/dkg/create.ts +++ b/ironfish-cli/src/commands/wallet/multisig/dkg/create.ts @@ -301,15 +301,12 @@ export class DkgCreateCommand extends IronfishCommand { async performRound1WithLedger( ledger: LedgerMultiSigner, - client: RpcClient, - participantName: string, identities: string[], minSigners: number, ): Promise<{ round1: { secretPackage: string; publicPackage: string } }> { - const identityResponse = await client.wallet.multisig.getIdentity({ name: participantName }) - const identity = identityResponse.content.identity + const identity = (await ledger.dkgGetIdentity(0, false)).toString('hex') if (!identities.includes(identity)) { identities.push(identity) @@ -351,13 +348,7 @@ export class DkgCreateCommand extends IronfishCommand { }) if (ledger) { - return await this.performRound1WithLedger( - ledger, - client, - participantName, - identities, - minSigners, - ) + return await this.performRound1WithLedger(ledger, identities, minSigners) } this.log('\nPerforming DKG Round 1...') diff --git a/ironfish-cli/src/commands/wallet/multisig/dkg/round1.ts b/ironfish-cli/src/commands/wallet/multisig/dkg/round1.ts index 3edae07d70..a462cbdac4 100644 --- a/ironfish-cli/src/commands/wallet/multisig/dkg/round1.ts +++ b/ironfish-cli/src/commands/wallet/multisig/dkg/round1.ts @@ -1,7 +1,6 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -import { RpcClient } from '@ironfish/sdk' import { Flags } from '@oclif/core' import { IronfishCommand } from '../../../../command' import { RemoteFlags } from '../../../../flags' @@ -72,7 +71,7 @@ export class DkgRound1Command extends IronfishCommand { } if (flags.ledger) { - await this.performRound1WithLedger(client, participantName, identities, minSigners) + await this.performRound1WithLedger(identities, minSigners) return } @@ -94,16 +93,10 @@ export class DkgRound1Command extends IronfishCommand { this.log('Send the round 1 public package to each participant') } - async performRound1WithLedger( - client: RpcClient, - participantName: string, - identities: string[], - minSigners: number, - ): Promise { + async performRound1WithLedger(identities: string[], minSigners: number): Promise { const ledger = new LedgerMultiSigner() - const identityResponse = await client.wallet.multisig.getIdentity({ name: participantName }) - const identity = identityResponse.content.identity + const identity = (await ledger.dkgGetIdentity(0, false)).toString('hex') if (!identities.includes(identity)) { identities.push(identity) From f33515f24a588f9b3f2628e6f1f4687edb5db5f1 Mon Sep 17 00:00:00 2001 From: Hugh Cunningham Date: Wed, 22 Jan 2025 16:40:17 -0800 Subject: [PATCH 2/2] uses 'ui.ledger' for error handling when reading identity from ledger --- ironfish-cli/src/commands/wallet/multisig/dkg/create.ts | 8 +++++++- ironfish-cli/src/commands/wallet/multisig/dkg/round1.ts | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/ironfish-cli/src/commands/wallet/multisig/dkg/create.ts b/ironfish-cli/src/commands/wallet/multisig/dkg/create.ts index 2adcfcff0f..c291a97c8a 100644 --- a/ironfish-cli/src/commands/wallet/multisig/dkg/create.ts +++ b/ironfish-cli/src/commands/wallet/multisig/dkg/create.ts @@ -306,7 +306,13 @@ export class DkgCreateCommand extends IronfishCommand { ): Promise<{ round1: { secretPackage: string; publicPackage: string } }> { - const identity = (await ledger.dkgGetIdentity(0, false)).toString('hex') + const identity = ( + await ui.ledger({ + ledger, + message: 'Getting Ledger Identity', + action: () => ledger.dkgGetIdentity(0), + }) + ).toString('hex') if (!identities.includes(identity)) { identities.push(identity) diff --git a/ironfish-cli/src/commands/wallet/multisig/dkg/round1.ts b/ironfish-cli/src/commands/wallet/multisig/dkg/round1.ts index a462cbdac4..379153c8b0 100644 --- a/ironfish-cli/src/commands/wallet/multisig/dkg/round1.ts +++ b/ironfish-cli/src/commands/wallet/multisig/dkg/round1.ts @@ -96,7 +96,13 @@ export class DkgRound1Command extends IronfishCommand { async performRound1WithLedger(identities: string[], minSigners: number): Promise { const ledger = new LedgerMultiSigner() - const identity = (await ledger.dkgGetIdentity(0, false)).toString('hex') + const identity = ( + await ui.ledger({ + ledger, + message: 'Getting Ledger Identity', + action: () => ledger.dkgGetIdentity(0), + }) + ).toString('hex') if (!identities.includes(identity)) { identities.push(identity)