From f86d7e3940bc5bb70551a8e127269263779e11b7 Mon Sep 17 00:00:00 2001 From: brianp Date: Tue, 23 Apr 2024 11:17:26 +0200 Subject: [PATCH] Make the software wallet use priv and pub key types --- .../comms/src/ledger_wallet.rs | 3 ++- base_layer/common_types/src/wallet_types.rs | 16 +++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/applications/minotari_ledger_wallet/comms/src/ledger_wallet.rs b/applications/minotari_ledger_wallet/comms/src/ledger_wallet.rs index 3452986e80..284a894937 100644 --- a/applications/minotari_ledger_wallet/comms/src/ledger_wallet.rs +++ b/applications/minotari_ledger_wallet/comms/src/ledger_wallet.rs @@ -45,6 +45,7 @@ pub enum Instruction { GetAppName = 0x02, GetPrivateKey = 0x03, GetPublicKey = 0x04, + GetScriptSignature = 0x05, } impl Instruction { @@ -78,7 +79,7 @@ impl> Command { #[derive(Debug, Clone, Serialize, Deserialize)] pub struct LedgerWallet { account: u64, - pubkey: Option, + pub pubkey: Option, } impl Display for LedgerWallet { diff --git a/base_layer/common_types/src/wallet_types.rs b/base_layer/common_types/src/wallet_types.rs index 729dcb3de7..7b66efeeaa 100644 --- a/base_layer/common_types/src/wallet_types.rs +++ b/base_layer/common_types/src/wallet_types.rs @@ -28,22 +28,20 @@ use std::{ use chacha20poly1305::aead::OsRng; use minotari_ledger_wallet_comms::ledger_wallet::LedgerWallet; use serde::{Deserialize, Serialize}; -use tari_crypto::{ - keys::{PublicKey, SecretKey}, - ristretto::{RistrettoPublicKey, RistrettoSecretKey}, -}; -use tari_utilities::ByteArray; +use tari_crypto::keys::{PublicKey as PublicKeyTrait, SecretKey}; + +use crate::types::{PrivateKey, PublicKey}; #[derive(Debug, Clone, Serialize, Deserialize)] pub enum WalletType { - Software(Vec, Vec), // Make them a priv and pub + Software(PrivateKey, PublicKey), // Make them a priv and pub Ledger(LedgerWallet), } impl Display for WalletType { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { match self { - WalletType::Software(pk, _k) => write!(f, "Software({:?})", pk), + WalletType::Software(_k, pk) => write!(f, "Software({:?})", pk), WalletType::Ledger(account) => write!(f, "Ledger({account})"), } } @@ -51,7 +49,7 @@ impl Display for WalletType { impl Default for WalletType { fn default() -> Self { - let k = RistrettoSecretKey::random(&mut OsRng); - WalletType::Software(RistrettoPublicKey::from_secret_key(&k).to_vec(), k.to_vec()) + let k: PrivateKey = SecretKey::random(&mut OsRng); + WalletType::Software(k.clone(), PublicKey::from_secret_key(&k)) } }