7#ifndef SECP256K1_MODULE_SCHNORRSIG_BENCH_H
8#define SECP256K1_MODULE_SCHNORRSIG_BENCH_H
10#include "../../../include/secp256k1_schnorrsig.h"
19 const unsigned char **
pk;
20 const unsigned char **
sigs;
21 const unsigned char **
msgs;
28 unsigned char sig[64];
30 for (i = 0; i < iters; i++) {
41 for (i = 0; i < iters; i++) {
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 *));
60 for (i = 0; i < iters; i++) {
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);
68 msg[1] = sk[1] = i >> 8;
69 msg[2] = sk[2] = i >> 16;
70 msg[3] = sk[3] = i >> 24;
72 memset(&sk[4],
's', 28);
74 data.keypairs[i] = keypair;
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);
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]);
96 free((
void *)
data.keypairs);
97 free((
void *)
data.pk);
98 free((
void *)
data.msgs);
99 free((
void *)
data.sigs);
static void run_benchmark(char *name, void(*benchmark)(void *), void(*setup)(void *), void(*teardown)(void *), void *data, int count, int iter)
#define CHECK(cond)
Unconditional failure on condition failure.
static void bench_schnorrsig_sign(void *arg, int iters)
static void run_schnorrsig_bench(int iters, int argc, char **argv)
static void bench_schnorrsig_verify(void *arg, int iters)
static int have_flag(int argc, char **argv, char *flag)
SECP256K1_API void secp256k1_context_destroy(secp256k1_context *ctx) SECP256K1_ARG_NONNULL(1)
Destroy a secp256k1 context object (created in dynamically allocated memory).
SECP256K1_API secp256k1_context * secp256k1_context_create(unsigned int flags) SECP256K1_WARN_UNUSED_RESULT
Create a secp256k1 context object (in dynamically allocated memory).
#define SECP256K1_CONTEXT_NONE
Context flags to pass to secp256k1_context_create, secp256k1_context_preallocated_size,...
SECP256K1_API int secp256k1_schnorrsig_sign_custom(const secp256k1_context *ctx, unsigned char *sig64, const unsigned char *msg, size_t msglen, const secp256k1_keypair *keypair, secp256k1_schnorrsig_extraparams *extraparams) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(5)
Create a Schnorr signature with a more flexible API.
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)
Verify a Schnorr signature.
const unsigned char ** sigs
const unsigned char ** pk
const unsigned char ** msgs
const secp256k1_keypair ** keypairs
Opaque data structure that holds a keypair consisting of a secret and a public key.
Opaque data structure that holds a parsed and valid "x-only" public key.