mirror of
https://github.com/jwinterm/grin-wallet.git
synced 2026-12-03 12:24:27 +01:00
Slatepack - Pt 2 - Encryption (#411)
* recreate PR from #400 * first tests with slate encryption * simplify slatepack model to contain encryption header in payload, and add de/ser tests * update tests and confirm slatepack encryption working * remove recipient list, add version check warning
This commit is contained in:
@@ -20,7 +20,7 @@ use crate::grin_core::core::hash::Hashed;
|
||||
use crate::grin_core::core::Transaction;
|
||||
use crate::grin_util::secp::key::SecretKey;
|
||||
use crate::grin_util::Mutex;
|
||||
use crate::util::OnionV3Address;
|
||||
use crate::util::{OnionV3Address, OnionV3AddressError};
|
||||
|
||||
use crate::api_impl::owner_updater::StatusMessage;
|
||||
use crate::grin_keychain::{Identifier, Keychain};
|
||||
@@ -93,6 +93,36 @@ where
|
||||
Ok(addr.to_ed25519()?)
|
||||
}
|
||||
|
||||
/// Retrieve the decryption key for the current parent key
|
||||
/// the given index
|
||||
/// set active account
|
||||
pub fn get_secret_key<'a, L, C, K>(
|
||||
wallet_inst: Arc<Mutex<Box<dyn WalletInst<'a, L, C, K>>>>,
|
||||
keychain_mask: Option<&SecretKey>,
|
||||
index: u32,
|
||||
) -> Result<DalekSecretKey, Error>
|
||||
where
|
||||
L: WalletLCProvider<'a, C, K>,
|
||||
C: NodeClient + 'a,
|
||||
K: Keychain + 'a,
|
||||
{
|
||||
wallet_lock!(wallet_inst, w);
|
||||
let parent_key_id = w.parent_key_id();
|
||||
let k = w.keychain(keychain_mask)?;
|
||||
let sec_addr_key = address::address_from_derivation_path(&k, &parent_key_id, index)?;
|
||||
let d_skey = match DalekSecretKey::from_bytes(&sec_addr_key.0) {
|
||||
Ok(k) => k,
|
||||
Err(e) => {
|
||||
return Err(OnionV3AddressError::InvalidPrivateKey(format!(
|
||||
"Unable to create secret key: {}",
|
||||
e
|
||||
))
|
||||
.into());
|
||||
}
|
||||
};
|
||||
Ok(d_skey)
|
||||
}
|
||||
|
||||
/// retrieve outputs
|
||||
pub fn retrieve_outputs<'a, L, C, K>(
|
||||
wallet_inst: Arc<Mutex<Box<dyn WalletInst<'a, L, C, K>>>>,
|
||||
|
||||
Reference in New Issue
Block a user