chore(deps): Update iota_stronghold to v2 (#1480)

ref https://github.com/tauri-apps/plugins-workspace/pull/950
This commit is contained in:
Fabian-Lars
2024-06-17 17:20:33 +02:00
committed by GitHub
parent d126183d0a
commit b18a03a376
4 changed files with 383 additions and 186 deletions
+2 -2
View File
@@ -22,11 +22,11 @@ serde_json = { workspace = true }
tauri = { workspace = true }
log = { workspace = true }
thiserror = { workspace = true }
iota_stronghold = "1"
iota_stronghold = "2"
iota-crypto = "0.23"
hex = "0.4"
zeroize = { version = "1", features = [ "zeroize_derive" ] }
rust-argon2 = { version = "1", optional = true }
rust-argon2 = { version = "2", optional = true }
rand_chacha = { version = "0.3.1", optional = true }
rand_core = { version = "0.6.4", features = [ "getrandom" ], optional = true }
+12 -7
View File
@@ -19,9 +19,10 @@ use std::{
time::Duration,
};
use crypto::keys::bip39;
use iota_stronghold::{
procedures::{
BIP39Generate, BIP39Recover, Chain, Ed25519Sign, KeyType as StrongholdKeyType,
BIP39Generate, BIP39Recover, Curve, Ed25519Sign, KeyType as StrongholdKeyType,
MnemonicLanguage, PublicKey, Slip10Derive, Slip10DeriveInput, Slip10Generate,
StrongholdProcedure,
},
@@ -33,7 +34,7 @@ use tauri::{
plugin::{Builder as PluginBuilder, TauriPlugin},
Manager, Runtime, State,
};
use zeroize::Zeroize;
use zeroize::{Zeroize, Zeroizing};
#[cfg(feature = "kdf")]
pub mod kdf;
@@ -199,7 +200,8 @@ impl From<ProcedureDto> for StrongholdProcedure {
input,
output,
} => StrongholdProcedure::Slip10Derive(Slip10Derive {
chain: Chain::from_u32_hardened(chain),
curve: Curve::Ed25519,
chain,
input: input.into(),
output: output.into(),
}),
@@ -208,13 +210,13 @@ impl From<ProcedureDto> for StrongholdProcedure {
passphrase,
output,
} => StrongholdProcedure::BIP39Recover(BIP39Recover {
mnemonic,
passphrase,
mnemonic: bip39::Mnemonic::from(mnemonic),
passphrase: bip39::Passphrase::from(passphrase.unwrap_or_default()),
output: output.into(),
}),
ProcedureDto::BIP39Generate { passphrase, output } => {
StrongholdProcedure::BIP39Generate(BIP39Generate {
passphrase,
passphrase: bip39::Passphrase::from(passphrase.unwrap_or_default()),
output: output.into(),
language: MnemonicLanguage::English,
})
@@ -351,7 +353,10 @@ async fn save_secret(
let client = get_client(collection, snapshot_path, client)?;
client
.vault(&vault)
.write_secret(Location::generic(vault, record_path), secret)
.write_secret(
Location::generic(vault, record_path),
Zeroizing::new(secret),
)
.map_err(Into::into)
}
+2 -1
View File
@@ -6,6 +6,7 @@ use std::{convert::TryFrom, ops::Deref, path::Path};
use iota_stronghold::{KeyProvider, SnapshotPath};
use serde::{Serialize, Serializer};
use zeroize::Zeroizing;
pub type Result<T> = std::result::Result<T, Error>;
@@ -40,7 +41,7 @@ impl Stronghold {
pub fn new<P: AsRef<Path>>(path: P, password: Vec<u8>) -> Result<Self> {
let path = SnapshotPath::from_path(path);
let stronghold = iota_stronghold::Stronghold::default();
let keyprovider = KeyProvider::try_from(password)?;
let keyprovider = KeyProvider::try_from(Zeroizing::new(password))?;
if path.exists() {
stronghold.load_snapshot(&keyprovider, &path)?;
}