-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.cpp
More file actions
70 lines (56 loc) · 1.39 KB
/
main.cpp
File metadata and controls
70 lines (56 loc) · 1.39 KB
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
#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <NTL/ZZ.h>
using namespace std;
using namespace NTL;
#include "iterative.h"
#include "recursive.h"
using namespace std;
using namespace NTL;
using namespace chrono;
//#define ITERATIVE
void usage_example_zp(uint npoints, uint flen){
long degree = npoints-1;
ZZ prime;
GenPrime(prime, flen);
ZZ_p::init(prime);
// interpolation points:
ZZ_p* X = new ZZ_p[degree+1];
ZZ_p* Y = new ZZ_p[degree+1];
for(unsigned int i=0;i<=degree; i++) {
random(X[i]);
random(Y[i]);
}
ZZ_pX P;
#ifdef ITERATIVE
poly_interpolate_zp_iterative(degree, X, Y, P);
#else
poly_interpolate_zp_recursive(degree, X, Y, P);
#endif
// EVALUATE
ZZ_p* X2 = new ZZ_p[degree+1];
ZZ_p* Y2 = new ZZ_p[degree+1];
for(unsigned int i=0;i<=degree; i++) {
random(X[i]);
}
#ifdef ITERATIVE
poly_evaluate_zp_iterative(degree, P, X2, Y2);
#else
poly_evaluate_zp_recursive(degree, P, X2, Y2);
#endif
delete[] X;
delete[] Y;
delete[] X2;
delete[] Y2;
}
int main(int argc, char *argv[]) {
uint num_points = pow(2,13)-1;
uint field_bitlen = 400;
if(1<argc)
num_points = atoi(argv[1]);
if(2<argc)
field_bitlen = atoi(argv[2]);
cout << "num_points: " << num_points << ", field_bitlen: " << field_bitlen << endl;
usage_example_zp(num_points, field_bitlen);
}