1 /**********************************************************************
2 * Copyright (c) 2014 Pieter Wuille *
3 * Distributed under the MIT software license, see the accompanying *
4 * file COPYING or http://www.opensource.org/licenses/mit-license.php.*
5 **********************************************************************/
7 #include "include/secp256k1.h"
12 secp256k1_context_t* ctx;
13 unsigned char msg[32];
14 unsigned char key[32];
17 static void bench_sign_setup(void* arg) {
19 bench_sign_t *data = (bench_sign_t*)arg;
21 for (i = 0; i < 32; i++) data->msg[i] = i + 1;
22 for (i = 0; i < 32; i++) data->key[i] = i + 65;
25 static void bench_sign(void* arg) {
27 bench_sign_t *data = (bench_sign_t*)arg;
29 unsigned char sig[64];
30 for (i = 0; i < 20000; i++) {
33 secp256k1_ecdsa_signature_t signature;
34 CHECK(secp256k1_ecdsa_sign(data->ctx, data->msg, &signature, data->key, NULL, NULL));
35 CHECK(secp256k1_ecdsa_signature_serialize_compact(data->ctx, sig, &recid, &signature));
36 for (j = 0; j < 32; j++) {
37 data->msg[j] = sig[j]; /* Move former R to message. */
38 data->key[j] = sig[j + 32]; /* Move former S to key. */
46 data.ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN);
48 run_benchmark("ecdsa_sign", bench_sign, bench_sign_setup, NULL, &data, 10, 20000);
50 secp256k1_context_destroy(data.ctx);