Skip to content

Commit

Permalink
fixing syntax - adjustment to schnorr examples
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Sep 3, 2024
1 parent edb863d commit 1129ab7
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
1 change: 1 addition & 0 deletions examples/ecdh.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ int main(void) {
return 1;
}
if (!secp256k1_ec_seckey_verify(ctx, seckey1) || !secp256k1_ec_seckey_verify(ctx, seckey2)) {
printf("Generated secret key is invalid. This indicates an issue with the random number generator.\n");
return 1;
}

Expand Down
1 change: 1 addition & 0 deletions examples/ecdsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ int main(void) {
return 1;
}
if (!secp256k1_ec_seckey_verify(ctx, seckey)) {
printf("Generated secret key is invalid. This indicates an issue with the random number generator.\n");
return 1;
}

Expand Down
2 changes: 1 addition & 1 deletion examples/ellswift.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ int main(void) {
return 1;
}
if (!secp256k1_ec_seckey_verify(ctx, seckey1) || !secp256k1_ec_seckey_verify(ctx, seckey2)) {
printf("Generated secret key is invalid. This could indicate an issue with the random number generator.\n")
printf("Generated secret key is invalid. This indicates an issue with the random number generator.\n");
return 1;
}

Expand Down
23 changes: 11 additions & 12 deletions examples/schnorr.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,17 @@ int main(void) {
/*** Key Generation ***/

/* If the secret key is zero or out of range (bigger than secp256k1's
* order), we try to sample a new key. Note that the probability of this
* happening is negligible. */
while (1) {
if (!fill_random(seckey, sizeof(seckey))) {
printf("Failed to generate randomness\n");
return 1;
}
/* Try to create a keypair with a valid context, it should only fail if
* the secret key is zero or out of range. */
if (secp256k1_keypair_create(ctx, &keypair, seckey)) {
break;
}
* order), we return 1. Note that the probability of this
* happening is negligible, though it could indicate a faulty RNG */
if (!fill_random(seckey, sizeof(seckey))) {
printf("Failed to generate randomness\n");
return 1;
}
/* Try to create a keypair with a valid context, it should only fail if
* the secret key is zero or out of range. */
if (secp256k1_keypair_create(ctx, &keypair, seckey)) {
printf("Generated secret key is invalid. This indicates an issue with the random number generator.\n");
return 1;
}

/* Extract the X-only public key from the keypair. We pass NULL for
Expand Down

0 comments on commit 1129ab7

Please sign in to comment.