-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathresult.h
75 lines (66 loc) · 1.09 KB
/
result.h
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
class Result
{
public:
Result(const mpz_t &x, const mpz_t &y, const mpz_t &p)
{
mpz_init(m_x);
mpz_init(m_y);
mpz_init(m_p);
mpz_set(m_x, x);
mpz_set(m_y, y);
mpz_set(m_p, p);
}
Result(const Result &other)
{
mpz_init(m_x);
mpz_init(m_y);
mpz_init(m_p);
mpz_set(m_x, other.m_x);
mpz_set(m_y, other.m_y);
mpz_set(m_p, other.m_p);
}
Result()
{
mpz_init(m_x);
mpz_init(m_y);
mpz_init(m_p);
}
virtual ~Result()
{
mpz_clear(m_x);
mpz_clear(m_y);
mpz_clear(m_p);
}
Result &operator = (const Result &other)
{
mpz_set(m_x, other.m_x);
mpz_set(m_y, other.m_y);
mpz_set(m_p, other.m_p);
}
std::string to_s()
{
std::string r;
char *szx = mpz_get_str(0, 16, m_x);
r += "0x";
r += szx;
r += "L";
free(szx);
r += " ";
char *szy = mpz_get_str(0, 16, m_y);
r += "0x";
r += szy;
r += "L";
free(szy);
r += " ";
char *szp = mpz_get_str(0, 16, m_p);
r += "0x";
r += szp;
r += "L";
free(szp);
return r;
}
private:
mpz_t m_x;
mpz_t m_y;
mpz_t m_p;
};