Skip to content

Commit 316ac76

Browse files
contexts: Deprecate all context flags except SECP256K1_CONTEXT_NONE
1 parent 1a553ee commit 316ac76

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

doc/CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ Each change falls into one of the following categories: Added, Changed, Deprecat
99
### Changed
1010
- Enable modules schnorrsig, extrakeys and ECDH by default in ./configure
1111

12+
### Deprecated
13+
- Deprecated context flags `SECP256K1_CONTEXT_VERIFY` and `SECP256K1_CONTEXT_SIGN`. Use `SECP256K1_CONTEXT_NONE` instead.
14+
1215
## [MAJOR.MINOR.PATCH] - YYYY-MM-DD
1316

1417
### Added/Changed/Deprecated/Removed/Fixed/Security

include/secp256k1.h

+16-10
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,13 @@ extern "C" {
2424
* 5. Opaque data pointers follow the function pointer they are to be passed to.
2525
*/
2626

27-
/** Opaque data structure that holds context information (precomputed tables etc.).
27+
/** Opaque data structure that holds context information
2828
*
29-
* The purpose of context structures is to cache large precomputed data tables
30-
* that are expensive to construct, and also to maintain the randomization data
31-
* for blinding.
29+
* The purpose of context structures is to store the randomization data for
30+
* blinding, see secp256k1_context_randomize.
3231
*
3332
* Do not create a new context object for each operation, as construction is
34-
* far slower than all other API calls (~100 times slower than an ECDSA
35-
* verification).
33+
* far slower than all other API calls.
3634
*
3735
* A constructed context can safely be used from multiple threads
3836
* simultaneously, but API calls that take a non-const pointer to a context
@@ -194,12 +192,16 @@ typedef int (*secp256k1_nonce_function)(
194192
#define SECP256K1_FLAGS_BIT_CONTEXT_DECLASSIFY (1 << 10)
195193
#define SECP256K1_FLAGS_BIT_COMPRESSION (1 << 8)
196194

197-
/** Flags to pass to secp256k1_context_create, secp256k1_context_preallocated_size, and
195+
/** Context flags to pass to secp256k1_context_create, secp256k1_context_preallocated_size, and
198196
* secp256k1_context_preallocated_create. */
197+
#define SECP256K1_CONTEXT_NONE (SECP256K1_FLAGS_TYPE_CONTEXT)
198+
199+
/** Deprecated context flags. These flags are treated equivalent to SECP256K1_CONTEXT_NONE. */
199200
#define SECP256K1_CONTEXT_VERIFY (SECP256K1_FLAGS_TYPE_CONTEXT | SECP256K1_FLAGS_BIT_CONTEXT_VERIFY)
200201
#define SECP256K1_CONTEXT_SIGN (SECP256K1_FLAGS_TYPE_CONTEXT | SECP256K1_FLAGS_BIT_CONTEXT_SIGN)
202+
203+
/* Testing flag. Do not use. */
201204
#define SECP256K1_CONTEXT_DECLASSIFY (SECP256K1_FLAGS_TYPE_CONTEXT | SECP256K1_FLAGS_BIT_CONTEXT_DECLASSIFY)
202-
#define SECP256K1_CONTEXT_NONE (SECP256K1_FLAGS_TYPE_CONTEXT)
203205

204206
/** Flag to pass to secp256k1_ec_pubkey_serialize. */
205207
#define SECP256K1_EC_COMPRESSED (SECP256K1_FLAGS_TYPE_COMPRESSION | SECP256K1_FLAGS_BIT_COMPRESSION)
@@ -226,9 +228,13 @@ SECP256K1_API extern const secp256k1_context *secp256k1_context_no_precomp;
226228
* memory allocation entirely, see the functions in secp256k1_preallocated.h.
227229
*
228230
* Returns: a newly created context object.
229-
* In: flags: which parts of the context to initialize.
231+
* In: flags: Always set to SECP256K1_CONTEXT_NONE (see below).
230232
*
231-
* See also secp256k1_context_randomize.
233+
* The only valid non-deprecated flag in recent library versions is
234+
* SECP256K1_CONTEXT_NONE, which will create a context sufficient for all functionality
235+
* offered by the library. All other (deprecated) flags will be treated as equivalent
236+
* to the SECP256K1_CONTEXT_NONE flag. Though the flags parameter primarily exists for
237+
* historical reasons, future versions of the library may introduce new flags.
232238
*/
233239
SECP256K1_API secp256k1_context* secp256k1_context_create(
234240
unsigned int flags

include/secp256k1_preallocated.h

+2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ SECP256K1_API size_t secp256k1_context_preallocated_size(
5858
* bytes, as detailed above.
5959
* flags: which parts of the context to initialize.
6060
*
61+
* See secp256k1_context_create (in secp256k1.h) for further details.
62+
*
6163
* See also secp256k1_context_randomize (in secp256k1.h)
6264
* and secp256k1_context_preallocated_destroy.
6365
*/

0 commit comments

Comments
 (0)