Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
bench_impl.h File Reference
#include "../include/secp256k1_recovery.h"
Include dependency graph for bench_impl.h:

Go to the source code of this file.

Classes

struct  bench_recover_data
 

Functions

void bench_recover (void *arg, int iters)
 
void bench_recover_setup (void *arg)
 
void run_recovery_bench (int iters, int argc, char **argv)
 

Function Documentation

◆ bench_recover()

void bench_recover ( void * arg,
int iters )

Definition at line 18 of file bench_impl.h.

18 {
19 int i;
22 unsigned char pubkeyc[33];
23
24 for (i = 0; i < iters; i++) {
25 int j;
26 size_t pubkeylen = 33;
28 CHECK(secp256k1_ecdsa_recoverable_signature_parse_compact(data->ctx, &sig, data->sig, i % 2));
29 CHECK(secp256k1_ecdsa_recover(data->ctx, &pubkey, &sig, data->msg));
30 CHECK(secp256k1_ec_pubkey_serialize(data->ctx, pubkeyc, &pubkeylen, &pubkey, SECP256K1_EC_COMPRESSED));
31 for (j = 0; j < 32; j++) {
32 data->sig[j + 32] = data->msg[j]; /* Move former message to S. */
33 data->msg[j] = data->sig[j]; /* Move former R to message. */
34 data->sig[j] = pubkeyc[j + 1]; /* Move recovered pubkey X coordinate to R (which must be a valid X coordinate). */
35 }
36 }
37}
#define CHECK(cond)
Definition util.h:80
SECP256K1_API int secp256k1_ec_pubkey_serialize(const secp256k1_context *ctx, unsigned char *output, size_t *outputlen, const secp256k1_pubkey *pubkey, unsigned int flags) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4)
Definition secp256k1.c:246
#define SECP256K1_EC_COMPRESSED
Definition secp256k1.h:201
SECP256K1_API int secp256k1_ecdsa_recoverable_signature_parse_compact(const secp256k1_context *ctx, secp256k1_ecdsa_recoverable_signature *sig, const unsigned char *input64, int recid) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
Definition main_impl.h:38
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ecdsa_recover(const secp256k1_context *ctx, secp256k1_pubkey *pubkey, const secp256k1_ecdsa_recoverable_signature *sig, const unsigned char *msghash32) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4)
Definition main_impl.h:137
uint16_t j
CK_BYTE_PTR pubkey
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bench_recover_setup()

void bench_recover_setup ( void * arg)

Definition at line 39 of file bench_impl.h.

39 {
40 int i;
42
43 for (i = 0; i < 32; i++) {
44 data->msg[i] = 1 + i;
45 }
46 for (i = 0; i < 64; i++) {
47 data->sig[i] = 65 + i;
48 }
49}
Here is the caller graph for this function:

◆ run_recovery_bench()

void run_recovery_bench ( int iters,
int argc,
char ** argv )

Definition at line 51 of file bench_impl.h.

51 {
53 int d = argc == 1;
54
56
57 if (d || have_flag(argc, argv, "ecdsa") || have_flag(argc, argv, "recover") || have_flag(argc, argv, "ecdsa_recover")) run_benchmark("ecdsa_recover", bench_recover, bench_recover_setup, NULL, &data, 10, iters);
58
60}
int have_flag(int argc, char **argv, char *flag)
Definition bench.h:116
void run_benchmark(char *name, void(*benchmark)(void *, int), void(*setup)(void *), void(*teardown)(void *, int), void *data, int count, int iter)
Definition bench.h:82
char ** argv
void bench_recover_setup(void *arg)
Definition bench_impl.h:39
void bench_recover(void *arg, int iters)
Definition bench_impl.h:18
SECP256K1_API void secp256k1_context_destroy(secp256k1_context *ctx) SECP256K1_ARG_NONNULL(1)
Definition secp256k1.c:146
SECP256K1_API secp256k1_context * secp256k1_context_create(unsigned int flags) SECP256K1_WARN_UNUSED_RESULT
Definition secp256k1.c:107
#define SECP256K1_CONTEXT_VERIFY
Definition secp256k1.h:195
CK_ULONG d
Here is the call graph for this function:
Here is the caller graph for this function: