keystore: move Error from bitbox02 crate to bitbox02-rust crate
What changed, and why it matters
This commit is a simple internal code cleanup: it moves a Rust error type definition from one internal crate to another. The same error variants and conversion logic are preserved exactly, just relocated. There is no user-facing change, no bug fix, and no security-relevant behavior change.
No action required. Treat as routine refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The keystore::Error enum and its From<securechip::Error> implementation are moved from src/rust/bitbox02/src/keystore.rs to src/rust/bitbox02-rust/src/keystore.rs. The bitbox02-rust crate stops re-exporting bitbox02::keystore::Error and instead defines it locally. The SignResult struct remains in bitbox02::keystore. This is a pure refactor with no functional change.
Changed components
src/rust/bitbox02-rust/src/keystore.rssrc/rust/bitbox02/src/keystore.rsInspect captured patch +29 / −30
diff --git a/src/rust/bitbox02-rust/src/keystore.rs b/src/rust/bitbox02-rust/src/keystore.rs
index 49692c8..5d48206 100644
--- a/src/rust/bitbox02-rust/src/keystore.rs
+++ b/src/rust/bitbox02-rust/src/keystore.rs
@@ -20,7 +20,6 @@ use alloc::vec::Vec;
use crate::bip32;
use crate::hal::Random;
-pub use bitbox02::keystore::Error;
pub use bitbox02::keystore::SignResult;
use bitbox02::{keystore, securechip};
@@ -41,6 +40,35 @@ const ENCRYPTION_OVERHEAD: usize = 64;
// to roughly seven seconds so we don't assume communication was lost mid-unlock.
const LONG_TIMEOUT: i16 = -70;
+#[derive(Debug)]
+pub enum Error {
+ CannotUnlockBIP39,
+ IncorrectPassword,
+ MaxAttemptsExceeded,
+ Unseeded,
+ Memory,
+ // Securechip error with the error code from securechip.c. 0 if the error is unspecified.
+ SecureChip(i32),
+ SeedSize,
+ Salt,
+ Hash,
+ Encrypt,
+ Decrypt,
+ StretchRetainedSeedKey,
+}
+
+impl core::convert::From<bitbox02::securechip::Error> for Error {
+ fn from(error: bitbox02::securechip::Error) -> Self {
+ match error {
+ bitbox02::securechip::Error::SecureChip(
+ bitbox02::securechip::SecureChipError::SC_ERR_INCORRECT_PASSWORD,
+ ) => Error::IncorrectPassword,
+ bitbox02::securechip::Error::SecureChip(sc_err) => Error::SecureChip(sc_err as i32),
+ bitbox02::securechip::Error::Status(status) => Error::SecureChip(status),
+ }
+ }
+}
+
#[derive(Copy, Clone)]
struct ReadOnlyBuffer {
// 64 is the biggest retained buffer (bip39 seed) we will store, and 64 is added for the
diff --git a/src/rust/bitbox02/src/keystore.rs b/src/rust/bitbox02/src/keystore.rs
index 259aaf0..d2ea790 100644
--- a/src/rust/bitbox02/src/keystore.rs
+++ b/src/rust/bitbox02/src/keystore.rs
@@ -19,35 +19,6 @@ use bitcoin::secp256k1::{All, Secp256k1};
/// Length of a compressed secp256k1 pubkey.
const EC_PUBLIC_KEY_LEN: usize = 33;
-#[derive(Debug)]
-pub enum Error {
- CannotUnlockBIP39,
- IncorrectPassword,
- MaxAttemptsExceeded,
- Unseeded,
- Memory,
- // Securechip error with the error code from securechip.c. 0 if the error is unspecified.
- SecureChip(i32),
- SeedSize,
- Salt,
- Hash,
- Encrypt,
- Decrypt,
- StretchRetainedSeedKey,
-}
-
-impl core::convert::From<crate::securechip::Error> for Error {
- fn from(error: crate::securechip::Error) -> Self {
- match error {
- crate::securechip::Error::SecureChip(
- crate::securechip::SecureChipError::SC_ERR_INCORRECT_PASSWORD,
- ) => Error::IncorrectPassword,
- crate::securechip::Error::SecureChip(sc_err) => Error::SecureChip(sc_err as i32),
- crate::securechip::Error::Status(status) => Error::SecureChip(status),
- }
- }
-}
-
pub struct SignResult {
pub signature: [u8; 64],
pub recid: u8,
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.