Skip to content

Commit 92e7293

Browse files
examples: Switch to DEFAULT contexts
1 parent 507dcba commit 92e7293

File tree

3 files changed

+6
-18
lines changed

3 files changed

+6
-18
lines changed

examples/ecdh.c

+2-6
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,8 @@ int main(void) {
3030
secp256k1_pubkey pubkey1;
3131
secp256k1_pubkey pubkey2;
3232

33-
/* The specification in secp256k1.h states that `secp256k1_ec_pubkey_create`
34-
* needs a context object initialized for signing, which is why we create
35-
* a context with the SECP256K1_CONTEXT_SIGN flag.
36-
* (The docs for `secp256k1_ecdh` don't require any special context, just
37-
* some initialized context) */
38-
secp256k1_context* ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN);
33+
/* Before we can call actual API functions, we need to create a "context". */
34+
secp256k1_context* ctx = secp256k1_context_create(SECP256K1_CONTEXT_DEFAULT);
3935
if (!fill_random(randomize, sizeof(randomize))) {
4036
printf("Failed to generate randomness\n");
4137
return 1;

examples/ecdsa.c

+2-6
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,8 @@ int main(void) {
3838
int return_val;
3939
secp256k1_pubkey pubkey;
4040
secp256k1_ecdsa_signature sig;
41-
/* The specification in secp256k1.h states that `secp256k1_ec_pubkey_create` needs
42-
* a context object initialized for signing and `secp256k1_ecdsa_verify` needs
43-
* a context initialized for verification, which is why we create a context
44-
* for both signing and verification with the SECP256K1_CONTEXT_SIGN and
45-
* SECP256K1_CONTEXT_VERIFY flags. */
46-
secp256k1_context* ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY);
41+
/* Before we can call actual API functions, we need to create a "context". */
42+
secp256k1_context* ctx = secp256k1_context_create(SECP256K1_CONTEXT_DEFAULT);
4743
if (!fill_random(randomize, sizeof(randomize))) {
4844
printf("Failed to generate randomness\n");
4945
return 1;

examples/schnorr.c

+2-6
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,8 @@ int main(void) {
3030
int return_val;
3131
secp256k1_xonly_pubkey pubkey;
3232
secp256k1_keypair keypair;
33-
/* The specification in secp256k1_extrakeys.h states that `secp256k1_keypair_create`
34-
* needs a context object initialized for signing. And in secp256k1_schnorrsig.h
35-
* they state that `secp256k1_schnorrsig_verify` needs a context initialized for
36-
* verification, which is why we create a context for both signing and verification
37-
* with the SECP256K1_CONTEXT_SIGN and SECP256K1_CONTEXT_VERIFY flags. */
38-
secp256k1_context* ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY);
33+
/* Before we can call actual API functions, we need to create a "context". */
34+
secp256k1_context* ctx = secp256k1_context_create(SECP256K1_CONTEXT_DEFAULT);
3935
if (!fill_random(randomize, sizeof(randomize))) {
4036
printf("Failed to generate randomness\n");
4137
return 1;

0 commit comments

Comments
 (0)