secp256k1-zkp/src/bench.c

28 lines
1.1 KiB
C
Raw Normal View History

2013-05-05 00:21:03 +02:00
// Copyright (c) 2013 Pieter Wuille
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
2013-03-16 15:51:55 +01:00
#include <stdio.h>
2014-09-29 08:20:07 +02:00
#include "include/secp256k1.h"
#include "util_impl.h"
2013-04-20 23:34:41 +02:00
2013-03-16 15:51:55 +01:00
int main() {
2014-09-29 08:20:07 +02:00
secp256k1_start(SECP256K1_START_VERIFY);
2013-03-30 22:32:16 +01:00
2013-03-16 15:51:55 +01:00
int good = 0;
2014-09-29 08:20:07 +02:00
unsigned char pubkey[33] = {0x02,0x1f,0x98,0xb7,0x3c,0xbd,0xd4,0x06,0xf3,0x49,0xa9,0x6c,0x2d,0xcb,0x7a,0xf7,0x01,0xe0,0xbd,0x07,0xdf,0xe9,0x17,0xae,0x0e,0x43,0x85,0x63,0xf0,0xff,0x7b,0xab,0x2f};
2013-03-16 15:51:55 +01:00
for (int i=0; i<1000000; i++) {
2014-09-29 08:20:07 +02:00
unsigned char msg[32];
secp256k1_rand256(msg);
unsigned char sig[72] = {0x30, 0x44, 0x02, 0x20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x02, 0x20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
secp256k1_rand256(sig + 4);
secp256k1_rand256(sig + 38);
good += secp256k1_ecdsa_verify(msg, 32, sig, 72, pubkey, 33);
}
printf("%i\n", good);
2013-03-30 22:32:16 +01:00
2014-09-29 08:20:07 +02:00
secp256k1_stop();
2013-03-16 15:51:55 +01:00
return 0;
}