@@ -214,20 +214,42 @@ typedef int (*secp256k1_nonce_function)(
214
214
#define SECP256K1_TAG_PUBKEY_HYBRID_EVEN 0x06
215
215
#define SECP256K1_TAG_PUBKEY_HYBRID_ODD 0x07
216
216
217
- /** A built-in constant secp256k1 context object with static storage duration.
217
+ /** A built-in constant secp256k1 context object with static storage duration, to be
218
+ * used in conjunction with secp256k1_selftest.
218
219
*
219
220
* This context object offers *only limited functionality* , i.e., it cannot be used
220
221
* for API functions that perform computations involving secret keys, e.g., signing
221
222
* and public key generation. If this restriction applies to a specific API function,
222
223
* it is mentioned in its documentation. See secp256k1_context_create if you need a
223
224
* full context object that supports all functionality offered by the library.
225
+ *
226
+ * It is highly recommended to call secp256k1_selftest before using this context.
224
227
*/
225
228
SECP256K1_API extern const secp256k1_context * secp256k1_context_static ;
226
229
227
230
/** Deprecated alias for secp256k1_context_static. */
228
231
SECP256K1_API extern const secp256k1_context * secp256k1_context_no_precomp
229
232
SECP256K1_DEPRECATED ("Use secp256k1_context_static instead" );
230
233
234
+ /** Perform basic self tests (to be used in conjunction with secp256k1_context_static)
235
+ *
236
+ * This function performs self tests that detect some serious usage errors and
237
+ * similar conditions, e.g., when the library is compiled for the wrong endianness.
238
+ * This is a last resort measure to be used in production. The performed tests are
239
+ * very rudimentary and are not intended as a replacement for running the test
240
+ * binaries.
241
+ *
242
+ * It is highly recommended to call this before using secp256k1_context_static.
243
+ * It is not necessary to call this function before using a context created with
244
+ * secp256k1_context_create (or secp256k1_context_preallocated_create), which will
245
+ * take care of performing the self tests.
246
+ *
247
+ * If the tests fail, this function will call the default error handler to abort the
248
+ * program (see secp256k1_context_set_error_callback).
249
+ */
250
+ SECP256K1_API void secp256k1_selftest (void );
251
+
252
+
231
253
/** Create a secp256k1 context object (in dynamically allocated memory).
232
254
*
233
255
* This function uses malloc to allocate memory. It is guaranteed that malloc is
0 commit comments