RusqliteMigration for Migration {
fn up(&self, transaction: &Transaction) -> Result<(), WalletMigrationError> {
let account_kind_derived = account_kind_code(AccountKind::Derived {
- seed_fingerprint: HdSeedFingerprint::from_bytes([0; 32]),
+ seed_fingerprint: SeedFingerprint::from_bytes([0; 32]),
account_index: zip32::AccountId::ZERO,
});
let account_kind_imported = account_kind_code(AccountKind::Imported);
@@ -83,7 +84,8 @@ impl RusqliteMigration for Migration {
Ok(row.get::<_, u32>(0)? > 0)
})? {
if let Some(seed) = &self.seed.as_ref() {
- let seed_id = HdSeedFingerprint::from_seed(seed);
+ let seed_id = SeedFingerprint::from_seed(seed.expose_secret())
+ .expect("Seed is between 32 and 252 bytes in length.");
let mut q = transaction.prepare("SELECT * FROM accounts")?;
let mut rows = q.query([])?;
while let Some(row) = rows.next()? {
@@ -145,7 +147,7 @@ impl RusqliteMigration for Migration {
named_params![
":account_id": account_id,
":account_kind": account_kind_derived,
- ":seed_id": seed_id.as_bytes(),
+ ":seed_id": seed_id.to_bytes(),
":account_index": account_index,
":ufvk": ufvk,
":uivk": uivk,
diff --git a/zcash_keys/CHANGELOG.md b/zcash_keys/CHANGELOG.md
index 79654d4c95..5689f98bbc 100644
--- a/zcash_keys/CHANGELOG.md
+++ b/zcash_keys/CHANGELOG.md
@@ -7,7 +7,6 @@ and this library adheres to Rust's notion of
## [Unreleased]
### Added
-- `zcash_keys::keys::HdSeedFingerprint`
- `zcash_keys::address::Address::has_receiver`
- `impl Display for zcash_keys::keys::AddressGenerationError`
- `impl std::error::Error for zcash_keys::keys::AddressGenerationError`
diff --git a/zcash_keys/src/keys.rs b/zcash_keys/src/keys.rs
index 27dfb8393b..92f5407c1e 100644
--- a/zcash_keys/src/keys.rs
+++ b/zcash_keys/src/keys.rs
@@ -1,6 +1,6 @@
//! Helper functions for managing light client key material.
-use blake2b_simd::Params as blake2bParams;
-use secrecy::{ExposeSecret, SecretVec};
+
+
use std::{error, fmt};
use zcash_address::unified::{self, Container, Encoding, Typecode};
@@ -73,53 +73,6 @@ pub mod sapling {
}
}
-/// A [ZIP 32 seed fingerprint] of a seed used for an HD account.
-///
-/// For wallets that use [BIP 39] mnemonic phrases, this is the fingerprint of the binary
-/// seed [produced from the mnemonic].
-///
-/// [ZIP 32 seed fingerprint]: https://zips.z.cash/zip-0032#seed-fingerprints
-/// [BIP 39]: https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki
-/// [produced from the mnemonic]: https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki#from-mnemonic-to-seed
-#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
-pub struct HdSeedFingerprint([u8; 32]);
-
-impl HdSeedFingerprint {
- /// Generates the fingerprint from a given seed.
- ///
- /// Panics if the length of the seed is not between 32 and 252 bytes inclusive.
- pub fn from_seed(seed: &SecretVec) -> Self {
- let len = seed.expose_secret().len();
- let len = match len {
- 32..=252 => [u8::try_from(len).unwrap()],
- _ => panic!("ZIP 32 seeds MUST be at least 32 bytes and at most 252 bytes"),
- };
- const PERSONALIZATION: &[u8] = b"Zcash_HD_Seed_FP";
- let hash = blake2bParams::new()
- .hash_length(32)
- .personal(PERSONALIZATION)
- .to_state()
- .update(&len)
- .update(seed.expose_secret())
- .finalize();
- Self(
- hash.as_bytes()
- .try_into()
- .expect("BLAKE2b-256 hash length is 32 bytes"),
- )
- }
-
- /// Instantiates the fingerprint from a buffer containing a previously computed fingerprint.
- pub fn from_bytes(hash: [u8; 32]) -> Self {
- Self(hash)
- }
-
- /// Returns the bytes of the fingerprint.
- pub fn as_bytes(&self) -> &[u8; 32] {
- &self.0
- }
-}
-
#[cfg(feature = "transparent-inputs")]
fn to_transparent_child_index(j: DiversifierIndex) -> Option {
let (low_4_bytes, rest) = j.as_bytes().split_at(4);