-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.c
79 lines (73 loc) · 1.81 KB
/
test.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include <openssl/bn.h>
#include <openssl/ec.h>
#include <math.h>
#include "rtrs.h"
#include "echash.h"
#include "multisig.h"
#include "bootle.h"
int main(void)
{
BIGNUM *a = BN_new();
BIGNUM *b = BN_new();
BIGNUM *p = BN_new();
BN_zero(a);
BN_set_word(b, 7);
BN_hex2bn(&p, "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F");
char *generator = "0479BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D9\
59F2815B16F81798483ADA7726A3C4655DA4FBFC0E1108A8FD\
17B448A68554199C47D08FFB10D4B8";
char *order = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8C\
D0364141";
char *cofactor = "01";
struct RTRS_CTX *ctx = RTRS_init(a, b, p, generator, order, cofactor);
BIGNUM **sk = malloc(2*sizeof(BIGNUM*));
EC_POINT *ki = 0;
EC_POINT **pk = malloc(2*sizeof(EC_POINT*));
long dbase = 8;
long dexp = 8;
int inputs = 8;
printf("Ring size %lf\n Inputs: %d\n", pow(dbase, dexp), inputs);
printf("Keygen...");
RTRS_keygen(ctx, sk, &ki, pk);
puts("done");
// sigma1 test
printf("Sigma1...");
{
BIGNUM ***b = malloc(2*sizeof(BIGNUM**));
b[0] = malloc(2*sizeof(BIGNUM*));
b[1] = malloc(2*sizeof(BIGNUM*));
b[0][0] = BN_new();
b[0][1] = BN_new();
b[1][0] = BN_new();
b[1][1] = BN_new();
BN_one(b[0][0]);
BN_zero(b[0][1]);
BN_zero(b[1][0]);
BN_one(b[1][1]);
BIGNUM *r = BN_new();
BN_one(r);
struct BOOTLE_SIGMA1 *P = BOOTLE_SIGMA1_new(ctx->curve, ctx->bnctx, b, 2, 2, r);
BOOTLE_SIGMA1_free(P);
BN_free(b[0][0]);
BN_free(b[0][1]);
BN_free(b[1][0]);
BN_free(b[1][1]);
free(b[0]);
free(b[1]);
free(b);
BN_free(r);
}
puts("done");
RTRS_free(ctx);
BN_free(sk[0]);
BN_free(sk[1]);
EC_POINT_free(ki);
EC_POINT_free(pk[0]);
EC_POINT_free(pk[1]);
BN_free(a);
BN_free(b);
BN_free(p);
free(sk);
free(pk);
return 0;
}