Skip to content

secp: context randomize in a few places - #1594

Open
delta1 wants to merge 5 commits into
ElementsProject:masterfrom
delta1:2026-09-secp-fixes
Open

secp: context randomize in a few places #1594
delta1 wants to merge 5 commits into
ElementsProject:masterfrom
delta1:2026-09-secp-fixes

Conversation

@delta1

@delta1 delta1 commented Sep 2, 2026

Copy link
Copy Markdown
Member

Adds a few instances of secp256k1_context_randomize in areas where we are using the secp context

@apoelstra

Copy link
Copy Markdown
Member

utACK. Only reviewed the total diff in the Github UI. It's a worthwhile change IMHO. But I assume you weighed this defense-in-depth against causing potential rebase conflicts.

@delta1
delta1 force-pushed the 2026-09-secp-fixes branch from 93d2387 to 97ca39d Compare September 3, 2026 06:32
@delta1

delta1 commented Sep 3, 2026

Copy link
Copy Markdown
Member Author

Dropped the commit adding aux_rand to schnorr sign since upstream does that intentionally. Also fixed lint CI by not asserting in RPC code

Comment thread src/pegins.cpp Outdated
Comment thread src/CMakeLists.txt Outdated
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.
@delta1
delta1 force-pushed the 2026-09-secp-fixes branch from 97ca39d to 0b87696 Compare September 3, 2026 14:00
@apoelstra

Copy link
Copy Markdown
Member

utACK 0b87696 -- though I guess the transition to SECP256K1_CONTEXT_NONE ought to happen everywhere. I guess upstream will do it and we can pull it in.

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.
Force BPPP, ECDSA_ADAPTOR, ECDSA_S2C, and SCHNORRSIG_HALFAGG OFF alongside
the existing MUSIG OFF in src/CMakeLists.txt. These experimental modules
default to ON in libsecp256k1's CMake but have zero references in the Elements
tree; building them is dead code that enlarges the binary and attack surface.
Genuinely used modules (ECDH, RECOVERY, EXTRAKEYS, SCHNORRSIG, ELLSWIFT,
GENERATOR, RANGEPROOF, SURJECTIONPROOF, WHITELIST) remain enabled.
@delta1
delta1 force-pushed the 2026-09-secp-fixes branch from 0b87696 to 72a88d4 Compare September 4, 2026 15:34
@delta1

delta1 commented Sep 4, 2026

Copy link
Copy Markdown
Member Author

Apologies for the force push, it was necessary to fix the failing windows CI job.

It changed GetRandBytes for GetStrongRandBytes, which is the correct function to use anyway

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.

2 participants