8
8
*************************************************************************/
9
9
10
10
#include <stdio.h>
11
+ #include <stdlib.h>
11
12
#include <assert.h>
12
13
#include <string.h>
13
14
@@ -34,7 +35,7 @@ int main(void) {
34
35
secp256k1_context * ctx = secp256k1_context_create (SECP256K1_CONTEXT_NONE );
35
36
if (!fill_random (randomize , sizeof (randomize ))) {
36
37
printf ("Failed to generate randomness\n" );
37
- return 1 ;
38
+ return EXIT_FAILURE ;
38
39
}
39
40
/* Randomizing the context is recommended to protect against side-channel
40
41
* leakage See `secp256k1_context_randomize` in secp256k1.h for more
@@ -45,15 +46,15 @@ int main(void) {
45
46
/*** Key Generation ***/
46
47
if (!fill_random (seckey , sizeof (seckey ))) {
47
48
printf ("Failed to generate randomness\n" );
48
- return 1 ;
49
+ return EXIT_FAILURE ;
49
50
}
50
51
/* Try to create a keypair with a valid context. This only fails if the
51
52
* secret key is zero or out of range (greater than secp256k1's order). Note
52
53
* that the probability of this occurring is negligible with a properly
53
54
* functioning random number generator. */
54
55
if (!secp256k1_keypair_create (ctx , & keypair , seckey )) {
55
56
printf ("Generated secret key is invalid. This indicates an issue with the random number generator.\n" );
56
- return 1 ;
57
+ return EXIT_FAILURE ;
57
58
}
58
59
59
60
/* Extract the X-only public key from the keypair. We pass NULL for
@@ -90,7 +91,7 @@ int main(void) {
90
91
/* Generate 32 bytes of randomness to use with BIP-340 schnorr signing. */
91
92
if (!fill_random (auxiliary_rand , sizeof (auxiliary_rand ))) {
92
93
printf ("Failed to generate randomness\n" );
93
- return 1 ;
94
+ return EXIT_FAILURE ;
94
95
}
95
96
96
97
/* Generate a Schnorr signature.
@@ -110,7 +111,7 @@ int main(void) {
110
111
* be parsed correctly */
111
112
if (!secp256k1_xonly_pubkey_parse (ctx , & pubkey , serialized_pubkey )) {
112
113
printf ("Failed parsing the public key\n" );
113
- return 1 ;
114
+ return EXIT_FAILURE ;
114
115
}
115
116
116
117
/* Compute the tagged hash on the received messages using the same tag as the signer. */
@@ -149,5 +150,5 @@ int main(void) {
149
150
* Here we are preventing these writes from being optimized out, as any good compiler
150
151
* will remove any writes that aren't used. */
151
152
secure_erase (seckey , sizeof (seckey ));
152
- return 0 ;
153
+ return EXIT_SUCCESS ;
153
154
}
0 commit comments