Skip to content

Commit 1129ab7

Browse files
author
root
committed
fixing syntax - adjustment to schnorr examples
1 parent edb863d commit 1129ab7

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

examples/ecdh.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ int main(void) {
5151
return 1;
5252
}
5353
if (!secp256k1_ec_seckey_verify(ctx, seckey1) || !secp256k1_ec_seckey_verify(ctx, seckey2)) {
54+
printf("Generated secret key is invalid. This indicates an issue with the random number generator.\n");
5455
return 1;
5556
}
5657

examples/ecdsa.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ int main(void) {
5858
return 1;
5959
}
6060
if (!secp256k1_ec_seckey_verify(ctx, seckey)) {
61+
printf("Generated secret key is invalid. This indicates an issue with the random number generator.\n");
6162
return 1;
6263
}
6364

examples/ellswift.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ int main(void) {
5656
return 1;
5757
}
5858
if (!secp256k1_ec_seckey_verify(ctx, seckey1) || !secp256k1_ec_seckey_verify(ctx, seckey2)) {
59-
printf("Generated secret key is invalid. This could indicate an issue with the random number generator.\n")
59+
printf("Generated secret key is invalid. This indicates an issue with the random number generator.\n");
6060
return 1;
6161
}
6262

examples/schnorr.c

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,17 @@ int main(void) {
4545
/*** Key Generation ***/
4646

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

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

0 commit comments

Comments
 (0)