You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/** Opaque data structure that holds context information (precomputed tables etc.).
*
* The purpose of context structures is to cache large precomputed data tables
* that are expensive to construct, and also to maintain the randomization data
* for blinding.
*
* Do not create a new context object for each operation, as construction is
* far slower than all other API calls (~100 times slower than an ECDSA
* verification).
*
* A constructed context can safely be used from multiple threads
* simultaneously, but API call that take a non-const pointer to a context
* need exclusive access to it. In particular this is the case for
* secp256k1_context_destroy and secp256k1_context_randomize.
*
* Regarding randomization, either do it once at creation time (in which case
* you do not need any locking for the other calls), or use a read-write lock.
*/
typedef struct secp256k1_context_struct secp256k1_context;
In bitshares_fmt_plug.c, electrum_fmt_plug.c, opencl_electrum_modern_fmt_plug.c, we currently recreate the context for each use. We should optimize these formats to use either one shared context structure, or per-thread ones, but not recreated/destroyed each time.
The text was updated successfully, but these errors were encountered:
OTOH, in all of those places we use SECP256K1_CONTEXT_NONE, which may skip much of the initialization, and maybe our uses are such that they don't require nor trigger further initialization. If so, the performance impact may not be that bad, but following the comment's advice is probably desirable anyway.
A comment in
secp256k1/secp256k1.h
says:In
bitshares_fmt_plug.c
,electrum_fmt_plug.c
,opencl_electrum_modern_fmt_plug.c
, we currently recreate the context for each use. We should optimize these formats to use either one shared context structure, or per-thread ones, but not recreated/destroyed each time.The text was updated successfully, but these errors were encountered: