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
/** @file
*****************************************************************************
* @author This file is part of libff, developed by SCIPR Lab
* and contributors (see AUTHORS).
* @copyright MIT license (see LICENSE file)
*****************************************************************************/
#include <libff/algebra/curves/bn128/bn128_gt.hpp>
namespace libff {
bn128_GT bn128_GT::GT_one;
bn128_GT::bn128_GT()
{
this->elem.clear();
}
bool bn128_GT::operator==(const bn128_GT &other) const
{
return (this->elem == other.elem);
}
bool bn128_GT::operator!=(const bn128_GT& other) const
{
return !(operator==(other));
}
bn128_GT bn128_GT::operator*(const bn128_GT &other) const
{
bn128_GT result;
bn::Fp12::mul(result.elem, this->elem, other.elem);
return result;
}
bn128_GT bn128_GT::unitary_inverse() const
{
bn128_GT result(*this);
bn::Fp6::neg(result.elem.b_, result.elem.b_);
return result;
}
bn128_GT bn128_GT::one()
{
return GT_one;
}
skale::ostream& operator<<(skale::ostream &out, const bn128_GT &g)
{
#ifndef BINARY_OUTPUT
out << g.elem.a_ << OUTPUT_SEPARATOR << g.elem.b_;
#else
out.write((char*) &g.elem.a_, sizeof(g.elem.a_));
out.write((char*) &g.elem.b_, sizeof(g.elem.b_));
#endif
return out;
}
skale::istream& operator>>(skale::istream &in, bn128_GT &g)
{
#ifndef BINARY_OUTPUT
in >> g.elem.a_;
consume_OUTPUT_SEPARATOR(in);
in >> g.elem.b_;
#else
in.read((char*) &g.elem.a_, sizeof(g.elem.a_));
in.read((char*) &g.elem.b_, sizeof(g.elem.b_));
#endif
return in;
}
} // libff