mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-21 07:39:08 +01:00
First step in converting to C: num
This commit is contained in:
27
bench.cpp
27
bench.cpp
@@ -1,25 +1,29 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "num.h"
|
||||
#include "field.h"
|
||||
#include "group.h"
|
||||
#include "ecmult.h"
|
||||
#include "ecdsa.h"
|
||||
#include "num.cpp"
|
||||
#include "field.cpp"
|
||||
#include "group.cpp"
|
||||
#include "ecmult.cpp"
|
||||
#include "ecdsa.cpp"
|
||||
|
||||
using namespace secp256k1;
|
||||
|
||||
int main() {
|
||||
FieldElem x;
|
||||
const Number &order = GetGroupConst().order;
|
||||
Number r, s, m;
|
||||
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);
|
||||
Signature sig;
|
||||
x.SetHex("a357ae915c4a65281309edf20504740f0eb3343990216b4f81063cb65f2f7e0f");
|
||||
int cnt = 0;
|
||||
int good = 0;
|
||||
for (int i=0; i<1000000; i++) {
|
||||
r.SetPseudoRand(order);
|
||||
s.SetPseudoRand(order);
|
||||
m.SetPseudoRand(order);
|
||||
secp256k1_num_set_rand(&r, &order);
|
||||
secp256k1_num_set_rand(&s, &order);
|
||||
secp256k1_num_set_rand(&m, &order);
|
||||
sig.SetRS(r,s);
|
||||
GroupElemJac pubkey; pubkey.SetCompressed(x, true);
|
||||
if (pubkey.IsValid()) {
|
||||
@@ -28,5 +32,8 @@ int main() {
|
||||
}
|
||||
}
|
||||
printf("%i/%i\n", good, cnt);
|
||||
secp256k1_num_free(&r);
|
||||
secp256k1_num_free(&s);
|
||||
secp256k1_num_free(&m);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user