0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-21 12:22:50 -05:00
bitcoin-bitcoin-core/bench.cpp

40 lines
1,014 B
C++
Raw Normal View History

2013-03-16 15:51:55 +01:00
#include <stdio.h>
2013-03-24 10:38:35 +01:00
#include "num.cpp"
#include "field.cpp"
#include "group.cpp"
#include "ecmult.cpp"
#include "ecdsa.cpp"
2013-03-16 15:51:55 +01:00
using namespace secp256k1;
int main() {
FieldElem x;
2013-03-24 10:38:35 +01:00
const secp256k1_num_t &order = GetGroupConst().order;
secp256k1_num_t r, s, m;
secp256k1_num_start();
secp256k1_num_init(&r);
secp256k1_num_init(&s);
secp256k1_num_init(&m);
2013-03-16 15:51:55 +01:00
Signature sig;
x.SetHex("a357ae915c4a65281309edf20504740f0eb3343990216b4f81063cb65f2f7e0f");
int cnt = 0;
int good = 0;
for (int i=0; i<1000000; i++) {
2013-03-24 10:38:35 +01:00
secp256k1_num_set_rand(&r, &order);
secp256k1_num_set_rand(&s, &order);
secp256k1_num_set_rand(&m, &order);
2013-03-16 15:51:55 +01:00
sig.SetRS(r,s);
GroupElemJac pubkey; pubkey.SetCompressed(x, true);
if (pubkey.IsValid()) {
cnt++;
good += sig.Verify(pubkey, m);
}
}
printf("%i/%i\n", good, cnt);
2013-03-24 10:38:35 +01:00
secp256k1_num_free(&r);
secp256k1_num_free(&s);
secp256k1_num_free(&m);
2013-03-16 15:51:55 +01:00
return 0;
}