Skip to content

Commit

Permalink
rusk-wallet: remove unnecessary Seed structure
Browse files Browse the repository at this point in the history
  • Loading branch information
ZER0 committed Sep 9, 2024
1 parent a2a0ae4 commit 0e3edbe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 30 deletions.
2 changes: 1 addition & 1 deletion rusk-wallet/src/dat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
36 changes: 7 additions & 29 deletions rusk-wallet/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Self, Self::Error> {
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)]
Expand All @@ -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<Seed> 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()
}
}

0 comments on commit 0e3edbe

Please sign in to comment.