2013-03-05 01:29:08 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2013-03-08 01:20:41 +01:00
|
|
|
#include "num.h"
|
|
|
|
#include "field.h"
|
|
|
|
#include "group.h"
|
2013-03-08 02:52:50 +01:00
|
|
|
#include "ecmult.h"
|
2013-03-10 05:34:04 +01:00
|
|
|
#include "ecdsa.h"
|
2013-03-05 01:29:08 +01:00
|
|
|
|
|
|
|
using namespace secp256k1;
|
|
|
|
|
|
|
|
int main() {
|
2013-03-08 00:23:52 +01:00
|
|
|
Context ctx;
|
2013-03-10 06:55:46 +01:00
|
|
|
FieldElem x;
|
2013-03-10 04:24:00 +01:00
|
|
|
const Number &order = GetGroupConst().order;
|
2013-03-10 06:55:46 +01:00
|
|
|
Number r(ctx), s(ctx), m(ctx);
|
|
|
|
Signature sig(ctx);
|
|
|
|
x.SetHex("a357ae915c4a65281309edf20504740f0eb3343990216b4f81063cb65f2f7e0f");
|
|
|
|
int cnt = 0;
|
|
|
|
int good = 0;
|
2013-03-10 04:24:00 +01:00
|
|
|
for (int i=0; i<1000000; i++) {
|
2013-03-10 06:55:46 +01:00
|
|
|
// ECMult(ctx, a, a, an, gn);
|
2013-03-10 04:24:00 +01:00
|
|
|
// an.SetModMul(ctx, af, order);
|
|
|
|
// gn.SetModMul(ctx, gf, order);
|
2013-03-10 06:55:46 +01:00
|
|
|
// an.Inc();
|
|
|
|
// gn.Inc();
|
|
|
|
r.SetPseudoRand(order);
|
|
|
|
s.SetPseudoRand(order);
|
|
|
|
if (i == 0)
|
|
|
|
x.SetSquare(x);
|
|
|
|
m.SetPseudoRand(order);
|
|
|
|
sig.SetRS(r,s);
|
|
|
|
GroupElemJac pubkey; pubkey.SetCompressed(x, true);
|
|
|
|
if (pubkey.IsValid()) {
|
|
|
|
cnt++;
|
|
|
|
good += sig.Verify(ctx, pubkey, m);
|
|
|
|
}
|
2013-03-10 01:49:42 +01:00
|
|
|
}
|
2013-03-10 06:55:46 +01:00
|
|
|
printf("%i/%i\n", good, cnt);
|
2013-03-05 01:29:08 +01:00
|
|
|
return 0;
|
|
|
|
}
|