48 {
49 int i;
52
55 data.pk = (const unsigned char **)malloc(iters * sizeof(unsigned char *));
56 data.msgs = (const unsigned char **)malloc(iters * sizeof(unsigned char *));
57 data.sigs = (const unsigned char **)malloc(iters * sizeof(unsigned char *));
58
60 for (i = 0; i < iters; i++) {
61 unsigned char sk[32];
62 unsigned char *msg = (
unsigned char *)malloc(
MSGLEN);
63 unsigned char *sig = (unsigned char *)malloc(64);
65 unsigned char *pk_char = (unsigned char *)malloc(32);
67 msg[0] = sk[0] = i;
68 msg[1] = sk[1] = i >> 8;
69 msg[2] = sk[2] = i >> 16;
70 msg[3] = sk[3] = i >> 24;
73
74 data.keypairs[i] = keypair;
75 data.pk[i] = pk_char;
76 data.msgs[i] = msg;
77 data.sigs[i] = sig;
78
83 }
84
85 if (d ||
have_flag(argc,
argv,
"schnorrsig") ||
have_flag(argc,
argv,
"sign") ||
have_flag(argc,
argv,
"schnorrsig_sign"))
run_benchmark(
"schnorrsig_sign",
bench_schnorrsig_sign, NULL, NULL, (
void *) &data, 10, iters);
86 if (d ||
have_flag(argc,
argv,
"schnorrsig") ||
have_flag(argc,
argv,
"verify") ||
have_flag(argc,
argv,
"schnorrsig_verify"))
run_benchmark(
"schnorrsig_verify",
bench_schnorrsig_verify, NULL, NULL, (
void *) &data, 10, iters);
87
88 for (i = 0; i < iters; i++) {
89 free((void *)data.keypairs[i]);
90 free((void *)data.pk[i]);
91 free((void *)data.msgs[i]);
92 free((void *)data.sigs[i]);
93 }
94 free(data.keypairs);
95 free(data.pk);
96 free(data.msgs);
97 free(data.sigs);
98
100}
int have_flag(int argc, char **argv, char *flag)
void run_benchmark(char *name, void(*benchmark)(void *, int), void(*setup)(void *), void(*teardown)(void *, int), void *data, int count, int iter)
void bench_schnorrsig_sign(void *arg, int iters)
void bench_schnorrsig_verify(void *arg, int iters)
SECP256K1_API void secp256k1_context_destroy(secp256k1_context *ctx) SECP256K1_ARG_NONNULL(1)
#define SECP256K1_CONTEXT_SIGN
SECP256K1_API secp256k1_context * secp256k1_context_create(unsigned int flags) SECP256K1_WARN_UNUSED_RESULT
#define SECP256K1_CONTEXT_VERIFY
memset(pInfo->slotDescription, ' ', 64)