1 /***********************************************************************
2 * Copyright (c) 2014 Pieter Wuille *
3 * Distributed under the MIT software license, see the accompanying *
4 * file COPYING or https://www.opensource.org/licenses/mit-license.php.*
5 ***********************************************************************/
7 #include "../include/secp256k1.h"
12 secp256k1_context* ctx;
13 unsigned char msg[32];
14 unsigned char key[32];
17 static void bench_sign_setup(void* arg) {
19 bench_sign_data *data = (bench_sign_data*)arg;
21 for (i = 0; i < 32; i++) {
24 for (i = 0; i < 32; i++) {
25 data->key[i] = i + 65;
29 static void bench_sign_run(void* arg, int iters) {
31 bench_sign_data *data = (bench_sign_data*)arg;
33 unsigned char sig[74];
34 for (i = 0; i < iters; i++) {
37 secp256k1_ecdsa_signature signature;
38 CHECK(secp256k1_ecdsa_sign(data->ctx, &signature, data->msg, data->key, NULL, NULL));
39 CHECK(secp256k1_ecdsa_signature_serialize_der(data->ctx, sig, &siglen, &signature));
40 for (j = 0; j < 32; j++) {
41 data->msg[j] = sig[j];
42 data->key[j] = sig[j + 32];
50 int iters = get_iters(20000);
52 data.ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN);
54 run_benchmark("ecdsa_sign", bench_sign_run, bench_sign_setup, NULL, &data, 10, iters);
56 secp256k1_context_destroy(data.ctx);