pub enum SessionError {
Keystore(KeystoreError),
EmptySeed,
LegacySeedFormat,
UnsupportedEnvelopeVersion(u8),
UnsupportedSeedKind(u8),
InvalidRecoveryPhrase,
}Expand description
Errors returned by crate::Session operations.
Wraps the underlying dig_keystore failure verbatim (via #[from]) so a
caller can match on the concrete storage/crypto error without dig-session
inventing a parallel error taxonomy, plus the small number of failures that
are specific to session enrollment.
Variants§
Keystore(KeystoreError)
A key-storage or decryption failure surfaced by dig_keystore
(missing file, wrong password, tampered ciphertext, scheme mismatch, …).
#[error(transparent)] is load-bearing: KeystoreError is
#[non_exhaustive] and its catalog grows, so forwarding the inner
Display verbatim is what keeps a NEW refusal legible to a caller that
only prints the error. dig-keystore 0.9 added two such refusals, both
fail-closed on the keystore ROOT directory rather than on any one key:
InsecurePermissions (the root is group- or world-accessible, which on a
mode-ignoring mount — WSL2 /mnt/c, CIFS/SMB, FAT32/exFAT, NFS without
POSIX modes, a Windows/macOS-hosted container bind mount — is reported as
mode 511 and cannot be tightened by chmod) and UnsafeRoot (the root
is a symlink, so the path that was checked is not the path written to).
Neither is recoverable in place: the remedy is a root on a filesystem
that honours Unix modes, and InsecurePermissions’ own Display names
it. A caller MUST NOT retry these, and MUST NOT fold them into a generic
storage-failure branch.
EmptySeed
Enrollment was asked to derive an identity from empty seed material.
A caller must supply real BIP-39 seed bytes; deriving an identity key from an empty seed would silently produce a fixed, guessable key.
LegacySeedFormat
The stored blob predates the versioned seed envelope: its 32 bytes are a raw master seed, not BIP-39 entropy.
This fails CLOSED on purpose. The two encodings are byte-for-byte indistinguishable, so reinterpreting the old bytes as entropy would derive a different, entirely plausible wallet with no error at all — the user would simply see the wrong (empty) account.
§A consumer MUST handle this variant explicitly (HARD REQUIREMENT)
A legacy account is WEDGED, not merely unreadable, and no amount of retrying changes that:
Session::unlock_master_seedreturns this error and never a handle;Session::enroll_master_seedat the same key returnsAlreadyExists, because enrolment refuses to overwrite a custody root;- the pre-envelope releases exposed no
recovery_phrase(), so the user was never shown 24 words, and a legacy raw seed has no phrase that means anything under the current scheme.
So a consumer that merely logs this error leaves the account permanently and silently without a signer. The required remediation, which the consumer owns because only it has a UI:
- Detect this variant specifically — never a catch-all log line.
- Preserve the existing blob (copy it aside; do NOT delete it). It is password-sealed and may hold value, and its password may live in an OS credential store this crate cannot read. Discarding it can destroy the only copy of a funded key.
- Tell the user, in the UI, that the account must be re-created, and that the preserved file is their only copy of the old key.
- Re-enrol at a fresh key (or after moving the old blob aside) via
enroll_master_seedorenroll_from_recovery_phrase, then show the new recovery phrase.
Adopting this version WITHOUT that path is a regression for every already-enrolled install (dig_ecosystem #1759).
UnsupportedEnvelopeVersion(u8)
The stored seed envelope declares a layout version this build does not know. Written by a newer dig-session; refuse rather than guess.
UnsupportedSeedKind(u8)
The stored seed envelope declares a secret KIND this build does not know. Refuse rather than fall back to an interpretation that could be wrong.
InvalidRecoveryPhrase
A supplied recovery phrase is not a valid 24-word English BIP-39 mnemonic (unknown word, failed checksum, or wrong word count).
The message names only the SHAPE of the failure — never a word of the phrase, which is secret material.
Trait Implementations§
Source§impl Debug for SessionError
impl Debug for SessionError
Source§impl Display for SessionError
impl Display for SessionError
Source§impl Error for SessionError
impl Error for SessionError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<KeystoreError> for SessionError
impl From<KeystoreError> for SessionError
Source§fn from(source: KeystoreError) -> Self
fn from(source: KeystoreError) -> Self
Auto Trait Implementations§
impl !RefUnwindSafe for SessionError
impl !UnwindSafe for SessionError
impl Freeze for SessionError
impl Send for SessionError
impl Sync for SessionError
impl Unpin for SessionError
impl UnsafeUnpin for SessionError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.