Skip to content

Conversation

@benma
Copy link
Collaborator

@benma benma commented Dec 18, 2025

All functions in it are unrelated to the keystore.

@benma benma requested review from cedwies and removed request for cedwies December 18, 2025 15:42
@benma benma marked this pull request as draft December 18, 2025 15:50
@benma benma requested a review from cedwies December 18, 2025 16:15
@benma benma marked this pull request as ready for review December 18, 2025 16:15
@benma benma force-pushed the keystore-c branch 2 times, most recently from 472a888 to 939adf1 Compare December 20, 2025 20:09
Copy link
Collaborator

@cedwies cedwies left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found no major issues. Nice refactoring. Please consider my comments.

}

/// Length of a compressed secp256k1 pubkey.
const EC_PUBLIC_KEY_LEN: usize = 33;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are you not using bitbox02::secp256k1::EC_PUBLIC_KEY_LEN here? Why did you choose the duplicate value?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Removed the constant completely, see added commit.

///
/// # Returns
/// * `Ok(SignResult)` containing signature in compact format and recoverable id on success
/// * `Err(())` if the keystore is locked
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doc was moved, but I think this line is incorrect. Does this fn even look at "keystore locked"? Isn't this checked before this fn runs?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, see added commit. This used to be true but stopped being true after some refactor in the past.

benma's agent and others added 6 commits December 22, 2025 11:58
Fix undefined secp256k1_* symbols when linking firmware. These errors
would happen if keystore.c stops referencing the secp256k1
symbols (see later commit).

We link libsecp256k1 as a static archive and the linker resolves
static libs left-to-right, only pulling in objects that satisfy
currently-unresolved symbols. Since the Rust archive introduces the
secp256k1_* references, it must appear before the secp256k1 library on
the link line (otherwise the linker scans secp256k1 too early and
doesn't pull the needed objects).
They are not related to the keystore. The keystore.c functions they
use will be dealt with in the next commit.
The two remaning functions are unrelated to keystore, and inlined into
the Rust C wrappers of secp256k1.
It was a leftover from the time we used libwally-core. The same
constant is available in bitcoin::secp256k1::constants::PUBLIC_KEY_SIZE.
keystore locked error used to be the case in the past when this
function took the private key from the keystore, but that changed.
Copy link
Collaborator

@cedwies cedwies left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing the comments, code review tACK :)

Copy link
Collaborator

@NickeZ NickeZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

@benma benma merged commit a1bdbad into BitBoxSwiss:master Dec 22, 2025
42 checks passed
@benma benma deleted the keystore-c branch December 22, 2025 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants