-
Notifications
You must be signed in to change notification settings - Fork 7
/
coordinates.cpp
47 lines (40 loc) · 1.56 KB
/
coordinates.cpp
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
/*
* coordinates.cpp
*
* Created on: Nov 12, 2009
* Author: bhess
*/
#include "coordinates.h"
Coordinate::Coordinate(const Jacobian& jac, const mpz_class mod) {
mpz_class const_2 = 2, const_3 = 3;
mpz_powm(X.get_mpz_t(), jac.Z.get_mpz_t(), const_2.get_mpz_t(), mod.get_mpz_t());
mpz_powm(Y.get_mpz_t(), jac.Z.get_mpz_t(), const_3.get_mpz_t(), mod.get_mpz_t());
mpz_invert(X.get_mpz_t(), X.get_mpz_t(), mod.get_mpz_t());
mpz_invert(Y.get_mpz_t(), Y.get_mpz_t(), mod.get_mpz_t());
mpz_mul(X.get_mpz_t(), jac.X.get_mpz_t(), X.get_mpz_t());
mpz_mul(Y.get_mpz_t(), jac.Y.get_mpz_t(), Y.get_mpz_t());
mpz_mod(X.get_mpz_t(), X.get_mpz_t(), mod.get_mpz_t());
mpz_mod(Y.get_mpz_t(), Y.get_mpz_t(), mod.get_mpz_t());
}
/*
Coordinate::Coordinate(const LD& ld, const mpz_class mod) {
mpz_class const_2 = 2;
//mpz_powm(X.get_mpz_t(), jac.Z.get_mpz_t(), const_2.get_mpz_t(), mod.get_mpz_t());
mpz_powm(Y.get_mpz_t(), ld.Z.get_mpz_t(), const_2.get_mpz_t(), mod.get_mpz_t());
mpz_invert(X.get_mpz_t(), ld.Z.get_mpz_t(), mod.get_mpz_t());
mpz_invert(Y.get_mpz_t(), Y.get_mpz_t(), mod.get_mpz_t());
mpz_mul(X.get_mpz_t(), ld.X.get_mpz_t(), X.get_mpz_t());
mpz_mul(Y.get_mpz_t(), ld.Y.get_mpz_t(), Y.get_mpz_t());
mpz_mod(X.get_mpz_t(), X.get_mpz_t(), mod.get_mpz_t());
mpz_mod(Y.get_mpz_t(), Y.get_mpz_t(), mod.get_mpz_t());
}
*/
Coordinate::Coordinate(const char* _x, int basex,
const char* _y, int basey) {
X.set_str(_x, basex);
Y.set_str(_y, basey);
}
ostream& operator<<(ostream& out, Coordinate& rhs){
out << "(" << rhs.X << ", "<<rhs.Y<<")";
return out;
}