HomePhabricator

[secp256k1] ecmult_gen: Simplify ecmult_gen context after making table static

Description

[secp256k1] ecmult_gen: Simplify ecmult_gen context after making table static

Summary:
This is a backwards-compatible API change: Before this commit, a context
initialized for signing was required to call functions that rely on
ecmult_gen. After this commit, this is no longer necessary because the
static ecmult_gen table is always present. In practice this means that
the corresponding functions will just work instead of calling the
illegal callback when given a context which is not (officially)
initialized for signing.

This is in line with 6815761, which made the analogous change with
respect to ecmult and contexts initialized for signing. But as opposed
to 681571, which removed the ecmult context entirely, we cannot remove
the ecmult_gen context entirely because it is still used for random
blinding. Moreover, since the secp256k1_context_no_precomp context is
const and cannot meaningfully support random blinding, we refrain (for
now) from changing its API, i.e., the illegal callback will still be
called when trying to use ecmult_gen operations with the static
secp256k1_context_no_precomp context.

This is a partial backport of secp256k1#988
https://github.com/bitcoin-core/secp256k1/pull/988/commits/3b0c2185eab0fe5cb910fffee4c88e134f6d3cad

Depends on D19383

Test Plan: ninja check-secp256k1

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D19384

Details

Provenance
Tim Ruffing <crypto@timruffing.de>Authored on Nov 9 2021, 09:17
PiRKCommitted on Jan 20 2026, 10:10
PiRKPushed on Jan 20 2026, 10:10
Reviewer
Restricted Project
Differential Revision
D19384: [secp256k1] ecmult_gen: Simplify ecmult_gen context after making table static
Parents
rABC93fa895b445e: [secp256k1] refactor: Decouple table generation and ecmult_gen context
Branches
Unknown
Tags
Unknown