From f3f192266512a9a30f2d18ddf2f56f9ad4ddd382 Mon Sep 17 00:00:00 2001 From: Hugh Cunningham <57735705+hughy@users.noreply.github.com> Date: Tue, 6 Feb 2024 14:43:03 -0800 Subject: [PATCH] renames SigningShare to SignatureShare (#4694) * renames SigningShare to SignatureShare the frost crates use the term SignatureShare to refer to a part of a signature, but we have used the term SigningShare the term 'SigningShare' can be confused with the 'signing_share' part of a key package, used to create signing commitments and signature shares renames SigningShare to SignatureShare in rust types, napi bindings, and multisig RPCs * updates test to use fully qualified rpc route --- ironfish-rust-nodejs/index.d.ts | 2 +- ironfish-rust-nodejs/index.js | 4 +- ironfish-rust-nodejs/src/frost.rs | 6 +-- .../src/structs/transaction.rs | 2 +- ironfish-rust/src/frost_utils/mod.rs | 2 +- .../{signing_share.rs => signature_share.rs} | 2 +- ironfish-rust/src/transaction/tests.rs | 10 ++--- ironfish/src/rpc/clients/client.ts | 28 ++++++------- ...e => createSignatureShare.test.ts.fixture} | 2 +- ...gShares.ts => aggregateSignatureShares.ts} | 20 +++++----- ...e.test.ts => createSignatureShare.test.ts} | 6 +-- ...igningShare.ts => createSignatureShare.ts} | 39 ++++++++++--------- .../src/rpc/routes/wallet/multisig/index.ts | 4 +- ironfish/src/wallet/wallet.test.slow.ts | 4 +- 14 files changed, 66 insertions(+), 65 deletions(-) rename ironfish-rust/src/frost_utils/{signing_share.rs => signature_share.rs} (98%) rename ironfish/src/rpc/routes/wallet/multisig/__fixtures__/{createSigningShare.test.ts.fixture => createSignatureShare.test.ts.fixture} (89%) rename ironfish/src/rpc/routes/wallet/multisig/{aggregateSigningShares.ts => aggregateSignatureShares.ts} (70%) rename ironfish/src/rpc/routes/wallet/multisig/{createSigningShare.test.ts => createSignatureShare.test.ts} (88%) rename ironfish/src/rpc/routes/wallet/multisig/{createSigningShare.ts => createSignatureShare.ts} (56%) diff --git a/ironfish-rust-nodejs/index.d.ts b/ironfish-rust-nodejs/index.d.ts index 7f6e4ef465..546f089603 100644 --- a/ironfish-rust-nodejs/index.d.ts +++ b/ironfish-rust-nodejs/index.d.ts @@ -9,7 +9,7 @@ export interface Commitment { binding: string } export function createSigningCommitment(keyPackage: string, seed: number): Commitment -export function createSigningShare(signingPackage: string, identifier: string, keyPackage: string, publicKeyRandomness: string, seed: number): string +export function createSignatureShare(signingPackage: string, identifier: string, keyPackage: string, publicKeyRandomness: string, seed: number): string export function splitSecret(coordinatorSaplingKey: string, minSigners: number, identifiers: Array): TrustedDealerKeyPackages export function contribute(inputPath: string, outputPath: string, seed?: string | undefined | null): Promise export function verifyTransform(paramsPath: string, newParamsPath: string): Promise diff --git a/ironfish-rust-nodejs/index.js b/ironfish-rust-nodejs/index.js index 526169e3ec..8c5d729d83 100644 --- a/ironfish-rust-nodejs/index.js +++ b/ironfish-rust-nodejs/index.js @@ -252,11 +252,11 @@ if (!nativeBinding) { throw new Error(`Failed to load native binding`) } -const { FishHashContext, createSigningCommitment, createSigningShare, ParticipantSecret, ParticipantIdentity, splitSecret, contribute, verifyTransform, KEY_LENGTH, NONCE_LENGTH, BoxKeyPair, randomBytes, boxMessage, unboxMessage, RollingFilter, initSignalHandler, triggerSegfault, ASSET_ID_LENGTH, ASSET_METADATA_LENGTH, ASSET_NAME_LENGTH, ASSET_LENGTH, Asset, NOTE_ENCRYPTION_KEY_LENGTH, MAC_LENGTH, ENCRYPTED_NOTE_PLAINTEXT_LENGTH, ENCRYPTED_NOTE_LENGTH, NoteEncrypted, PUBLIC_ADDRESS_LENGTH, RANDOMNESS_LENGTH, MEMO_LENGTH, AMOUNT_VALUE_LENGTH, DECRYPTED_NOTE_LENGTH, Note, PROOF_LENGTH, TRANSACTION_SIGNATURE_LENGTH, TRANSACTION_PUBLIC_KEY_RANDOMNESS_LENGTH, TRANSACTION_EXPIRATION_LENGTH, TRANSACTION_FEE_LENGTH, LATEST_TRANSACTION_VERSION, TransactionPosted, Transaction, verifyTransactions, UnsignedTransaction, LanguageCode, generateKey, spendingKeyToWords, wordsToSpendingKey, generateKeyFromPrivateKey, initializeSapling, FoundBlockResult, ThreadPoolHandler, isValidPublicAddress } = nativeBinding +const { FishHashContext, createSigningCommitment, createSignatureShare, ParticipantSecret, ParticipantIdentity, splitSecret, contribute, verifyTransform, KEY_LENGTH, NONCE_LENGTH, BoxKeyPair, randomBytes, boxMessage, unboxMessage, RollingFilter, initSignalHandler, triggerSegfault, ASSET_ID_LENGTH, ASSET_METADATA_LENGTH, ASSET_NAME_LENGTH, ASSET_LENGTH, Asset, NOTE_ENCRYPTION_KEY_LENGTH, MAC_LENGTH, ENCRYPTED_NOTE_PLAINTEXT_LENGTH, ENCRYPTED_NOTE_LENGTH, NoteEncrypted, PUBLIC_ADDRESS_LENGTH, RANDOMNESS_LENGTH, MEMO_LENGTH, AMOUNT_VALUE_LENGTH, DECRYPTED_NOTE_LENGTH, Note, PROOF_LENGTH, TRANSACTION_SIGNATURE_LENGTH, TRANSACTION_PUBLIC_KEY_RANDOMNESS_LENGTH, TRANSACTION_EXPIRATION_LENGTH, TRANSACTION_FEE_LENGTH, LATEST_TRANSACTION_VERSION, TransactionPosted, Transaction, verifyTransactions, UnsignedTransaction, LanguageCode, generateKey, spendingKeyToWords, wordsToSpendingKey, generateKeyFromPrivateKey, initializeSapling, FoundBlockResult, ThreadPoolHandler, isValidPublicAddress } = nativeBinding module.exports.FishHashContext = FishHashContext module.exports.createSigningCommitment = createSigningCommitment -module.exports.createSigningShare = createSigningShare +module.exports.createSignatureShare = createSignatureShare module.exports.ParticipantSecret = ParticipantSecret module.exports.ParticipantIdentity = ParticipantIdentity module.exports.splitSecret = splitSecret diff --git a/ironfish-rust-nodejs/src/frost.rs b/ironfish-rust-nodejs/src/frost.rs index 6009132f5b..a0d97e4385 100644 --- a/ironfish-rust-nodejs/src/frost.rs +++ b/ironfish-rust-nodejs/src/frost.rs @@ -9,8 +9,8 @@ use crate::{ use ironfish::{ frost::{keys::KeyPackage, round2::Randomizer, Identifier, SigningPackage}, frost_utils::{ + signature_share::create_signature_share as create_signature_share_rust, signing_commitment::create_signing_commitment as create_signing_commitment_rust, - signing_share::create_signing_share as create_signing_share_rust, split_spender_key::split_spender_key, }, participant::{Identity, Secret}, @@ -42,7 +42,7 @@ pub fn create_signing_commitment(key_package: String, seed: u32) -> Result = BTreeMap::new(); + let mut signature_shares: BTreeMap = BTreeMap::new(); let randomizer = Randomizer::deserialize(&unsigned_transaction.public_key_randomness.to_bytes()) .expect("should be able to deserialize randomizer"); for key_package in key_packages.key_packages.iter() { - let signature_share = create_signing_share( + let signature_share = create_signature_share( signing_package.clone(), *key_package.0, key_package.1.clone(), @@ -807,7 +807,7 @@ fn test_aggregate_signature_shares() { 0, ) .expect("should be able to create signature share"); - signing_shares.insert(signature_share.identifier, signature_share.signature_share); + signature_shares.insert(signature_share.identifier, signature_share.signature_share); } // coordinator creates signed transaction @@ -815,7 +815,7 @@ fn test_aggregate_signature_shares() { .aggregate_signature_shares( &key_packages.public_key_package, &signing_package, - signing_shares, + signature_shares, ) .expect("should be able to sign transaction"); diff --git a/ironfish/src/rpc/clients/client.ts b/ironfish/src/rpc/clients/client.ts index 9ca3fc0b0a..3939a3c519 100644 --- a/ironfish/src/rpc/clients/client.ts +++ b/ironfish/src/rpc/clients/client.ts @@ -9,8 +9,8 @@ import type { AddPeerResponse, AddTransactionRequest, AddTransactionResponse, - AggregateSigningSharesRequest, - AggregateSigningSharesResponse, + AggregateSignatureSharesRequest, + AggregateSignatureSharesResponse, BlockTemplateStreamRequest, BlockTemplateStreamResponse, BroadcastTransactionRequest, @@ -21,12 +21,12 @@ import type { BurnAssetResponse, CreateAccountRequest, CreateAccountResponse, + CreateSignatureShareRequest, + CreateSignatureShareResponse, CreateSigningCommitmentRequest, CreateSigningCommitmentResponse, CreateSigningPackageRequest, CreateSigningPackageResponse, - CreateSigningShareRequest, - CreateSigningShareResponse, CreateTransactionRequest, CreateTransactionResponse, CreateTrustedDealerKeyPackageRequest, @@ -181,11 +181,11 @@ export abstract class RpcClient { wallet = { multisig: { - aggregateSigningShares: ( - params: AggregateSigningSharesRequest, - ): Promise> => { - return this.request( - `${ApiNamespace.wallet}/multisig/aggregateSigningShares`, + aggregateSignatureShares: ( + params: AggregateSignatureSharesRequest, + ): Promise> => { + return this.request( + `${ApiNamespace.wallet}/multisig/aggregateSignatureShares`, params, ).waitForEnd() }, @@ -217,11 +217,11 @@ export abstract class RpcClient { ).waitForEnd() }, - createSigningShare: ( - params: CreateSigningShareRequest, - ): Promise> => { - return this.request( - `${ApiNamespace.wallet}/multisig/createSigningShare`, + createSignatureShare: ( + params: CreateSignatureShareRequest, + ): Promise> => { + return this.request( + `${ApiNamespace.wallet}/multisig/createSignatureShare`, params, ).waitForEnd() }, diff --git a/ironfish/src/rpc/routes/wallet/multisig/__fixtures__/createSigningShare.test.ts.fixture b/ironfish/src/rpc/routes/wallet/multisig/__fixtures__/createSignatureShare.test.ts.fixture similarity index 89% rename from ironfish/src/rpc/routes/wallet/multisig/__fixtures__/createSigningShare.test.ts.fixture rename to ironfish/src/rpc/routes/wallet/multisig/__fixtures__/createSignatureShare.test.ts.fixture index 4d8d1f91b9..2e0ee28694 100644 --- a/ironfish/src/rpc/routes/wallet/multisig/__fixtures__/createSigningShare.test.ts.fixture +++ b/ironfish/src/rpc/routes/wallet/multisig/__fixtures__/createSignatureShare.test.ts.fixture @@ -1,5 +1,5 @@ { - "Route multisig/createSigningShare should fail for an account that does not have multisig keys": [ + "Route wallet/multisig/createSignatureShare should fail for an account that does not have multisig keys": [ { "version": 4, "id": "ef8a8d12-b4c2-48ba-952c-8cf7b398bd82", diff --git a/ironfish/src/rpc/routes/wallet/multisig/aggregateSigningShares.ts b/ironfish/src/rpc/routes/wallet/multisig/aggregateSignatureShares.ts similarity index 70% rename from ironfish/src/rpc/routes/wallet/multisig/aggregateSigningShares.ts rename to ironfish/src/rpc/routes/wallet/multisig/aggregateSignatureShares.ts index 9f9de4429e..8c190e2220 100644 --- a/ironfish/src/rpc/routes/wallet/multisig/aggregateSigningShares.ts +++ b/ironfish/src/rpc/routes/wallet/multisig/aggregateSignatureShares.ts @@ -9,37 +9,37 @@ import { routes } from '../../router' import { AssertHasRpcContext } from '../../rpcContext' import { getAccount } from '../utils' -export type AggregateSigningSharesRequest = { +export type AggregateSignatureSharesRequest = { account: string unsignedTransaction: string signingPackage: string - signingShares: Array + signatureShares: Array } -export type AggregateSigningSharesResponse = { +export type AggregateSignatureSharesResponse = { transaction: string } -export const AggregateSigningSharesRequestSchema: yup.ObjectSchema = +export const AggregateSignatureSharesRequestSchema: yup.ObjectSchema = yup .object({ account: yup.string().defined(), unsignedTransaction: yup.string().defined(), signingPackage: yup.string().defined(), - signingShares: yup.array(yup.string().defined()).defined(), + signatureShares: yup.array(yup.string().defined()).defined(), }) .defined() -export const AggregateSigningSharesResponseSchema: yup.ObjectSchema = +export const AggregateSignatureSharesResponseSchema: yup.ObjectSchema = yup .object({ transaction: yup.string().defined(), }) .defined() -routes.register( - `${ApiNamespace.wallet}/multisig/aggregateSigningShares`, - AggregateSigningSharesRequestSchema, +routes.register( + `${ApiNamespace.wallet}/multisig/aggregateSignatureShares`, + AggregateSignatureSharesRequestSchema, (request, node): void => { AssertHasRpcContext(request, node, 'wallet') const account = getAccount(node.wallet, request.data.account) @@ -52,7 +52,7 @@ routes.register { +describe('Route wallt/multisig/createSignatureShare', () => { const routeTest = createRouteTest() it('should fail for an account that does not exist', async () => { await expect( - routeTest.client.wallet.multisig.createSigningShare({ + routeTest.client.wallet.multisig.createSignatureShare({ account: 'non-existent', signingPackage: 'fake', unsignedTransaction: 'deadbeef', @@ -40,7 +40,7 @@ describe('Route multisig/createSigningShare', () => { const account = await routeTest.wallet.importAccount(accountImport) await expect( - routeTest.client.wallet.multisig.createSigningShare({ + routeTest.client.wallet.multisig.createSignatureShare({ account: account.name, signingPackage: 'fake', unsignedTransaction: 'deadbeef', diff --git a/ironfish/src/rpc/routes/wallet/multisig/createSigningShare.ts b/ironfish/src/rpc/routes/wallet/multisig/createSignatureShare.ts similarity index 56% rename from ironfish/src/rpc/routes/wallet/multisig/createSigningShare.ts rename to ironfish/src/rpc/routes/wallet/multisig/createSignatureShare.ts index 63d934de2f..cbc5ec4900 100644 --- a/ironfish/src/rpc/routes/wallet/multisig/createSigningShare.ts +++ b/ironfish/src/rpc/routes/wallet/multisig/createSignatureShare.ts @@ -1,7 +1,7 @@ /* 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 { createSigningShare, UnsignedTransaction } from '@ironfish/rust-nodejs' +import { createSignatureShare, UnsignedTransaction } from '@ironfish/rust-nodejs' import * as yup from 'yup' import { AssertMultiSigSigner } from '../../../../wallet' import { ApiNamespace } from '../../namespaces' @@ -9,36 +9,37 @@ import { routes } from '../../router' import { AssertHasRpcContext } from '../../rpcContext' import { getAccount } from '../utils' -export type CreateSigningShareRequest = { +export type CreateSignatureShareRequest = { account: string signingPackage: string unsignedTransaction: string seed: number // TODO: remove when we have deterministic nonces } -export type CreateSigningShareResponse = { - signingShare: string +export type CreateSignatureShareResponse = { + signatureShare: string } -export const CreateSigningShareRequestSchema: yup.ObjectSchema = yup - .object({ - account: yup.string().defined(), - signingPackage: yup.string().defined(), - unsignedTransaction: yup.string().defined(), - seed: yup.number().defined(), - }) - .defined() +export const CreateSignatureShareRequestSchema: yup.ObjectSchema = + yup + .object({ + account: yup.string().defined(), + signingPackage: yup.string().defined(), + unsignedTransaction: yup.string().defined(), + seed: yup.number().defined(), + }) + .defined() -export const CreateSigningShareResponseSchema: yup.ObjectSchema = +export const CreateSignatureShareResponseSchema: yup.ObjectSchema = yup .object({ - signingShare: yup.string().defined(), + signatureShare: yup.string().defined(), }) .defined() -routes.register( - `${ApiNamespace.wallet}/multisig/createSigningShare`, - CreateSigningShareRequestSchema, +routes.register( + `${ApiNamespace.wallet}/multisig/createSignatureShare`, + CreateSignatureShareRequestSchema, (request, node): void => { AssertHasRpcContext(request, node, 'wallet') @@ -48,7 +49,7 @@ routes.register { for (const participant of participants) { AssertMultiSigSigner(participant) signatureShares.push( - createSigningShare( + createSignatureShare( signingPackage, participant.multiSigKeys.identifier, participant.multiSigKeys.keyPackage,