secp: context randomize in a few places - #1594
Open
delta1 wants to merge 6 commits into
Open
Conversation
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.
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.
The wallet Schnorr-signing path passed uint256{} (all-zero) as aux_rnd, a
side-channel/key-reuse hazard. Draw a fresh strong-random aux_rnd per sign.
Adjust the upstream BIP341 key-path vector test to sign deterministically via
key.SignSchnorr with the zero aux the vectors encode, since CreateSchnorrSig
randomness makes exact-hex reproduction impossible.
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a few instances of
secp256k1_context_randomizein areas where we are using the secp context