key: add `GetSecp256k1SignContext` access function
What changed, and why it matters
This commit simply adds a public accessor function that returns an internal cryptographic context object. It does not change how keys are created, signed, or verified, and it introduces no new behavior that could be exploited. It is a routine code-organization change to support future work.
No security action required; review as normal refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch adds GetSecp256k1SignContext() in src/key.cpp and declares it in src/key.h, exposing the existing secp256k1_context_sign pointer. It also adds the forward declaration for secp256k1_context in the header. No logic changes, no new allocations, no input handling, and no security-sensitive operations are introduced.
Changed components
src/key.cppsrc/key.hInspect captured patch +10 / −0
diff --git a/src/key.cpp b/src/key.cpp
index f17a2867..60f6eb67 100644
--- a/src/key.cpp
+++ b/src/key.cpp
@@ -568,6 +568,11 @@ bool ECC_InitSanityCheck() {
return key.VerifyPubKey(pubkey);
}
+secp256k1_context* GetSecp256k1SignContext()
+{
+ return secp256k1_context_sign;
+}
+
/** Initialize the elliptic curve support. May not be called twice without calling ECC_Stop first. */
static void ECC_Start() {
assert(secp256k1_context_sign == nullptr);
diff --git a/src/key.h b/src/key.h
index f35f3cc0..e2c9d82f 100644
--- a/src/key.h
+++ b/src/key.h
@@ -16,6 +16,8 @@
#include <stdexcept>
#include <vector>
+struct secp256k1_context_struct;
+typedef struct secp256k1_context_struct secp256k1_context;
/**
* CPrivKey is a serialized private key, with all parameters included
@@ -315,6 +317,9 @@ private:
/** Check that required EC support is available at runtime. */
bool ECC_InitSanityCheck();
+/** Access the secp256k1 context used for signing and MuSig2 nonce generation. */
+secp256k1_context* GetSecp256k1SignContext();
+
/**
* RAII class initializing and deinitializing global state for elliptic curve support.
* Only one instance may be initialized at a time.
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.