Struct RootSeed

Source
pub struct RootSeed(/* private fields */);
Expand description

The root secret from which the user node’s keys and credentials are derived.

Implementations§

Source§

impl RootSeed

Source

pub fn generate() -> Self

Generate a new random RootSeed using the system CSPRNG.

Source

pub fn read(wallet_env: &WalletEnv) -> Result<Option<Self>>

Read a RootSeed from the default seedphrase path for this environment (~/.lexe/seedphrase[.env].txt).

Returns Ok(None) if the file doesn’t exist.

Source

pub fn write(&self, wallet_env: &WalletEnv) -> Result<()>

Write this RootSeed to the default seedphrase path for this environment (~/.lexe/seedphrase[.env].txt).

Creates parent directories if needed. Fails if the file already exists.

Source

pub fn read_from_path(path: &Path) -> Result<Option<Self>>

Read a RootSeed from a seedphrase file at a specific path.

Returns Ok(None) if the file doesn’t exist.

Source

pub fn write_to_path(&self, path: &Path) -> Result<()>

Write this RootSeed to a seedphrase file at a specific path.

Creates parent directories if needed. Returns an error if the file already exists. On Unix, the file is created with mode 0600 (owner read/write only).

Source

pub fn from_mnemonic(mnemonic: Mnemonic) -> Result<Self>

Construct a RootSeed from a BIP39 mnemonic.

Source

pub fn from_bytes(bytes: &[u8]) -> Result<Self>

Construct a RootSeed from a 32-byte slice.

Source

pub fn from_hex(hex: &str) -> Result<Self>

Construct a RootSeed from a 64-character hex string.

Source

pub fn to_mnemonic(&self) -> Mnemonic

Convert this root secret to its BIP39 mnemonic.

Source

pub fn as_bytes(&self) -> &[u8]

Borrow the 32-byte root secret.

Source

pub fn to_hex(&self) -> String

Encode the root secret as a 64-character hex string.

Source

pub fn derive_user_pk(&self) -> UserPk

Derive the user’s public key.

Source

pub fn derive_node_pk(&self) -> NodePk

Derive the node public key.

Source

pub fn password_encrypt(&self, password: &str) -> Result<Vec<u8>>

Encrypt this root secret under the given password.

Source

pub fn password_decrypt(password: &str, encrypted: Vec<u8>) -> Result<Self>

Decrypt a password-encrypted root secret.

Trait Implementations§

Source§

impl Debug for RootSeed

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for RootSeed

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<'a> From<&'a RootSeed> for CredentialsRef<'a>

Source§

fn from(root_seed: &'a RootSeed) -> Self

Converts to this type from the input type.
Source§

impl From<RootSeed> for Credentials

Source§

fn from(root_seed: RootSeed) -> Self

Converts to this type from the input type.
Source§

impl FromStr for RootSeed

Source§

type Err = <RootSeed as FromStr>::Err

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Serialize for RootSeed

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl TryFrom<&[u8]> for RootSeed

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(bytes: &[u8]) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Mnemonic> for RootSeed

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(mnemonic: Mnemonic) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<F, T, U> Apply<F, U> for T
where F: FnOnce(T) -> U,

§

fn apply(self, f: F) -> U

Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,