From 52455af680bc3b5d9f1353455a17020cda43fe77 Mon Sep 17 00:00:00 2001 From: Byron Hambly Date: Tue, 1 Sep 2026 19:55:31 +0200 Subject: [PATCH 1/5] pegin: randomize secp256k1 SIGN context in Secp256k1Ctx --- src/pegins.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pegins.cpp b/src/pegins.cpp index b09677faec..f5471cd911 100644 --- a/src/pegins.cpp +++ b/src/pegins.cpp @@ -35,7 +35,7 @@ class Secp256k1Ctx public: Secp256k1Ctx() { assert(secp256k1_ctx_validation == nullptr); - secp256k1_ctx_validation = secp256k1_context_create(SECP256K1_CONTEXT_VERIFY | SECP256K1_CONTEXT_SIGN); + secp256k1_ctx_validation = secp256k1_context_create(SECP256K1_CONTEXT_NONE); assert(secp256k1_ctx_validation != nullptr); } From 0e7b1a69c768269fabe1c1db02697595a4e85158 Mon Sep 17 00:00:00 2001 From: Byron Hambly Date: Tue, 1 Sep 2026 19:55:46 +0200 Subject: [PATCH 2/5] blind: randomize secp256k1 SIGN context in Blind_ECC_Init Side-channel hardening: pass a fresh 32-byte GetStrongRandBytes seed to secp256k1_context_randomize immediately after context creation, matching the randomization of secp256k1_context_sign in key.cpp. No change to consensus behavior or key/signature formats. --- src/blind.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/blind.cpp b/src/blind.cpp index fc443d2977..67ffcb4059 100644 --- a/src/blind.cpp +++ b/src/blind.cpp @@ -22,6 +22,12 @@ class Blind_ECC_Init { secp256k1_context *ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY); assert(ctx != nullptr); + // Pass in a random blinding seed to the secp256k1 context (side-channel hardening, + // matching the randomization of secp256k1_context_sign in key.cpp). + unsigned char randseed[32]; + GetStrongRandBytes(randseed); + assert(secp256k1_context_randomize(ctx, randseed) == 1); + secp256k1_blind_context = ctx; } From 7aca7070a96a2fbfdb7c90202ac1c2a4b0e6c36b Mon Sep 17 00:00:00 2001 From: Byron Hambly Date: Tue, 1 Sep 2026 20:07:02 +0200 Subject: [PATCH 3/5] wallet: randomize secp256k1 SIGN contexts in CSecp256k1Init Side-channel hardening: blind each SIGN-capable secp256k1 context in the wallet with a fresh 32-byte GetRandBytes seed via secp256k1_context_randomize, mirroring key.cpp ECC_Start. Assert on null ctx and on a 0 randomize return. No consensus impact. --- src/wallet/rpc/backup.cpp | 6 ++++++ src/wallet/rpc/elements.cpp | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/wallet/rpc/backup.cpp b/src/wallet/rpc/backup.cpp index 67ffd6958f..548a4d0c07 100644 --- a/src/wallet/rpc/backup.cpp +++ b/src/wallet/rpc/backup.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include