From 0e3edbebb714ce21d6eddc337001c8e001fc869d Mon Sep 17 00:00:00 2001 From: zer0 Date: Mon, 9 Sep 2024 17:27:09 +0200 Subject: [PATCH] rusk-wallet: remove unnecessary `Seed` structure --- rusk-wallet/src/dat.rs | 2 +- rusk-wallet/src/store.rs | 36 +++++++----------------------------- 2 files changed, 8 insertions(+), 30 deletions(-) diff --git a/rusk-wallet/src/dat.rs b/rusk-wallet/src/dat.rs index 6ab92adaf0..285acf21cf 100644 --- a/rusk-wallet/src/dat.rs +++ b/rusk-wallet/src/dat.rs @@ -7,7 +7,7 @@ use std::fs; use std::io::Read; -use wallet_core::keys::Seed; +use wallet_core::Seed; use crate::crypto::decrypt; use crate::Error; diff --git a/rusk-wallet/src/store.rs b/rusk-wallet/src/store.rs index b5c31aec54..99944c112a 100644 --- a/rusk-wallet/src/store.rs +++ b/rusk-wallet/src/store.rs @@ -6,29 +6,7 @@ use crate::clients::State; -use dusk_bytes::{Error as BytesError, Serializable}; - -use wallet_core::keys::{self, RNG_SEED}; - -#[derive(Clone)] -pub struct Seed(keys::Seed); - -impl Default for Seed { - fn default() -> Self { - Self([0u8; RNG_SEED]) - } -} - -impl Serializable<64> for Seed { - type Error = BytesError; - - fn from_bytes(buff: &[u8; Seed::SIZE]) -> Result { - Ok(Self(*buff)) - } - fn to_bytes(&self) -> [u8; Seed::SIZE] { - self.0 - } -} +use wallet_core::Seed; /// Provides a valid wallet seed to dusk_wallet_core #[derive(Clone)] @@ -38,20 +16,20 @@ pub(crate) struct LocalStore { impl LocalStore { /// Retrieves the seed used to derive keys. - pub fn get_seed(&self) -> &[u8; Seed::SIZE] { - &self.seed.0 + pub fn get_seed(&self) -> &Seed { + &self.seed } } -impl From<[u8; Seed::SIZE]> for LocalStore { - fn from(seed: [u8; Seed::SIZE]) -> Self { - LocalStore { seed: Seed(seed) } +impl From for LocalStore { + fn from(seed: Seed) -> Self { + LocalStore { seed } } } impl State { /// Retrieves the seed used to derive keys. - pub fn get_seed(&self) -> &[u8; Seed::SIZE] { + pub fn get_seed(&self) -> &Seed { self.store().get_seed() } }