Skip to content

Commit

Permalink
fixup! Use KeyObfuscator in VssStore.
Browse files Browse the repository at this point in the history
  • Loading branch information
G8XSU committed Oct 17, 2024
1 parent 483464f commit f0510a0
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/io/vss_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ pub struct VssStore {
storable_builder: StorableBuilder<RandEntropySource>,
key_obfuscator: KeyObfuscator,
}

// Used to derive `data_encryption_key` from `vss_seed`, which is then used by the `StorableBuilder`.
const DATA_ENCRYPTION_KEY_DERIVATION_INDEX: u32 = 1;

// Used to derive `obfuscation_master_key` from `vss_seed`, which is then used by the `KeyObfuscator`.
const OBFUSCATION_KEY_DERIVATION_INDEX: u32 = 2;

impl VssStore {
Expand All @@ -56,7 +60,11 @@ impl VssStore {
header_provider: Arc<dyn VssHeaderProvider>,
) -> io::Result<Self> {
let runtime = tokio::runtime::Builder::new_multi_thread().enable_all().build()?;
let vss_master_xprv = Xpriv::new_master(Network::Bitcoin, &vss_seed).unwrap();
// The selected bitcoin network doesn't matter here.
let vss_master_xprv = Xpriv::new_master(Network::Bitcoin, &vss_seed).map_err(|e| {
let msg = format!("Failed to create Vss master key, error: {}", e);
io::Error::new(ErrorKind::Other, msg)
})?;
let data_encryption_key =
derive_hardened_key(&vss_master_xprv, DATA_ENCRYPTION_KEY_DERIVATION_INDEX)?;
let obfuscation_master_key =
Expand Down

0 comments on commit f0510a0

Please sign in to comment.