bitbox-secp256k1: remove needless ffi def of secp256k1_ecdsa_signature_serialize_compact
What changed, and why it matters
This commit removes a duplicate low-level binding to a secp256k1 cryptographic function and replaces its use with an equivalent, already-vetted wrapper from the project's dependency on the bitcoin::secp256k1 Rust crate. It is a code cleanup/refactoring change with no security-relevant behavior change visible in the diff.
No security action required. Treat as routine refactoring/cleanup. Standard review is sufficient.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change deletes a manual FFI declaration for secp256k1_ecdsa_signature_serialize_compact and the call site that used it. Instead, the code converts the raw secp256k1_ecdsa_signature to bitcoin::secp256k1::ecdsa::Signature and calls serialize_compact() on that wrapper. The functional result (a 64-byte compact ECDSA signature) is identical; only the source of the implementation changes, from a local FFI call to the upstream Rust crate’s wrapper.
Changed components
src/rust/bitbox-secp256k1/src/lib.rsInspect captured patch +2 / −17
diff --git a/src/rust/bitbox-secp256k1/src/lib.rs b/src/rust/bitbox-secp256k1/src/lib.rs
index 24ffc64..2822ca6 100644
--- a/src/rust/bitbox-secp256k1/src/lib.rs
+++ b/src/rust/bitbox-secp256k1/src/lib.rs
@@ -72,12 +72,6 @@ mod ffi {
opening: *const secp256k1_ecdsa_s2c_opening,
) -> c_int;
- pub fn secp256k1_ecdsa_signature_serialize_compact(
- ctx: *const Context,
- output64: *mut c_uchar,
- sig: *const Signature,
- ) -> c_int;
-
pub fn bitbox_secp256k1_dleq_prove(
ctx: *const Context,
s: *mut c_uchar,
@@ -176,17 +170,8 @@ pub fn secp256k1_sign(
return Err(());
}
- let mut signature = [0u8; 64];
- if unsafe {
- ffi::secp256k1_ecdsa_signature_serialize_compact(
- SECP256K1.ctx().as_ptr(),
- signature.as_mut_ptr(),
- sig.as_ptr(),
- )
- } != 1
- {
- return Err(());
- }
+ let sig = bitcoin::secp256k1::ecdsa::Signature::from(unsafe { sig.assume_init() });
+ let signature = sig.serialize_compact();
Ok(SignResult {
signature,
recid: recid.try_into().unwrap(),
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.