From ec0fa3a1a4185f11deabb2cffa5c895a50f7569e Mon Sep 17 00:00:00 2001 From: Dmitry Balashov <43530070+0x009922@users.noreply.github.com> Date: Tue, 12 Mar 2024 03:55:54 +0900 Subject: [PATCH] [refactor]: restruct `KeyPair` methods - revert `from_raw_parts` to `new` - rename `into_raw_parts` to `into_parts` - remove `impl From to (K, K)` Signed-off-by: Dmitry Balashov <43530070+0x009922@users.noreply.github.com> --- cli/src/lib.rs | 2 +- cli/src/samples.rs | 2 +- client/benches/torii.rs | 4 +-- client/examples/million_accounts_genesis.rs | 2 +- client/examples/tutorial.rs | 2 +- client/src/config/user.rs | 2 +- client/tests/integration/asset_propagation.rs | 2 +- client/tests/integration/burn_public_keys.rs | 2 +- .../multiple_blocks_created.rs | 2 +- .../extra_functional/unregister_peer.rs | 2 +- client/tests/integration/mod.rs | 2 +- client/tests/integration/roles.rs | 2 +- client/tests/integration/transfer_asset.rs | 2 +- client/tests/integration/tx_chain_id.rs | 4 +-- config/src/parameters/user.rs | 4 +-- core/benches/blocks/common.rs | 5 ++-- core/benches/validation.rs | 4 +-- core/src/smartcontracts/isi/mod.rs | 4 +-- core/src/smartcontracts/wasm.rs | 8 +++--- core/test_network/src/lib.rs | 4 +-- crypto/src/lib.rs | 26 +++++++------------ data_model/src/events/data/filters.rs | 2 +- data_model/src/predicate.rs | 6 ++--- genesis/src/lib.rs | 14 ++++------ tools/kagami/src/genesis.rs | 2 +- 25 files changed, 49 insertions(+), 62 deletions(-) diff --git a/cli/src/lib.rs b/cli/src/lib.rs index 1e79cf52aa7..996fc52a76a 100644 --- a/cli/src/lib.rs +++ b/cli/src/lib.rs @@ -559,7 +559,7 @@ mod tests { use super::*; fn config_factory() -> PartialUserConfig { - let (pubkey, privkey) = KeyPair::random().into(); + let (pubkey, privkey) = KeyPair::random().into_parts(); let mut base = PartialUserConfig::default(); diff --git a/cli/src/samples.rs b/cli/src/samples.rs index f1f360dc791..bf372d8f6c2 100644 --- a/cli/src/samples.rs +++ b/cli/src/samples.rs @@ -65,7 +65,7 @@ pub fn get_user_config( ) -> UserConfig { let chain_id = chain_id.unwrap_or_else(|| ChainId::from("0")); - let (public_key, private_key) = key_pair.unwrap_or_else(KeyPair::random).into(); + let (public_key, private_key) = key_pair.unwrap_or_else(KeyPair::random).into_parts(); iroha_logger::info!(%public_key); let mut config = UserConfig::new(); diff --git a/client/benches/torii.rs b/client/benches/torii.rs index 1410a7a0f31..f58096a6a29 100644 --- a/client/benches/torii.rs +++ b/client/benches/torii.rs @@ -63,7 +63,7 @@ fn query_requests(criterion: &mut Criterion) { let domain_id: DomainId = "domain".parse().expect("Valid"); let create_domain = Register::domain(Domain::new(domain_id.clone())); let account_id = AccountId::new(domain_id.clone(), "account".parse().expect("Valid")); - let (public_key, _) = KeyPair::random().into(); + let (public_key, _) = KeyPair::random().into_parts(); let create_account = Register::account(Account::new(account_id.clone(), public_key)); let asset_definition_id = AssetDefinitionId::new(domain_id, "xor".parse().expect("Valid")); let create_asset = @@ -162,7 +162,7 @@ fn instruction_submits(criterion: &mut Criterion) { let domain_id: DomainId = "domain".parse().expect("Valid"); let create_domain: InstructionBox = Register::domain(Domain::new(domain_id.clone())).into(); let account_id = AccountId::new(domain_id.clone(), "account".parse().expect("Valid")); - let (public_key, _) = KeyPair::random().into(); + let (public_key, _) = KeyPair::random().into_parts(); let create_account = Register::account(Account::new(account_id.clone(), public_key)).into(); let asset_definition_id = AssetDefinitionId::new(domain_id, "xor".parse().expect("Valid")); let client_config = iroha_client::samples::get_client_config( diff --git a/client/examples/million_accounts_genesis.rs b/client/examples/million_accounts_genesis.rs index da009164a8b..26d22df1b25 100644 --- a/client/examples/million_accounts_genesis.rs +++ b/client/examples/million_accounts_genesis.rs @@ -80,7 +80,7 @@ fn create_million_accounts_directly() { let create_domain: InstructionBox = Register::domain(Domain::new(domain_id)).into(); let create_account = Register::account(Account::new( normal_account_id.clone(), - KeyPair::random().into_raw_parts().0, + KeyPair::random().into_parts().0, )) .into(); if test_client diff --git a/client/examples/tutorial.rs b/client/examples/tutorial.rs index 903a0493e35..f4b36283ac6 100644 --- a/client/examples/tutorial.rs +++ b/client/examples/tutorial.rs @@ -117,7 +117,7 @@ fn account_registration_test(config: Config) -> Result<(), Error> { // TODO: consider getting a key from white_rabbit // Generate a new public key for a new account - let (public_key, _) = KeyPair::random().into(); + let (public_key, _) = KeyPair::random().into_parts(); // #region register_account_generate // Generate a new account diff --git a/client/src/config/user.rs b/client/src/config/user.rs index 0ace0225db2..30a684e5bac 100644 --- a/client/src/config/user.rs +++ b/client/src/config/user.rs @@ -93,7 +93,7 @@ impl Root { )) } - let key_pair = KeyPair::from_raw_parts(public_key, private_key) + let key_pair = KeyPair::new(public_key, private_key) .wrap_err("failed to construct a key pair") .map_or_else( |err| { diff --git a/client/tests/integration/asset_propagation.rs b/client/tests/integration/asset_propagation.rs index 7342f36ee7e..48129d2f3e1 100644 --- a/client/tests/integration/asset_propagation.rs +++ b/client/tests/integration/asset_propagation.rs @@ -31,7 +31,7 @@ fn client_add_asset_quantity_to_existing_asset_should_increase_asset_amount_on_a let create_domain: InstructionBox = Register::domain(Domain::new(DomainId::from_str("domain")?)).into(); let account_id = AccountId::from_str("account@domain")?; - let (public_key, _) = KeyPair::random().into(); + let (public_key, _) = KeyPair::random().into_parts(); let create_account = Register::account(Account::new(account_id.clone(), public_key)).into(); let asset_definition_id = AssetDefinitionId::from_str("xor#domain")?; let create_asset = diff --git a/client/tests/integration/burn_public_keys.rs b/client/tests/integration/burn_public_keys.rs index c6afc2f26f7..ca9b38ff348 100644 --- a/client/tests/integration/burn_public_keys.rs +++ b/client/tests/integration/burn_public_keys.rs @@ -62,7 +62,7 @@ fn public_keys_cannot_be_burned_to_nothing() { assert_eq!(keys_count, 1); let mint_keys = (0..KEYS_COUNT - 1).map(|_| { - let (public_key, _) = KeyPair::random().into(); + let (public_key, _) = KeyPair::random().into_parts(); Mint::account_public_key(public_key, charlie_id.clone()) }); diff --git a/client/tests/integration/extra_functional/multiple_blocks_created.rs b/client/tests/integration/extra_functional/multiple_blocks_created.rs index c949bddec2e..ee229fa1dfd 100644 --- a/client/tests/integration/extra_functional/multiple_blocks_created.rs +++ b/client/tests/integration/extra_functional/multiple_blocks_created.rs @@ -30,7 +30,7 @@ fn long_multiple_blocks_created() -> Result<()> { let create_domain: InstructionBox = Register::domain(Domain::new("domain".parse()?)).into(); let account_id: AccountId = "account@domain".parse()?; - let (public_key, _) = KeyPair::random().into(); + let (public_key, _) = KeyPair::random().into_parts(); let create_account = Register::account(Account::new(account_id.clone(), public_key)).into(); let asset_definition_id: AssetDefinitionId = "xor#domain".parse()?; let create_asset = diff --git a/client/tests/integration/extra_functional/unregister_peer.rs b/client/tests/integration/extra_functional/unregister_peer.rs index b7c34e802bf..f653e07890f 100644 --- a/client/tests/integration/extra_functional/unregister_peer.rs +++ b/client/tests/integration/extra_functional/unregister_peer.rs @@ -122,7 +122,7 @@ fn init() -> Result<( .into_set_parameters(); let create_domain = Register::domain(Domain::new("domain".parse()?)); let account_id: AccountId = "account@domain".parse()?; - let (public_key, _) = KeyPair::random().into(); + let (public_key, _) = KeyPair::random().into_parts(); let create_account = Register::account(Account::new(account_id.clone(), public_key)); let asset_definition_id: AssetDefinitionId = "xor#domain".parse()?; let create_asset = diff --git a/client/tests/integration/mod.rs b/client/tests/integration/mod.rs index 3ecbf346ef4..ac94bb4e1c5 100644 --- a/client/tests/integration/mod.rs +++ b/client/tests/integration/mod.rs @@ -26,5 +26,5 @@ mod tx_rollback; mod upgrade; fn new_account_with_random_public_key(account_id: AccountId) -> NewAccount { - Account::new(account_id, KeyPair::random().into_raw_parts().0) + Account::new(account_id, KeyPair::random().into_parts().0) } diff --git a/client/tests/integration/roles.rs b/client/tests/integration/roles.rs index de8ea3bf3a4..fee724009ce 100644 --- a/client/tests/integration/roles.rs +++ b/client/tests/integration/roles.rs @@ -227,7 +227,7 @@ fn grant_revoke_role_permissions() -> Result<()> { let mouse_id = AccountId::from_str("mouse@wonderland")?; // Registering Mouse - let mouse_key_pair = KeyPair::generate(); + let mouse_key_pair = KeyPair::random(); let register_mouse = Register::account(Account::new( mouse_id.clone(), mouse_key_pair.public_key().clone(), diff --git a/client/tests/integration/transfer_asset.rs b/client/tests/integration/transfer_asset.rs index 7adaf6afade..c962aa87f68 100644 --- a/client/tests/integration/transfer_asset.rs +++ b/client/tests/integration/transfer_asset.rs @@ -142,6 +142,6 @@ fn generate_two_ids() -> (AccountId, AccountId) { } fn create_mouse(mouse_id: AccountId) -> Register { - let (mouse_public_key, _) = KeyPair::random().into(); + let (mouse_public_key, _) = KeyPair::random().into_parts(); Register::account(Account::new(mouse_id, mouse_public_key)) } diff --git a/client/tests/integration/tx_chain_id.rs b/client/tests/integration/tx_chain_id.rs index 9bda1ed32b2..ebd0bb26d90 100644 --- a/client/tests/integration/tx_chain_id.rs +++ b/client/tests/integration/tx_chain_id.rs @@ -13,9 +13,9 @@ fn send_tx_with_different_chain_id() { wait_for_genesis_committed(&[test_client.clone()], 0); // Given let sender_account_id = AccountId::from_str("sender@wonderland").unwrap(); - let sender_keypair = KeyPair::generate(); + let sender_keypair = KeyPair::random(); let receiver_account_id = AccountId::from_str("receiver@wonderland").unwrap(); - let receiver_keypair = KeyPair::generate(); + let receiver_keypair = KeyPair::random(); let asset_definition_id = AssetDefinitionId::from_str("test_asset#wonderland").unwrap(); let to_transfer = numeric!(1); diff --git a/config/src/parameters/user.rs b/config/src/parameters/user.rs index 89ff28a6173..d4e523b4732 100644 --- a/config/src/parameters/user.rs +++ b/config/src/parameters/user.rs @@ -138,7 +138,7 @@ impl Root { let mut emitter = Emitter::new(); let key_pair = - KeyPair::from_raw_parts(self.public_key, self.private_key) + KeyPair::new(self.public_key, self.private_key) .wrap_err("failed to construct a key pair from `iroha.public_key` and `iroha.private_key` configuration parameters") .map_or_else(|err| { emitter.emit(err); @@ -318,7 +318,7 @@ impl Genesis { public_key: self.public_key, }), (Some(private_key), Some(file), true) => Ok(actual::Genesis::Full { - key_pair: KeyPair::from_raw_parts(self.public_key, private_key) + key_pair: KeyPair::new(self.public_key, private_key) .map_err(GenesisConfigError::from)?, file, }), diff --git a/core/benches/blocks/common.rs b/core/benches/blocks/common.rs index 81e34ca47ba..ef489686047 100644 --- a/core/benches/blocks/common.rs +++ b/core/benches/blocks/common.rs @@ -74,7 +74,7 @@ pub fn populate_wsv( instructions.push(can_unregister_domain.into()); for j in 0..accounts_per_domain { let account_id = construct_account_id(j, domain_id.clone()); - let account = Account::new(account_id.clone(), KeyPair::random().into_raw_parts().0); + let account = Account::new(account_id.clone(), KeyPair::random().into_parts().0); instructions.push(Register::account(account).into()); let can_unregister_account = Grant::permission( PermissionToken::new( @@ -147,8 +147,7 @@ pub fn restore_every_nth( for j in 0..accounts_per_domain { if j % nth == 0 || i % nth == 0 { let account_id = construct_account_id(j, domain_id.clone()); - let account = - Account::new(account_id.clone(), KeyPair::random().into_raw_parts().0); + let account = Account::new(account_id.clone(), KeyPair::random().into_parts().0); instructions.push(Register::account(account).into()); } } diff --git a/core/benches/validation.rs b/core/benches/validation.rs index e43aba9b267..814e565fce0 100644 --- a/core/benches/validation.rs +++ b/core/benches/validation.rs @@ -28,7 +28,7 @@ fn build_test_transaction(keys: &KeyPair, chain_id: ChainId) -> SignedTransactio let domain_id = DomainId::from_str(domain_name).expect("does not panic"); let create_domain: InstructionBox = Register::domain(Domain::new(domain_id)).into(); let account_name = "account"; - let (public_key, _) = KeyPair::random().into(); + let (public_key, _) = KeyPair::random().into_parts(); let create_account = Register::account(Account::new( AccountId::new( domain_name.parse().expect("Valid"), @@ -59,7 +59,7 @@ fn build_test_transaction(keys: &KeyPair, chain_id: ChainId) -> SignedTransactio fn build_test_and_transient_wsv(keys: KeyPair) -> WorldStateView { let kura = iroha_core::kura::Kura::blank_kura_for_testing(); let query_handle = LiveQueryStore::test().start(); - let (public_key, _) = keys.into(); + let (public_key, _) = keys.into_parts(); let mut wsv = WorldStateView::new( { diff --git a/core/src/smartcontracts/isi/mod.rs b/core/src/smartcontracts/isi/mod.rs index ac12efa5fba..eea1e9d3d9d 100644 --- a/core/src/smartcontracts/isi/mod.rs +++ b/core/src/smartcontracts/isi/mod.rs @@ -216,7 +216,7 @@ mod tests { let mut wsv = WorldStateView::new(world, kura.clone(), query_handle); let genesis_account_id = AccountId::from_str("genesis@genesis")?; let account_id = AccountId::from_str("alice@wonderland")?; - let (public_key, _) = KeyPair::random().into(); + let (public_key, _) = KeyPair::random().into_parts(); let asset_definition_id = AssetDefinitionId::from_str("rose#wonderland")?; Register::domain(Domain::new(DomainId::from_str("wonderland")?)) .execute(&genesis_account_id, &mut wsv)?; @@ -366,7 +366,7 @@ mod tests { let trigger_id = TriggerId::from_str("test_trigger_id")?; // register fake account - let (public_key, _) = KeyPair::random().into(); + let (public_key, _) = KeyPair::random().into_parts(); let register_account = Register::account(Account::new(fake_account_id.clone(), public_key)); register_account.execute(&account_id, &mut wsv)?; diff --git a/core/src/smartcontracts/wasm.rs b/core/src/smartcontracts/wasm.rs index c5c2345c33d..959c57e31ba 100644 --- a/core/src/smartcontracts/wasm.rs +++ b/core/src/smartcontracts/wasm.rs @@ -1651,7 +1651,7 @@ mod tests { fn world_with_test_account(authority: &AccountId) -> World { let domain_id = authority.domain_id.clone(); - let (public_key, _) = KeyPair::random().into(); + let (public_key, _) = KeyPair::random().into_parts(); let account = Account::new(authority.clone(), public_key).build(authority); let mut domain = Domain::new(domain_id).build(authority); assert!(domain.add_account(account).is_none()); @@ -1714,7 +1714,7 @@ mod tests { let new_authority = AccountId::from_str("mad_hatter@wonderland").expect("Valid"); let register_isi = Register::account(Account::new( new_authority, - KeyPair::random().into_raw_parts().0, + KeyPair::random().into_parts().0, )); encode_hex(InstructionBox::from(register_isi)) }; @@ -1805,7 +1805,7 @@ mod tests { let new_authority = AccountId::from_str("mad_hatter@wonderland").expect("Valid"); let register_isi = Register::account(Account::new( new_authority, - KeyPair::random().into_raw_parts().0, + KeyPair::random().into_parts().0, )); encode_hex(InstructionBox::from(register_isi)) }; @@ -1857,7 +1857,7 @@ mod tests { let new_authority = AccountId::from_str("mad_hatter@wonderland").expect("Valid"); let register_isi = Register::account(Account::new( new_authority, - KeyPair::random().into_raw_parts().0, + KeyPair::random().into_parts().0, )); encode_hex(InstructionBox::from(register_isi)) }; diff --git a/core/test_network/src/lib.rs b/core/test_network/src/lib.rs index d68056fc190..a614b6bd4eb 100644 --- a/core/test_network/src/lib.rs +++ b/core/test_network/src/lib.rs @@ -52,7 +52,7 @@ pub fn get_chain_id() -> ChainId { /// Get a standardised key-pair from the hard-coded literals. pub fn get_key_pair() -> KeyPair { - KeyPair::from_raw_parts( + KeyPair::new( PublicKey::from_str( "ed01207233BFC89DCBD68C19FDE6CE6158225298EC1131B6A130D1AEB454C1AB5183C0", ).unwrap(), @@ -759,7 +759,7 @@ impl TestConfig for Config { ) .merge(RootPartial::from_env(&StdEnv).expect("test env variables should parse properly")); - let (public_key, private_key) = KeyPair::random().into(); + let (public_key, private_key) = KeyPair::random().into_parts(); layer.public_key.set(public_key); layer.private_key.set(private_key); diff --git a/crypto/src/lib.rs b/crypto/src/lib.rs index 6ea83d59033..f1662780479 100755 --- a/crypto/src/lib.rs +++ b/crypto/src/lib.rs @@ -189,11 +189,11 @@ impl KeyPair { /// Construct a [`KeyPair`]. /// - /// See [`Self::into_raw_parts`] for an opposite conversion. + /// See [`Self::into_parts`] for an opposite conversion. /// /// # Errors /// If public and private keys don't match, i.e. if they don't make a pair - pub fn from_raw_parts(public_key: PublicKey, private_key: PrivateKey) -> Result { + pub fn new(public_key: PublicKey, private_key: PrivateKey) -> Result { let algorithm = private_key.algorithm(); if algorithm != public_key.algorithm() { @@ -213,7 +213,7 @@ impl KeyPair { /// Get [`PublicKey`] and [`PrivateKey`] contained in the [`KeyPair`]. /// /// See [`Self::from_raw_parts`] for an opposite conversion. - pub fn into_raw_parts(self) -> (PublicKey, PrivateKey) { + pub fn into_parts(self) -> (PublicKey, PrivateKey) { (self.public_key, self.private_key) } } @@ -297,15 +297,7 @@ impl<'de> Deserialize<'de> for KeyPair { // NOTE: Verify that key pair is valid let key_pair = KeyPairCandidate::deserialize(deserializer)?; - Self::from_raw_parts(key_pair.public_key, key_pair.private_key).map_err(D::Error::custom) - } -} - -// TODO: enable in ffi_import? -#[cfg(not(feature = "ffi_import"))] -impl From for (PublicKey, PrivateKey) { - fn from(key_pair: KeyPair) -> Self { - key_pair.into_raw_parts() + Self::new(key_pair.public_key, key_pair.private_key).map_err(D::Error::custom) } } @@ -938,7 +930,7 @@ mod tests { #[test] fn key_pair_match() { - KeyPair::from_raw_parts("ed012059C8A4DA1EBB5380F74ABA51F502714652FDCCE9611FAFB9904E4A3C4D382774" + KeyPair::new("ed012059C8A4DA1EBB5380F74ABA51F502714652FDCCE9611FAFB9904E4A3C4D382774" .parse() .expect("Public key not in mulithash format"), PrivateKey::from_hex( @@ -946,7 +938,7 @@ mod tests { "93CA389FC2979F3F7D2A7F8B76C70DE6D5EAF5FA58D4F93CB8B0FB298D398ACC59C8A4DA1EBB5380F74ABA51F502714652FDCCE9611FAFB9904E4A3C4D382774" ).expect("Private key not hex encoded")).unwrap(); - KeyPair::from_raw_parts("ea01309060D021340617E9554CCBC2CF3CC3DB922A9BA323ABDF7C271FCC6EF69BE7A8DEBCA7D9E96C0F0089ABA22CDAADE4A2" + KeyPair::new("ea01309060D021340617E9554CCBC2CF3CC3DB922A9BA323ABDF7C271FCC6EF69BE7A8DEBCA7D9E96C0F0089ABA22CDAADE4A2" .parse() .expect("Public key not in multihash format"), PrivateKey::from_hex( @@ -965,7 +957,7 @@ mod tests { Algorithm::BlsSmall, ] { let key_pair = KeyPair::random_with_algorithm(algorithm); - let (public_key, _) = key_pair.into(); + let (public_key, _) = key_pair.into_parts(); let encoded_public_key = public_key.encode(); @@ -995,7 +987,7 @@ mod tests { #[test] fn key_pair_mismatch() { - KeyPair::from_raw_parts("ed012059C8A4DA1EBB5380F74ABA51F502714652FDCCE9611FAFB9904E4A3C4D382774" + KeyPair::new("ed012059C8A4DA1EBB5380F74ABA51F502714652FDCCE9611FAFB9904E4A3C4D382774" .parse() .expect("Public key not in mulithash format"), PrivateKey::from_hex( @@ -1003,7 +995,7 @@ mod tests { "3A7991AF1ABB77F3FD27CC148404A6AE4439D095A63591B77C788D53F708A02A1509A611AD6D97B01D871E58ED00C8FD7C3917B6CA61A8C2833A19E000AAC2E4" ).expect("Private key not valid")).unwrap_err(); - KeyPair::from_raw_parts("ea01309060D021340617E9554CCBC2CF3CC3DB922A9BA323ABDF7C271FCC6EF69BE7A8DEBCA7D9E96C0F0089ABA22CDAADE4A2" + KeyPair::new("ea01309060D021340617E9554CCBC2CF3CC3DB922A9BA323ABDF7C271FCC6EF69BE7A8DEBCA7D9E96C0F0089ABA22CDAADE4A2" .parse() .expect("Public key not in mulithash format"), PrivateKey::from_hex( diff --git a/data_model/src/events/data/filters.rs b/data_model/src/events/data/filters.rs index 2ffa745f1c7..2d497cd128c 100644 --- a/data_model/src/events/data/filters.rs +++ b/data_model/src/events/data/filters.rs @@ -220,7 +220,7 @@ mod tests { let account_id = AccountId::new(domain_id.clone(), account_name); let account = Account::new( account_id.clone(), - iroha_crypto::KeyPair::random().into_raw_parts().0, + iroha_crypto::KeyPair::random().into_parts().0, ) .into_account(); let asset_id = AssetId::new( diff --git a/data_model/src/predicate.rs b/data_model/src/predicate.rs index cd9ee2961d2..ad2d5775cfa 100644 --- a/data_model/src/predicate.rs +++ b/data_model/src/predicate.rs @@ -495,7 +495,7 @@ pub mod string { #[test] fn peer_id() { - let (public_key, _) = iroha_crypto::KeyPair::random().into(); + let (public_key, _) = iroha_crypto::KeyPair::random().into_parts(); let id = IdBox::PeerId(peer::PeerId::new(socket_addr!(127.0.0.1:123), public_key)); assert!(StringPredicate::contains("123").applies(&id)); } @@ -1066,7 +1066,7 @@ pub mod value { pred.applies(&Value::Identifiable(IdentifiableBox::NewAccount( Account::new( "alice@wonderland".parse().expect("Valid"), - KeyPair::random().into_raw_parts().0, + KeyPair::random().into_parts().0, ) ))) ); @@ -1085,7 +1085,7 @@ pub mod value { } { let key_pair = iroha_crypto::KeyPair::random(); - let (public_key, _) = key_pair.into(); + let (public_key, _) = key_pair.into_parts(); let pred = ValuePredicate::Display(string::StringPredicate::is("alice@wonderland")); println!("{pred:?}"); diff --git a/genesis/src/lib.rs b/genesis/src/lib.rs index cef6ee3c557..128f1a937eb 100644 --- a/genesis/src/lib.rs +++ b/genesis/src/lib.rs @@ -307,11 +307,7 @@ impl RawGenesisDomainBuilder { fn account_with_random_public_key(mut self, account_name: Name) -> Self { let account_id = AccountId::new(self.domain_id.clone(), account_name); self.transaction.isi.push( - Register::account(Account::new( - account_id, - KeyPair::random().into_raw_parts().0, - )) - .into(), + Register::account(Account::new(account_id, KeyPair::random().into_parts().0)).into(), ); self } @@ -362,7 +358,7 @@ mod tests { let chain_id = ChainId::from("0"); let genesis_key_pair = KeyPair::random(); - let (alice_public_key, _) = KeyPair::random().into(); + let (alice_public_key, _) = KeyPair::random().into_parts(); let _genesis_block = GenesisNetwork::new( RawGenesisBlockBuilder::default() @@ -410,7 +406,7 @@ mod tests { finished_genesis_block.transactions[0].isi[1], Register::account(Account::new( AccountId::new(domain_id.clone(), "alice".parse().unwrap()), - KeyPair::random().into_raw_parts().0, + KeyPair::random().into_parts().0, )) .into() ); @@ -418,7 +414,7 @@ mod tests { finished_genesis_block.transactions[0].isi[2], Register::account(Account::new( AccountId::new(domain_id, "bob".parse().unwrap()), - KeyPair::random().into_raw_parts().0, + KeyPair::random().into_parts().0, )) .into() ); @@ -433,7 +429,7 @@ mod tests { finished_genesis_block.transactions[0].isi[4], Register::account(Account::new( AccountId::new(domain_id, "Cheshire_Cat".parse().unwrap()), - KeyPair::random().into_raw_parts().0, + KeyPair::random().into_parts().0, )) .into() ); diff --git a/tools/kagami/src/genesis.rs b/tools/kagami/src/genesis.rs index 01ee0e792b9..3d21b2dc5c7 100644 --- a/tools/kagami/src/genesis.rs +++ b/tools/kagami/src/genesis.rs @@ -237,7 +237,7 @@ fn generate_synthetic( let mut domain_builder = builder.domain(format!("domain_{domain}").parse()?); for account in 0..accounts_per_domain { - let (public_key, _) = iroha_crypto::KeyPair::random().into(); + let (public_key, _) = iroha_crypto::KeyPair::random().into_parts(); domain_builder = domain_builder.account(format!("account_{account}").parse()?, public_key); }