20 {
21 unsigned char msg[12] = "Hello World!";
22 unsigned char msg_hash[32];
23 unsigned char tag[17] = "my_fancy_protocol";
24 unsigned char seckey[32];
25 unsigned char randomize[32];
26 unsigned char auxiliary_rand[32];
27 unsigned char serialized_pubkey[32];
29 int is_signature_valid;
30 int return_val;
33
34
35
36
37
39 if (!fill_random(randomize, sizeof(randomize))) {
40 printf(
"Failed to generate randomness\n");
41 return 1;
42 }
43
44
45
47 assert(return_val);
48
49
50
51
52
53
54 while (1) {
55 if (!fill_random(seckey, sizeof(seckey))) {
56 printf(
"Failed to generate randomness\n");
57 return 1;
58 }
59
60
62 break;
63 }
64 }
65
66
67
68
69
70
72 assert(return_val);
73
74
76 assert(return_val);
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
95 assert(return_val);
96
97
98 if (!fill_random(auxiliary_rand, sizeof(auxiliary_rand))) {
99 printf(
"Failed to generate randomness\n");
100 return 1;
101 }
102
103
104
105
106
107
108
109
110
112 assert(return_val);
113
114
115
116
117
119 printf(
"Failed parsing the public key\n");
120 return 1;
121 }
122
123
125 assert(return_val);
126
127
129
130
131 printf(
"Is the signature valid? %s\n", is_signature_valid ?
"true" :
"false");
133 print_hex(seckey, sizeof(seckey));
135 print_hex(serialized_pubkey, sizeof(serialized_pubkey));
137 print_hex(signature, sizeof(signature));
138
139
141
142
143
144
145
146
147
148
149 memset(seckey, 0,
sizeof(seckey));
150
151 return 0;
152}
LOGGING_API void printf(Category category, const char *format,...)
fc::array< char, 72 > signature
SECP256K1_API void secp256k1_context_destroy(secp256k1_context *ctx) SECP256K1_ARG_NONNULL(1)
#define SECP256K1_CONTEXT_SIGN
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_context_randomize(secp256k1_context *ctx, const unsigned char *seed32) SECP256K1_ARG_NONNULL(1)
SECP256K1_API secp256k1_context * secp256k1_context_create(unsigned int flags) SECP256K1_WARN_UNUSED_RESULT
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_tagged_sha256(const secp256k1_context *ctx, unsigned char *hash32, const unsigned char *tag, size_t taglen, const unsigned char *msg, size_t msglen) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(5)
#define SECP256K1_CONTEXT_VERIFY
SECP256K1_API int secp256k1_schnorrsig_sign32(const secp256k1_context *ctx, unsigned char *sig64, const unsigned char *msg32, const secp256k1_keypair *keypair, const unsigned char *aux_rand32) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4)
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_schnorrsig_verify(const secp256k1_context *ctx, const unsigned char *sig64, const unsigned char *msg, size_t msglen, const secp256k1_xonly_pubkey *pubkey) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(5)
memset(pInfo->slotDescription, ' ', 64)