diff --git a/crates/daemon/keyforkd/src/lib.rs b/crates/daemon/keyforkd/src/lib.rs index 40eafd4..d578500 100644 --- a/crates/daemon/keyforkd/src/lib.rs +++ b/crates/daemon/keyforkd/src/lib.rs @@ -57,7 +57,7 @@ pub async fn start_and_run_server_on( let service = ServiceBuilder::new() .layer(middleware::BincodeLayer::new()) // TODO: passphrase support and/or store passphrase with mnemonic - .service(Keyforkd::new(mnemonic.generate_seed(None))); + .service(Keyforkd::new(mnemonic.generate_seed(None).to_vec())); let mut server = match UnixServer::bind(socket_path) { Ok(s) => s, diff --git a/crates/keyfork/src/cli/wizard.rs b/crates/keyfork/src/cli/wizard.rs index dc9cbb1..d7fa553 100644 --- a/crates/keyfork/src/cli/wizard.rs +++ b/crates/keyfork/src/cli/wizard.rs @@ -14,7 +14,7 @@ use keyfork_derive_openpgp::{ openpgp::{self, packet::UserID, types::KeyFlags, Cert, serialize::Marshal, armor::{Writer, Kind}}, XPrv, }; -use keyfork_derive_util::{DerivationIndex, DerivationPath, VariableLengthSeed}; +use keyfork_derive_util::{DerivationIndex, DerivationPath}; use keyfork_prompt::{ default_terminal, validators::{SecurePinValidator, Validator}, @@ -196,7 +196,6 @@ fn generate_shard_secret( fn bottoms_up(key_discovery: &Path, threshold: u8, output_shardfile: &Path, output_cert: &Path, user_id: &str,) -> Result<()> { let entropy = keyfork_entropy::generate_entropy_of_const_size::<{ 256 / 8 }>()?; let mnemonic = Mnemonic::from_nonstandard_bytes(entropy); - // TODO: make this return const size, since is hash based let seed = mnemonic.generate_seed(None); // TODO: should this allow for customizing the account index from 0? Potential for key reuse @@ -213,7 +212,7 @@ fn bottoms_up(key_discovery: &Path, threshold: u8, output_shardfile: &Path, outp .set_storage_encryption(), KeyFlags::empty().set_authentication(), ]; - let xprv = XPrv::new(VariableLengthSeed::new(&seed)) + let xprv = XPrv::new(seed) .expect("could not construct master key from seed") .derive_path(&path)?; let userid = UserID::from(user_id); diff --git a/crates/util/keyfork-mnemonic-util/src/lib.rs b/crates/util/keyfork-mnemonic-util/src/lib.rs index 1ba5405..d456f64 100644 --- a/crates/util/keyfork-mnemonic-util/src/lib.rs +++ b/crates/util/keyfork-mnemonic-util/src/lib.rs @@ -408,7 +408,7 @@ where &self, passphrase: impl Into>, ) -> Result, MnemonicGenerationError> { - Ok(self.generate_seed(passphrase)) + Ok(self.generate_seed(passphrase).to_vec()) } /// Create a BIP-0032 seed from the provided data and an optional passphrase. @@ -416,8 +416,7 @@ where /// # Panics /// The function may panic if the HmacSha512 function returns an error. The only error the /// HmacSha512 function should return is an invalid length, which should not be possible. - /// - pub fn generate_seed<'a>(&self, passphrase: impl Into>) -> Vec { + pub fn generate_seed<'a>(&self, passphrase: impl Into>) -> [u8; 64] { let passphrase = passphrase.into(); let mut seed = [0u8; 64]; @@ -425,7 +424,7 @@ where let salt = ["mnemonic", passphrase.unwrap_or("")].join(""); pbkdf2::>(mnemonic.as_bytes(), salt.as_bytes(), 2048, &mut seed) .expect(bug!("HmacSha512 InvalidLength should be infallible")); - seed.to_vec() + seed } /// Encode the mnemonic into a list of integers 11 bits in length, matching the length of a