diff --git a/ironfish-cli/src/commands/wallet/multisig/account/create.ts b/ironfish-cli/src/commands/wallet/multisig/account/create.ts index 6ae132188a..1ad8772ce1 100644 --- a/ironfish-cli/src/commands/wallet/multisig/account/create.ts +++ b/ironfish-cli/src/commands/wallet/multisig/account/create.ts @@ -7,7 +7,7 @@ import { IronfishCommand } from '../../../../command' import { RemoteFlags } from '../../../../flags' export class MultisigCreate extends IronfishCommand { - static description = `Create a set of multisig accounts from identifiers` + static description = `Create a set of multisig accounts from identities` static hidden = true static flags = { @@ -16,9 +16,9 @@ export class MultisigCreate extends IronfishCommand { char: 'n', description: 'Name to use for the coordinator', }), - identifier: Flags.string({ + identity: Flags.string({ char: 'i', - description: 'Identifier of a participant', + description: 'Identity of a participant', multiple: true, }), minSigners: Flags.integer({ @@ -35,18 +35,18 @@ export class MultisigCreate extends IronfishCommand { async start(): Promise { const { flags } = await this.parse(MultisigCreate) - let identifiers = flags.identifier - if (!identifiers || identifiers.length < 2) { - const input = await CliUx.ux.prompt('Enter the identifiers separated by commas', { + let identities = flags.identity + if (!identities || identities.length < 2) { + const input = await CliUx.ux.prompt('Enter the identities separated by commas', { required: true, }) - identifiers = input.split(',') + identities = input.split(',') - if (identifiers.length < 2) { - this.error('Minimum number of identifiers must be at least 2') + if (identities.length < 2) { + this.error('Minimum number of identities must be at least 2') } } - identifiers = identifiers.map((i) => i.trim()) + identities = identities.map((i) => i.trim()) let minSigners = flags.minSigners if (!minSigners) { @@ -67,7 +67,7 @@ export class MultisigCreate extends IronfishCommand { const response = await client.wallet.multisig.createTrustedDealerKeyPackage({ minSigners, - participants: identifiers.map((identifier) => ({ identifier })), + participants: identities.map((identity) => ({ identity })), }) const chainResponse = await client.chain.getChainInfo() @@ -110,7 +110,7 @@ export class MultisigCreate extends IronfishCommand { for (const [i, keyPackage] of response.content.keyPackages.entries()) { this.log('\n') this.log(`Account ${i + 1}`) - this.log(`Identifier ${keyPackage.identifier}`) + this.log(`Identifier ${keyPackage.identity}`) this.log('----------------') const accountStr = encoder.encode({ name: `${name}-0`, @@ -123,7 +123,7 @@ export class MultisigCreate extends IronfishCommand { publicAddress: response.content.publicAddress, proofAuthorizingKey: response.content.proofAuthorizingKey, multisigKeys: { - identifier: keyPackage.identifier, + identity: keyPackage.identity, keyPackage: keyPackage.keyPackage, publicKeyPackage: response.content.publicKeyPackage, }, diff --git a/ironfish-cli/src/commands/wallet/multisig/identity/create.ts b/ironfish-cli/src/commands/wallet/multisig/identity/create.ts index ba7db9fdb5..4bad9ff0b5 100644 --- a/ironfish-cli/src/commands/wallet/multisig/identity/create.ts +++ b/ironfish-cli/src/commands/wallet/multisig/identity/create.ts @@ -15,12 +15,5 @@ export class MultisigIdentityCreate extends IronfishCommand { const identity = secret.toIdentity() this.log('Identity:') this.log(identity.serialize().toString('hex')) - - this.log() - - // TODO: remove when other multisig CLI commands use identity as inputs - const identifier = identity.toFrostIdentifier() - this.log('Identifier:') - this.log(identifier) } } diff --git a/ironfish-rust-nodejs/index.d.ts b/ironfish-rust-nodejs/index.d.ts index ba6d8d7211..9257305e78 100644 --- a/ironfish-rust-nodejs/index.d.ts +++ b/ironfish-rust-nodejs/index.d.ts @@ -4,8 +4,8 @@ /* auto-generated by NAPI-RS */ export function createSigningCommitment(keyPackage: 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 createSignatureShare(signingPackage: string, identity: string, keyPackage: string, publicKeyRandomness: string, seed: number): string +export function splitSecret(coordinatorSaplingKey: string, minSigners: number, identities: Array): TrustedDealerKeyPackages export function contribute(inputPath: string, outputPath: string, seed?: string | undefined | null): Promise export function verifyTransform(paramsPath: string, newParamsPath: string): Promise export const KEY_LENGTH: number @@ -52,8 +52,8 @@ export const TRANSACTION_EXPIRATION_LENGTH: number export const TRANSACTION_FEE_LENGTH: number export const LATEST_TRANSACTION_VERSION: number export function verifyTransactions(serializedTransactions: Array): boolean -export interface IdentiferKeyPackage { - identifier: string +export interface IdentityKeyPackage { + identity: string keyPackage: string } export interface TrustedDealerKeyPackages { @@ -63,7 +63,7 @@ export interface TrustedDealerKeyPackages { incomingViewKey: string outgoingViewKey: string publicAddress: string - keyPackages: Array + keyPackages: Array publicKeyPackage: string } export const enum LanguageCode { @@ -104,7 +104,6 @@ export class ParticipantSecret { export class ParticipantIdentity { constructor(jsBytes: Buffer) serialize(): Buffer - toFrostIdentifier(): string } export class BoxKeyPair { constructor() diff --git a/ironfish-rust-nodejs/src/frost.rs b/ironfish-rust-nodejs/src/frost.rs index aa9c97f627..c8974f939b 100644 --- a/ironfish-rust-nodejs/src/frost.rs +++ b/ironfish-rust-nodejs/src/frost.rs @@ -3,11 +3,11 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::{ - structs::{IdentiferKeyPackage, TrustedDealerKeyPackages}, + structs::{IdentityKeyPackage, TrustedDealerKeyPackages}, to_napi_err, }; use ironfish::{ - frost::{keys::KeyPackage, round2::Randomizer, Identifier, SigningPackage}, + frost::{keys::KeyPackage, round2::Randomizer, SigningPackage}, frost_utils::{ signature_share::create_signature_share as create_signature_share_rust, signing_commitment::{ @@ -42,13 +42,14 @@ pub fn create_signing_commitment(key_package: String, seed: u32) -> Result Result { - let identifier = Identifier::deserialize(&hex_to_bytes(&identifier).map_err(to_napi_err)?) - .map_err(to_napi_err)?; + let identity = + Identity::deserialize_from(&hex_to_vec_bytes(&identity).map_err(to_napi_err)?[..]) + .map_err(to_napi_err)?; let key_package = KeyPackage::deserialize(&hex_to_vec_bytes(&key_package).map_err(to_napi_err)?[..]) .map_err(to_napi_err)?; @@ -61,7 +62,7 @@ pub fn create_signature_share( let signature_share = create_signature_share_rust( signing_package, - identifier, + &identity, key_package, randomizer, seed as u64, @@ -135,39 +136,33 @@ impl ParticipantIdentity { Ok(Buffer::from(vec)) } - - #[napi] - pub fn to_frost_identifier(&self) -> String { - let identifier: Identifier = self.identity.to_frost_identifier(); - - bytes_to_hex(&identifier.serialize()) - } } #[napi] pub fn split_secret( coordinator_sapling_key: String, min_signers: u16, - identifiers: Vec, + identities: Vec, ) -> Result { let coordinator_key = SaplingKey::new(hex_to_bytes(&coordinator_sapling_key).map_err(to_napi_err)?) .map_err(to_napi_err)?; - let mut converted = Vec::new(); + let mut deserialized_identities = Vec::new(); - for identifier in &identifiers { - let bytes = hex_to_bytes(identifier).map_err(to_napi_err)?; - let deserialized = Identifier::deserialize(&bytes).map_err(to_napi_err)?; - converted.push(deserialized); + for identity in &identities { + let bytes = hex_to_vec_bytes(identity).map_err(to_napi_err)?; + let frost_id = Identity::deserialize_from(&bytes[..]).map_err(to_napi_err)?; + deserialized_identities.push(frost_id); } - let t = split_spender_key(&coordinator_key, min_signers, converted).map_err(to_napi_err)?; + let t = split_spender_key(&coordinator_key, min_signers, deserialized_identities) + .map_err(to_napi_err)?; let mut key_packages_serialized = Vec::new(); for (k, v) in t.key_packages.iter() { - key_packages_serialized.push(IdentiferKeyPackage { - identifier: bytes_to_hex(&k.serialize()), + key_packages_serialized.push(IdentityKeyPackage { + identity: bytes_to_hex(&k.serialize()), key_package: bytes_to_hex(&v.serialize().map_err(to_napi_err)?), }); } diff --git a/ironfish-rust-nodejs/src/structs/key_packages.rs b/ironfish-rust-nodejs/src/structs/key_packages.rs index 7237149d70..d4c6070c22 100644 --- a/ironfish-rust-nodejs/src/structs/key_packages.rs +++ b/ironfish-rust-nodejs/src/structs/key_packages.rs @@ -5,8 +5,8 @@ use napi_derive::napi; #[napi(object)] -pub struct IdentiferKeyPackage { - pub identifier: String, +pub struct IdentityKeyPackage { + pub identity: String, pub key_package: String, } #[napi(object)] @@ -18,6 +18,6 @@ pub struct TrustedDealerKeyPackages { pub incoming_view_key: String, pub outgoing_view_key: String, pub public_address: String, - pub key_packages: Vec, + pub key_packages: Vec, pub public_key_package: String, } diff --git a/ironfish-rust/src/frost_utils/signature_share.rs b/ironfish-rust/src/frost_utils/signature_share.rs index 3dc1d79ba3..d20f4dc734 100644 --- a/ironfish-rust/src/frost_utils/signature_share.rs +++ b/ironfish-rust/src/frost_utils/signature_share.rs @@ -9,6 +9,7 @@ use ironfish_frost::frost::{ round2::{Randomizer, SignatureShare as FrostSignatureShare}, Identifier, SigningPackage, }; +use ironfish_frost::participant::Identity; use rand::{rngs::StdRng, SeedableRng}; use crate::errors::{IronfishError, IronfishErrorKind}; @@ -50,7 +51,7 @@ impl SignatureShare { // Wrapper around frost::round2::sign that provides a seedable rng from u64 pub fn create_signature_share( signing_package: SigningPackage, - identifier: Identifier, + identity: &Identity, key_package: KeyPackage, randomizer: Randomizer, seed: u64, @@ -60,6 +61,7 @@ pub fn create_signature_share( let signature_share = frost::round2::sign(&signing_package, &signer_nonces, &key_package, randomizer) .map_err(|_| IronfishError::new(IronfishErrorKind::RoundTwoSigningFailure))?; + let identifier = identity.to_frost_identifier(); Ok(SignatureShare { identifier, signature_share, diff --git a/ironfish-rust/src/frost_utils/signing_commitment.rs b/ironfish-rust/src/frost_utils/signing_commitment.rs index 1c5a17d3fc..4d201af328 100644 --- a/ironfish-rust/src/frost_utils/signing_commitment.rs +++ b/ironfish-rust/src/frost_utils/signing_commitment.rs @@ -73,7 +73,7 @@ pub fn create_signing_commitment( #[cfg(test)] mod test { use crate::frost_utils::split_secret::{split_secret, SecretShareConfig}; - use crate::test_util::create_identifiers; + use crate::test_util::create_multisig_identities; use ff::Field; use jubjub::Fr; use rand::thread_rng; @@ -83,11 +83,11 @@ mod test { let seed = 100; let key = Fr::random(&mut rand::thread_rng()); - let identifiers = create_identifiers(10); + let identities = create_multisig_identities(10); let key_packages = split_secret( &SecretShareConfig { - identifiers, + identities, min_signers: 2, secret: key.to_bytes().to_vec(), }, diff --git a/ironfish-rust/src/frost_utils/split_secret.rs b/ironfish-rust/src/frost_utils/split_secret.rs index 05ea804c5c..4dcc142aa1 100644 --- a/ironfish-rust/src/frost_utils/split_secret.rs +++ b/ironfish-rust/src/frost_utils/split_secret.rs @@ -5,8 +5,9 @@ use ironfish_frost::frost::{ frost::keys::split, keys::{IdentifierList, KeyPackage, PublicKeyPackage}, - Identifier, SigningKey, + SigningKey, }; +use ironfish_frost::participant::Identity; use rand::{CryptoRng, RngCore}; use std::collections::HashMap; @@ -14,14 +15,14 @@ use crate::errors::{IronfishError, IronfishErrorKind}; pub struct SecretShareConfig { pub min_signers: u16, - pub identifiers: Vec, + pub identities: Vec, pub secret: Vec, } pub(crate) fn split_secret( config: &SecretShareConfig, mut rng: R, -) -> Result<(HashMap, PublicKeyPackage), IronfishError> { +) -> Result<(HashMap, PublicKeyPackage), IronfishError> { let secret_bytes: [u8; 32] = config .secret .clone() @@ -30,25 +31,35 @@ pub(crate) fn split_secret( let secret_key = SigningKey::deserialize(secret_bytes)?; - let identifier_list = IdentifierList::Custom(&config.identifiers); + let mut frost_id_map = config + .identities + .iter() + .cloned() + .map(|identity| (identity.to_frost_identifier(), identity)) + .collect::>(); + let frost_ids = frost_id_map.keys().cloned().collect::>(); + let identifier_list = IdentifierList::Custom(&frost_ids[..]); let (shares, pubkeys) = split( &secret_key, - config.identifiers.len() as u16, + config + .identities + .len() + .try_into() + .expect("too many identities"), config.min_signers, identifier_list, &mut rng, )?; - for (_k, v) in shares.clone() { - KeyPackage::try_from(v)?; - } - let mut key_packages: HashMap<_, _> = HashMap::new(); - for (identifier, secret_share) in shares { + for (frost_id, secret_share) in shares { + let identity = frost_id_map + .remove(&frost_id) + .expect("frost returned an identifier that was not passed as an input"); let key_package = KeyPackage::try_from(secret_share.clone())?; - key_packages.insert(identifier, key_package); + key_packages.insert(identity, key_package); } Ok((key_packages, pubkeys)) @@ -57,17 +68,17 @@ pub(crate) fn split_secret( #[cfg(test)] mod test { use super::*; - use crate::{keys::SaplingKey, test_util::create_identifiers}; + use crate::{keys::SaplingKey, test_util::create_multisig_identities}; use ironfish_frost::frost::{frost::keys::reconstruct, JubjubBlake2b512}; #[test] fn test_invalid_secret() { - let identifiers = create_identifiers(10); + let identities = create_multisig_identities(10); let vec = vec![1; 31]; let config = SecretShareConfig { min_signers: 2, - identifiers, + identities, secret: vec, }; @@ -82,8 +93,8 @@ mod test { #[test] fn test_split_secret() { - let identifiers = create_identifiers(10); - let identifiers_length = identifiers.len(); + let identities = create_multisig_identities(10); + let identities_length = identities.len(); let rng = rand::thread_rng(); @@ -91,12 +102,12 @@ mod test { let config = SecretShareConfig { min_signers: 2, - identifiers, + identities, secret: key.to_vec(), }; let (key_packages, _) = split_secret(&config, rng).unwrap(); - assert_eq!(key_packages.len(), identifiers_length); + assert_eq!(key_packages.len(), identities_length); let key_parts: Vec<_> = key_packages.values().cloned().collect(); diff --git a/ironfish-rust/src/frost_utils/split_spender_key.rs b/ironfish-rust/src/frost_utils/split_spender_key.rs index 4c2af8bc8a..1bbeebb208 100644 --- a/ironfish-rust/src/frost_utils/split_spender_key.rs +++ b/ironfish-rust/src/frost_utils/split_spender_key.rs @@ -3,10 +3,8 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use group::GroupEncoding; -use ironfish_frost::frost::{ - keys::{KeyPackage, PublicKeyPackage}, - Identifier, -}; +use ironfish_frost::frost::keys::{KeyPackage, PublicKeyPackage}; +use ironfish_frost::participant::Identity; use ironfish_zkp::constants::PROOF_GENERATION_KEY_GENERATOR; use jubjub::SubgroupPoint; use rand::thread_rng; @@ -28,14 +26,14 @@ pub struct TrustedDealerKeyPackages { pub incoming_view_key: IncomingViewKey, pub outgoing_view_key: OutgoingViewKey, pub public_address: PublicAddress, - pub key_packages: HashMap, + pub key_packages: HashMap, pub public_key_package: PublicKeyPackage, } pub fn split_spender_key( coordinator_sapling_key: &SaplingKey, min_signers: u16, - identifiers: Vec, + identities: Vec, ) -> Result { let secret = coordinator_sapling_key .spend_authorizing_key @@ -44,7 +42,7 @@ pub fn split_spender_key( let secret_config = SecretShareConfig { min_signers, - identifiers, + identities, secret, }; @@ -87,22 +85,22 @@ pub fn split_spender_key( #[cfg(test)] mod test { - use crate::test_util::create_identifiers; + use crate::test_util::create_multisig_identities; use super::*; use ironfish_frost::frost::{frost::keys::reconstruct, JubjubBlake2b512}; #[test] fn test_split_spender_key_success() { - let identifiers = create_identifiers(10); + let identities = create_multisig_identities(10); - let mut cloned_identifiers = identifiers.clone(); - cloned_identifiers.sort(); + let mut cloned_identities = identities.clone(); + cloned_identities.sort_by_key(Identity::serialize); let sapling_key = SaplingKey::generate_key(); let trusted_dealer_key_packages = - split_spender_key(&sapling_key, 5, identifiers).expect("spender key split failed"); + split_spender_key(&sapling_key, 5, identities).expect("spender key split failed"); assert_eq!( trusted_dealer_key_packages.key_packages.len(), @@ -137,14 +135,14 @@ mod test { assert_eq!(scalar.to_bytes(), spend_auth_key); - // assert identifiers and trusted_dealer_key_packages.key_packages.keys() are the same - let mut t_identifiers = trusted_dealer_key_packages + // assert identities and trusted_dealer_key_packages.key_packages.keys() are the same + let mut t_identities = trusted_dealer_key_packages .key_packages .keys() .cloned() .collect::>(); - t_identifiers.sort(); - assert_eq!(t_identifiers, cloned_identifiers); + t_identities.sort_by_key(Identity::serialize); + assert_eq!(t_identities, cloned_identities); } } diff --git a/ironfish-rust/src/test_util.rs b/ironfish-rust/src/test_util.rs index 7b59fb8050..b015c8c7dd 100644 --- a/ironfish-rust/src/test_util.rs +++ b/ironfish-rust/src/test_util.rs @@ -8,7 +8,7 @@ use super::{ MerkleNoteHash, }; use blstrs::Scalar; -use ironfish_frost::{frost::Identifier, participant::Secret}; +use ironfish_frost::{participant::Identity, participant::Secret}; use ironfish_zkp::constants::TREE_DEPTH; use rand::{thread_rng, Rng}; @@ -60,17 +60,10 @@ pub(crate) fn auth_path_to_root_hash( cur } -// Helper function to create a list of random identifiers for multisig participants. -pub fn create_identifiers(num_identifiers: usize) -> Vec { - let mut identifiers = Vec::new(); - - for _ in 0..num_identifiers { - identifiers.push( - Secret::random(thread_rng()) - .to_identity() - .to_frost_identifier(), - ); - } - - identifiers +/// Helper function to create a list of random identifiers for multisig participants. +pub fn create_multisig_identities(num_identifiers: usize) -> Vec { + (0..num_identifiers) + .into_iter() + .map(|_| Secret::random(thread_rng()).to_identity()) + .collect() } diff --git a/ironfish-rust/src/transaction/tests.rs b/ironfish-rust/src/transaction/tests.rs index 53e9f33b57..ac9353f994 100644 --- a/ironfish-rust/src/transaction/tests.rs +++ b/ironfish-rust/src/transaction/tests.rs @@ -2,7 +2,7 @@ * 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/. */ -use std::collections::BTreeMap; +use std::collections::{BTreeMap, HashMap}; #[cfg(test)] use super::internal_batch_verify_transactions; @@ -10,7 +10,7 @@ use super::{ProposedTransaction, Transaction}; use crate::frost_utils::{ signature_share::create_signature_share, signing_commitment::create_signing_commitment, }; -use crate::test_util::create_identifiers; +use crate::test_util::create_multisig_identities; use crate::transaction::tests::split_spender_key::split_spender_key; use crate::{ assets::{asset::Asset, asset_identifier::NATIVE_ASSET}, @@ -706,7 +706,7 @@ fn test_sign_simple() { fn test_aggregate_signature_shares() { let spender_key = SaplingKey::generate_key(); - let identifiers = create_identifiers(10); + let identifiers = create_multisig_identities(10); // key package generation by trusted dealer let key_packages = split_spender_key(&spender_key, 2, identifiers) @@ -779,12 +779,12 @@ fn test_aggregate_signature_shares() { ) .expect("should be able to build unsigned transaction"); - let mut commitments = BTreeMap::new(); + let mut commitments = HashMap::new(); // simulate round 1 for key_package in key_packages.key_packages.iter() { let (_nonce, commitment) = create_signing_commitment(key_package.1, 0); - commitments.insert(*key_package.0, commitment); + commitments.insert(key_package.0, commitment); } // coordinator creates signing package @@ -801,7 +801,7 @@ fn test_aggregate_signature_shares() { for key_package in key_packages.key_packages.iter() { let signature_share = create_signature_share( signing_package.clone(), - *key_package.0, + key_package.0, key_package.1.clone(), randomizer, 0, diff --git a/ironfish-rust/src/transaction/unsigned.rs b/ironfish-rust/src/transaction/unsigned.rs index 93333a1ec1..edfa3a581d 100644 --- a/ironfish-rust/src/transaction/unsigned.rs +++ b/ironfish-rust/src/transaction/unsigned.rs @@ -286,12 +286,20 @@ impl UnsignedTransaction { // Creates frost signing package for use in round two of FROST multisig protocol // only applicable for multisig transactions - pub fn signing_package( + pub fn signing_package( &self, - commitments: BTreeMap, - ) -> Result { + commitments: Iter, + ) -> Result + where + Iter: IntoIterator, + ID: Into, + { // Create the transaction signature hash let data_to_sign = self.transaction_signature_hash()?; + let commitments = commitments + .into_iter() + .map(|(identity, commitments)| (identity.into(), commitments)) + .collect(); Ok(SigningPackage::new(commitments, &data_to_sign)) } diff --git a/ironfish/src/migrations/data/031-add-pak-to-account/new/AccountValue.ts b/ironfish/src/migrations/data/031-add-pak-to-account/new/AccountValue.ts index b5b17a907c..27521c4521 100644 --- a/ironfish/src/migrations/data/031-add-pak-to-account/new/AccountValue.ts +++ b/ironfish/src/migrations/data/031-add-pak-to-account/new/AccountValue.ts @@ -21,7 +21,7 @@ export interface AccountValue { publicAddress: string createdAt: HeadValue | null multisigKeys?: { - identifier: string + identity: string keyPackage: string } proofAuthorizingKey: string | null @@ -53,7 +53,7 @@ export class AccountValueEncoding implements IDatabaseEncoding { } if (value.multisigKeys) { - bw.writeVarBytes(Buffer.from(value.multisigKeys.identifier, 'hex')) + bw.writeVarBytes(Buffer.from(value.multisigKeys.identity, 'hex')) bw.writeVarBytes(Buffer.from(value.multisigKeys.keyPackage, 'hex')) } @@ -89,7 +89,7 @@ export class AccountValueEncoding implements IDatabaseEncoding { let multisigKeys = undefined if (hasMultisigKeys) { multisigKeys = { - identifier: reader.readVarBytes().toString('hex'), + identity: reader.readVarBytes().toString('hex'), keyPackage: reader.readVarBytes().toString('hex'), } } @@ -131,7 +131,7 @@ export class AccountValueEncoding implements IDatabaseEncoding { size += encoding.nonNullSize } if (value.multisigKeys) { - size += bufio.sizeVarString(value.multisigKeys.identifier, 'hex') + size += bufio.sizeVarString(value.multisigKeys.identity, 'hex') size += bufio.sizeVarString(value.multisigKeys.keyPackage, 'hex') } if (value.proofAuthorizingKey) { diff --git a/ironfish/src/rpc/routes/wallet/exportAccount.test.ts b/ironfish/src/rpc/routes/wallet/exportAccount.test.ts index 446b8e780f..2509fd6225 100644 --- a/ironfish/src/rpc/routes/wallet/exportAccount.test.ts +++ b/ironfish/src/rpc/routes/wallet/exportAccount.test.ts @@ -158,7 +158,7 @@ describe('Route wallet/exportAccount', () => { createdAt: null, multisigKeys: { publicKeyPackage: 'aaaa', - identifier: 'aaaa', + identity: 'aaaa', keyPackage: 'bbbb', }, proofAuthorizingKey: key.proofAuthorizingKey, diff --git a/ironfish/src/rpc/routes/wallet/importAccount.test.ts b/ironfish/src/rpc/routes/wallet/importAccount.test.ts index 42e2d27e86..ec9b3194ff 100644 --- a/ironfish/src/rpc/routes/wallet/importAccount.test.ts +++ b/ironfish/src/rpc/routes/wallet/importAccount.test.ts @@ -66,7 +66,7 @@ describe('Route wallet/importAccount', () => { createdAt: null, multisigKeys: { publicKeyPackage: 'aaaa', - identifier: 'aaaa', + identity: 'aaaa', keyPackage: 'bbbb', }, }, diff --git a/ironfish/src/rpc/routes/wallet/multisig/createSignatureShare.ts b/ironfish/src/rpc/routes/wallet/multisig/createSignatureShare.ts index cb22783dc0..2d01cc796c 100644 --- a/ironfish/src/rpc/routes/wallet/multisig/createSignatureShare.ts +++ b/ironfish/src/rpc/routes/wallet/multisig/createSignatureShare.ts @@ -51,7 +51,7 @@ routes.register { it('cannot perform signing commitment if the account is a trusted dealer', async () => { const participants = Array.from({ length: 3 }, () => ({ - identifier: ParticipantSecret.random().toIdentity().toFrostIdentifier(), + identity: ParticipantSecret.random().toIdentity().serialize().toString('hex'), })) const request = { minSigners: 2, participants } @@ -73,7 +73,7 @@ describe('Route wallet/multisig/createSigningCommitment', () => { it('should create signing commitment', async () => { const participants = Array.from({ length: 3 }, () => ({ - identifier: ParticipantSecret.random().toIdentity().toFrostIdentifier(), + identity: ParticipantSecret.random().toIdentity().serialize().toString('hex'), })) const request = { minSigners: 2, participants } @@ -95,7 +95,7 @@ describe('Route wallet/multisig/createSigningCommitment', () => { createdAt: null, multisigKeys: { keyPackage: trustedDealerPackage.keyPackages[0].keyPackage, - identifier: trustedDealerPackage.keyPackages[0].identifier, + identity: trustedDealerPackage.keyPackages[0].identity, publicKeyPackage: trustedDealerPackage.publicKeyPackage, }, proofAuthorizingKey: null, diff --git a/ironfish/src/rpc/routes/wallet/multisig/createSigningPackage.test.ts b/ironfish/src/rpc/routes/wallet/multisig/createSigningPackage.test.ts index 1a4d1e2155..075a205020 100644 --- a/ironfish/src/rpc/routes/wallet/multisig/createSigningPackage.test.ts +++ b/ironfish/src/rpc/routes/wallet/multisig/createSigningPackage.test.ts @@ -18,13 +18,15 @@ describe('Route multisig/createSigningPackage', () => { it('should create signing package', async () => { const seed = 420 - const participants = Array.from({ length: 3 }, () => ({ - identifier: ParticipantSecret.random().toIdentity().toFrostIdentifier(), - })) + const participants = Array.from({ length: 3 }, () => + ParticipantSecret.random().toIdentity(), + ) const request = { minSigners: 2, - participants, + participants: participants.map((identity) => ({ + identity: identity.serialize().toString('hex'), + })), } const trustedDealerPackage = ( @@ -44,7 +46,7 @@ describe('Route multisig/createSigningPackage', () => { createdAt: null, multisigKeys: { keyPackage: trustedDealerPackage.keyPackages[0].keyPackage, - identifier: trustedDealerPackage.keyPackages[0].identifier, + identity: trustedDealerPackage.keyPackages[0].identity, publicKeyPackage: trustedDealerPackage.publicKeyPackage, }, proofAuthorizingKey: null, diff --git a/ironfish/src/rpc/routes/wallet/multisig/createTrustedDealerKeyPackage.test.ts b/ironfish/src/rpc/routes/wallet/multisig/createTrustedDealerKeyPackage.test.ts index 67b81b9af3..3ec492b913 100644 --- a/ironfish/src/rpc/routes/wallet/multisig/createTrustedDealerKeyPackage.test.ts +++ b/ironfish/src/rpc/routes/wallet/multisig/createTrustedDealerKeyPackage.test.ts @@ -9,7 +9,7 @@ describe('Route multisig/createTrustedDealerKeyPackage', () => { it('should create trusted dealer key package', async () => { const participants = Array.from({ length: 3 }, () => ({ - identifier: ParticipantSecret.random().toIdentity().toFrostIdentifier(), + identity: ParticipantSecret.random().toIdentity().serialize().toString('hex'), })) const request = { minSigners: 2, participants } const response = await routeTest.client @@ -20,15 +20,15 @@ describe('Route multisig/createTrustedDealerKeyPackage', () => { incomingViewKey: expect.any(String), keyPackages: expect.arrayContaining([ { - identifier: participants[0].identifier, + identity: participants[0].identity, keyPackage: expect.any(String), }, { - identifier: participants[1].identifier, + identity: participants[1].identity, keyPackage: expect.any(String), }, { - identifier: participants[2].identifier, + identity: participants[2].identity, keyPackage: expect.any(String), }, ]), diff --git a/ironfish/src/rpc/routes/wallet/multisig/createTrustedDealerKeyPackage.ts b/ironfish/src/rpc/routes/wallet/multisig/createTrustedDealerKeyPackage.ts index cf1e0192c2..aa5564eebf 100644 --- a/ironfish/src/rpc/routes/wallet/multisig/createTrustedDealerKeyPackage.ts +++ b/ironfish/src/rpc/routes/wallet/multisig/createTrustedDealerKeyPackage.ts @@ -9,7 +9,7 @@ import { routes } from '../../router' export type CreateTrustedDealerKeyPackageRequest = { minSigners: number participants: Array<{ - identifier: string + identity: string }> } export type CreateTrustedDealerKeyPackageResponse = { @@ -19,7 +19,7 @@ export type CreateTrustedDealerKeyPackageResponse = { incomingViewKey: string outgoingViewKey: string publicAddress: string - keyPackages: Array<{ identifier: string; keyPackage: string }> + keyPackages: Array<{ identity: string; keyPackage: string }> publicKeyPackage: string } export const CreateTrustedDealerKeyPackageRequestSchema: yup.ObjectSchema = @@ -31,7 +31,7 @@ export const CreateTrustedDealerKeyPackageRequestSchema: yup.ObjectSchema { const key = generateKey() const { minSigners, participants } = request.data - const identifiers = participants.map((p) => p.identifier) - const trustedDealerPackage = splitSecret(key.spendingKey, minSigners, identifiers) + const identities = participants.map((p) => p.identity) + const trustedDealerPackage = splitSecret(key.spendingKey, minSigners, identities) request.end(trustedDealerPackage) }, diff --git a/ironfish/src/rpc/routes/wallet/multisig/integration.test.slow.ts b/ironfish/src/rpc/routes/wallet/multisig/integration.test.slow.ts index 665aa95f09..a9bd672e24 100644 --- a/ironfish/src/rpc/routes/wallet/multisig/integration.test.slow.ts +++ b/ironfish/src/rpc/routes/wallet/multisig/integration.test.slow.ts @@ -15,7 +15,7 @@ describe('multisig RPC integration', () => { // create participants const participants = Array.from({ length: 3 }, () => ({ - identifier: ParticipantSecret.random().toIdentity().toFrostIdentifier(), + identity: ParticipantSecret.random().toIdentity().serialize().toString('hex'), })) // create trusted dealer key package @@ -42,7 +42,7 @@ describe('multisig RPC integration', () => { createdAt: null, multisigKeys: { keyPackage: trustedDealerPackage.keyPackages[i].keyPackage, - identifier: trustedDealerPackage.keyPackages[i].identifier, + identity: trustedDealerPackage.keyPackages[i].identity, publicKeyPackage: trustedDealerPackage.publicKeyPackage, }, proofAuthorizingKey: null, diff --git a/ironfish/src/rpc/routes/wallet/types.ts b/ironfish/src/rpc/routes/wallet/types.ts index b025382947..8063bb1ded 100644 --- a/ironfish/src/rpc/routes/wallet/types.ts +++ b/ironfish/src/rpc/routes/wallet/types.ts @@ -134,7 +134,7 @@ export const RpcWalletTransactionSchema: yup.ObjectSchema .defined() export type RpcMultisigKeys = { - identifier?: string + identity?: string keyPackage?: string publicKeyPackage: string } @@ -170,7 +170,7 @@ export const RpcAccountImportSchema: yup.ObjectSchema = yup .defined(), multisigKeys: yup .object({ - identifier: yup.string().optional(), + identity: yup.string().optional(), keyPackage: yup.string().optional(), publicKeyPackage: yup.string().defined(), }) diff --git a/ironfish/src/rpc/routes/wallet/utils.ts b/ironfish/src/rpc/routes/wallet/utils.ts index f24773772b..e185ebf234 100644 --- a/ironfish/src/rpc/routes/wallet/utils.ts +++ b/ironfish/src/rpc/routes/wallet/utils.ts @@ -119,7 +119,7 @@ export function deserializeRpcAccountMultisigKeys( if (isSignerMultisig(rpcMultisigKeys)) { return { publicKeyPackage: rpcMultisigKeys.publicKeyPackage, - identifier: rpcMultisigKeys.identifier, + identity: rpcMultisigKeys.identity, keyPackage: rpcMultisigKeys.keyPackage, } } diff --git a/ironfish/src/wallet/account/encoder/base64.json.test.ts b/ironfish/src/wallet/account/encoder/base64.json.test.ts index b27c6b6514..4655fe95a8 100644 --- a/ironfish/src/wallet/account/encoder/base64.json.test.ts +++ b/ironfish/src/wallet/account/encoder/base64.json.test.ts @@ -111,7 +111,7 @@ describe('Base64JsonEncoder', () => { createdAt: null, multisigKeys: { publicKeyPackage: 'cccc', - identifier: 'aaaa', + identity: 'aaaa', keyPackage: 'bbbb', }, proofAuthorizingKey: null, diff --git a/ironfish/src/wallet/account/encoder/bech32.test.ts b/ironfish/src/wallet/account/encoder/bech32.test.ts index d43babe00c..96e4956eae 100644 --- a/ironfish/src/wallet/account/encoder/bech32.test.ts +++ b/ironfish/src/wallet/account/encoder/bech32.test.ts @@ -112,7 +112,7 @@ describe('Bech32AccountEncoder', () => { createdAt: null, multisigKeys: { publicKeyPackage: 'cccc', - identifier: 'aaaa', + identity: 'aaaa', keyPackage: 'bbbb', }, proofAuthorizingKey: null, diff --git a/ironfish/src/wallet/account/encoder/json.test.ts b/ironfish/src/wallet/account/encoder/json.test.ts index 2471b34918..c12b5ac0ce 100644 --- a/ironfish/src/wallet/account/encoder/json.test.ts +++ b/ironfish/src/wallet/account/encoder/json.test.ts @@ -74,7 +74,7 @@ describe('JsonEncoder', () => { createdAt: null, multisigKeys: { publicKeyPackage: 'cccc', - identifier: 'aaaa', + identity: 'aaaa', keyPackage: 'bbbb', }, proofAuthorizingKey: key.proofAuthorizingKey, diff --git a/ironfish/src/wallet/account/encoder/multiSigKeys.test.ts b/ironfish/src/wallet/account/encoder/multiSigKeys.test.ts index 0828402e15..42c4099bb8 100644 --- a/ironfish/src/wallet/account/encoder/multiSigKeys.test.ts +++ b/ironfish/src/wallet/account/encoder/multiSigKeys.test.ts @@ -11,7 +11,7 @@ describe('multisigKeys encoder', () => { const value: MultisigSigner = { publicKeyPackage: 'aaaaaa', - identifier: 'aaaaaa', + identity: 'aaaaaa', keyPackage: 'bbbb', } const buffer = encoder.serialize(value) diff --git a/ironfish/src/wallet/account/encoder/multisigKeys.ts b/ironfish/src/wallet/account/encoder/multisigKeys.ts index 2fdd50ef7a..e807da9dad 100644 --- a/ironfish/src/wallet/account/encoder/multisigKeys.ts +++ b/ironfish/src/wallet/account/encoder/multisigKeys.ts @@ -16,7 +16,7 @@ export class MultisigKeysEncoding implements IDatabaseEncoding { bw.writeVarBytes(Buffer.from(value.publicKeyPackage, 'hex')) if (isSignerMultisig(value)) { - bw.writeVarBytes(Buffer.from(value.identifier, 'hex')) + bw.writeVarBytes(Buffer.from(value.identity, 'hex')) bw.writeVarBytes(Buffer.from(value.keyPackage, 'hex')) } @@ -31,11 +31,11 @@ export class MultisigKeysEncoding implements IDatabaseEncoding { const publicKeyPackage = reader.readVarBytes().toString('hex') if (isSigner) { - const identifier = reader.readVarBytes().toString('hex') + const identity = reader.readVarBytes().toString('hex') const keyPackage = reader.readVarBytes().toString('hex') return { publicKeyPackage, - identifier, + identity, keyPackage, } } @@ -51,7 +51,7 @@ export class MultisigKeysEncoding implements IDatabaseEncoding { size += bufio.sizeVarString(value.publicKeyPackage, 'hex') if (isSignerMultisig(value)) { - size += bufio.sizeVarString(value.identifier, 'hex') + size += bufio.sizeVarString(value.identity, 'hex') size += bufio.sizeVarString(value.keyPackage, 'hex') } @@ -60,7 +60,7 @@ export class MultisigKeysEncoding implements IDatabaseEncoding { } export function isSignerMultisig(multisigKeys: MultisigKeys): multisigKeys is MultisigSigner { - return 'keyPackage' in multisigKeys && 'identifier' in multisigKeys + return 'keyPackage' in multisigKeys && 'identity' in multisigKeys } export function AssertIsSignerMultisig( diff --git a/ironfish/src/wallet/interfaces/multisigKeys.ts b/ironfish/src/wallet/interfaces/multisigKeys.ts index 0928ac034a..489bc1879d 100644 --- a/ironfish/src/wallet/interfaces/multisigKeys.ts +++ b/ironfish/src/wallet/interfaces/multisigKeys.ts @@ -2,7 +2,7 @@ * 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/. */ export interface MultisigSigner { - identifier: string + identity: string keyPackage: string publicKeyPackage: string } diff --git a/ironfish/src/wallet/wallet.test.slow.ts b/ironfish/src/wallet/wallet.test.slow.ts index 61f92aedaa..f212e98f21 100644 --- a/ironfish/src/wallet/wallet.test.slow.ts +++ b/ironfish/src/wallet/wallet.test.slow.ts @@ -1147,25 +1147,23 @@ describe('Wallet', () => { const coordinatorSaplingKey = generateKey() - const identifiers: string[] = [] - - for (let i = 0; i < 3; i++) { - identifiers.push(ParticipantSecret.random().toIdentity().toFrostIdentifier()) - } + const identities = Array.from({ length: 3 }, () => + ParticipantSecret.random().toIdentity().serialize().toString('hex'), + ) // construct 3 separate secrets for the participants - // take the secrets and get identifiers back (get identity first then identifier) + // take the secrets and get identities back (get identity first then identifier) const trustedDealerPackage: TrustedDealerKeyPackages = splitSecret( coordinatorSaplingKey.spendingKey, minSigners, - identifiers, + identities, ) const getMultisigKeys = (index: number) => { return { publicKeyPackage: trustedDealerPackage.publicKeyPackage, - identifier: trustedDealerPackage.keyPackages[index].identifier, + identity: trustedDealerPackage.keyPackages[index].identity, keyPackage: trustedDealerPackage.keyPackages[index].keyPackage, } } @@ -1173,7 +1171,7 @@ describe('Wallet', () => { const participantA = await node.wallet.importAccount({ version: 2, id: uuid(), - name: trustedDealerPackage.keyPackages[0].identifier, + name: trustedDealerPackage.keyPackages[0].identity, spendingKey: null, createdAt: null, multisigKeys: getMultisigKeys(0), @@ -1182,7 +1180,7 @@ describe('Wallet', () => { const participantB = await node.wallet.importAccount({ version: 2, id: uuid(), - name: trustedDealerPackage.keyPackages[1].identifier, + name: trustedDealerPackage.keyPackages[1].identity, spendingKey: null, createdAt: null, multisigKeys: getMultisigKeys(1), @@ -1191,7 +1189,7 @@ describe('Wallet', () => { const participantC = await node.wallet.importAccount({ version: 2, id: uuid(), - name: trustedDealerPackage.keyPackages[2].identifier, + name: trustedDealerPackage.keyPackages[2].identity, spendingKey: null, createdAt: null, multisigKeys: getMultisigKeys(2), @@ -1290,7 +1288,7 @@ describe('Wallet', () => { signatureShares.push( createSignatureShare( signingPackage, - participant.multisigKeys.identifier, + participant.multisigKeys.identity, participant.multisigKeys.keyPackage, publicKeyRandomness, seed, diff --git a/ironfish/src/wallet/walletdb/accountValue.test.ts b/ironfish/src/wallet/walletdb/accountValue.test.ts index e436810836..e60441e074 100644 --- a/ironfish/src/wallet/walletdb/accountValue.test.ts +++ b/ironfish/src/wallet/walletdb/accountValue.test.ts @@ -46,7 +46,7 @@ describe('AccountValueEncoding', () => { createdAt: null, multisigKeys: { publicKeyPackage: 'cccc', - identifier: 'deaf', + identity: 'deaf', keyPackage: 'beef', }, proofAuthorizingKey: key.proofAuthorizingKey,