diff --git a/ironfish-rust-nodejs/index.d.ts b/ironfish-rust-nodejs/index.d.ts index a9f41d68c6..c6744d3551 100644 --- a/ironfish-rust-nodejs/index.d.ts +++ b/ironfish-rust-nodejs/index.d.ts @@ -4,13 +4,10 @@ /* auto-generated by NAPI-RS */ export interface Commitment { + identifier: string hiding: string binding: string } -export interface IdentifierCommitment { - identifier: string - commitment: Commitment -} export function createSigningCommitment(keyPackage: string, seed: number): Commitment export function createSigningShare(signingPackage: string, keyPackage: string, publicKeyRandomness: string, seed: number): string export function splitSecret(coordinatorSaplingKey: string, minSigners: number, identifiers: Array): TrustedDealerKeyPackages @@ -250,7 +247,7 @@ export class UnsignedTransaction { constructor(jsBytes: Buffer) serialize(): Buffer publicKeyRandomness(): string - signingPackage(nativeIdentiferCommitments: Array): string + signingPackage(nativeIdentiferCommitments: Array): string sign(spenderHexKey: string): Buffer signFrost(publicKeyPackageStr: string, signingPackageStr: string, signatureSharesMap: Record): Buffer } diff --git a/ironfish-rust-nodejs/src/frost.rs b/ironfish-rust-nodejs/src/frost.rs index c7c80f6b74..660da3371c 100644 --- a/ironfish-rust-nodejs/src/frost.rs +++ b/ironfish-rust-nodejs/src/frost.rs @@ -23,16 +23,11 @@ use rand::thread_rng; #[napi(object, js_name = "Commitment")] pub struct NativeCommitment { + pub identifier: String, pub hiding: String, pub binding: String, } -#[napi(object, js_name = "IdentifierCommitment")] -pub struct NativeIdentifierCommitment { - pub identifier: String, - pub commitment: NativeCommitment, -} - #[napi] pub fn create_signing_commitment(key_package: String, seed: u32) -> Result { let key_package = @@ -40,6 +35,7 @@ pub fn create_signing_commitment(key_package: String, seed: u32) -> Result, + native_identifer_commitments: Vec, ) -> Result { let mut commitments: BTreeMap = BTreeMap::new(); @@ -425,11 +425,11 @@ impl NativeUnsignedTransaction { let commitment = SigningCommitments::new( NonceCommitment::deserialize( - hex_to_bytes(&identifier_commitment.commitment.hiding).map_err(to_napi_err)?, + hex_to_bytes(&identifier_commitment.hiding).map_err(to_napi_err)?, ) .map_err(to_napi_err)?, NonceCommitment::deserialize( - hex_to_bytes(&identifier_commitment.commitment.binding).map_err(to_napi_err)?, + hex_to_bytes(&identifier_commitment.binding).map_err(to_napi_err)?, ) .map_err(to_napi_err)?, ); diff --git a/ironfish/src/rpc/routes/multisig/createSigningCommitment.ts b/ironfish/src/rpc/routes/multisig/createSigningCommitment.ts index 52094e95c4..7741a565e2 100644 --- a/ironfish/src/rpc/routes/multisig/createSigningCommitment.ts +++ b/ironfish/src/rpc/routes/multisig/createSigningCommitment.ts @@ -32,6 +32,7 @@ routes.register { const trustedDealerPackage = response.content - const commitments: Array = [] + const commitments: Array = [] for (let i = 0; i < 3; i++) { - const commitment = await routeTest.client.multisig.createSigningCommitment({ + const signingCommitment = await routeTest.client.multisig.createSigningCommitment({ keyPackage: trustedDealerPackage.keyPackages[i].keyPackage, seed, }) - - commitments.push({ - identifier: trustedDealerPackage.keyPackages[i].identifier, - commitment: commitment.content, - }) + commitments.push(signingCommitment.content) } const account = await useAccountFixture(nodeTest.wallet) diff --git a/ironfish/src/rpc/routes/multisig/createSigningPackage.ts b/ironfish/src/rpc/routes/multisig/createSigningPackage.ts index 12e49aa0d7..fc3f142c82 100644 --- a/ironfish/src/rpc/routes/multisig/createSigningPackage.ts +++ b/ironfish/src/rpc/routes/multisig/createSigningPackage.ts @@ -9,10 +9,7 @@ import { RpcSigningCommitments, RpcSigningCommitmentsSchema } from './types' export type CreateSigningPackageRequest = { unsignedTransaction: string - commitments: Array<{ - identifier: string - commitment: RpcSigningCommitments - }> + commitments: Array } export type CreateSigningPackageResponse = { @@ -23,16 +20,7 @@ export const CreateSigningPackageRequestSchema: yup.ObjectSchema = yup .object({ + identifier: yup.string().defined(), hiding: yup.string().defined(), binding: yup.string().defined(), }) diff --git a/ironfish/src/wallet/wallet.test.slow.ts b/ironfish/src/wallet/wallet.test.slow.ts index c4e95ab57b..a657598663 100644 --- a/ironfish/src/wallet/wallet.test.slow.ts +++ b/ironfish/src/wallet/wallet.test.slow.ts @@ -4,6 +4,7 @@ import { Asset, ASSET_ID_LENGTH, + Commitment, createSigningCommitment, createSigningShare, generateKey, @@ -1141,7 +1142,6 @@ describe('Wallet', () => { it('can do a multisig transaction', async () => { const seed = 420 const minSigners = 2 - const participants = 3 const { node } = await nodeTest.createSetup() const recipient = await useAccountFixture(node.wallet, 'recipient') @@ -1150,7 +1150,7 @@ describe('Wallet', () => { const identifiers: string[] = [] - for (let i = 0; i < participants; i++) { + for (let i = 0; i < 3; i++) { identifiers.push(ParticipantSecret.random().toIdentity().toFrostIdentifier()) } @@ -1198,6 +1198,9 @@ describe('Wallet', () => { multiSigKeys: getMultiSigKeys(2), ...trustedDealerPackage, }) + + const participants = [participantA, participantB, participantC] + const coordinator = await node.wallet.importAccount({ version: 4, id: uuid(), @@ -1210,27 +1213,14 @@ describe('Wallet', () => { ...trustedDealerPackage, }) - Assert.isNotUndefined(participantA.multiSigKeys) - Assert.isNotUndefined(participantB.multiSigKeys) - Assert.isNotUndefined(participantC.multiSigKeys) - AssertIsSignerMultiSig(participantA.multiSigKeys) - AssertIsSignerMultiSig(participantB.multiSigKeys) - AssertIsSignerMultiSig(participantC.multiSigKeys) - - const signingCommitments = [ - { - identifier: participantA.multiSigKeys.identifier, - commitment: createSigningCommitment(participantA.multiSigKeys.keyPackage, seed), - }, - { - identifier: participantB.multiSigKeys.identifier, - commitment: createSigningCommitment(participantB.multiSigKeys.keyPackage, seed), - }, - { - identifier: participantC.multiSigKeys.identifier, - commitment: createSigningCommitment(participantC.multiSigKeys.keyPackage, seed), - }, - ] + const signingCommitments: Commitment[] = [] + for (const participant of participants) { + Assert.isNotUndefined(participant.multiSigKeys) + AssertIsSignerMultiSig(participant.multiSigKeys) + signingCommitments.push( + createSigningCommitment(participant.multiSigKeys.keyPackage, seed), + ) + } // mine block to send IRON to multisig account const miner = await useAccountFixture(node.wallet, 'miner') @@ -1295,25 +1285,17 @@ describe('Wallet', () => { const signingPackage = unsignedTransaction.signingPackage(signingCommitments) const publicKeyRandomness = unsignedTransaction.publicKeyRandomness() - const signatureShares: Record = { - [participantA.multiSigKeys.identifier]: createSigningShare( - signingPackage, - participantA.multiSigKeys.keyPackage, - publicKeyRandomness, - seed, - ), - [participantB.multiSigKeys.identifier]: createSigningShare( - signingPackage, - participantB.multiSigKeys.keyPackage, - publicKeyRandomness, - seed, - ), - [participantC.multiSigKeys.identifier]: createSigningShare( + const signatureShares: Record = {} + + for (const participant of participants) { + Assert.isNotUndefined(participant.multiSigKeys) + AssertIsSignerMultiSig(participant.multiSigKeys) + signatureShares[participant.multiSigKeys.identifier] = createSigningShare( signingPackage, - participantC.multiSigKeys.keyPackage, + participant.multiSigKeys.keyPackage, publicKeyRandomness, seed, - ), + ) } Assert.isNotUndefined(coordinator.multiSigKeys)