Clearmatics Libff  0.1
C++ library for Finite Fields and Elliptic Curves
bn128_gt.cpp
Go to the documentation of this file.
1 
9 
10 namespace libff
11 {
12 
13 bn128_GT bn128_GT::GT_one;
14 bn128_GT::bn128_GT() { this->elem.clear(); }
15 
16 bool bn128_GT::operator==(const bn128_GT &other) const
17 {
18  return (this->elem == other.elem);
19 }
20 
21 bool bn128_GT::operator!=(const bn128_GT &other) const
22 {
23  return !(operator==(other));
24 }
25 
27 {
28  bn128_GT result;
29  bn::Fp12::mul(result.elem, this->elem, other.elem);
30  return result;
31 }
32 
34 {
35  bn128_GT result(*this);
36  bn::Fp6::neg(result.elem.b_, result.elem.b_);
37  return result;
38 }
39 
41 
42 std::ostream &operator<<(std::ostream &out, const bn128_GT &g)
43 {
44 #ifndef BINARY_OUTPUT
45  out << g.elem.a_ << OUTPUT_SEPARATOR << g.elem.b_;
46 #else
47  out.write((char *)&g.elem.a_, sizeof(g.elem.a_));
48  out.write((char *)&g.elem.b_, sizeof(g.elem.b_));
49 #endif
50  return out;
51 }
52 
53 std::istream &operator>>(std::istream &in, bn128_GT &g)
54 {
55 #ifndef BINARY_OUTPUT
56  in >> g.elem.a_;
58  in >> g.elem.b_;
59 #else
60  in.read((char *)&g.elem.a_, sizeof(g.elem.a_));
61  in.read((char *)&g.elem.b_, sizeof(g.elem.b_));
62 #endif
63  return in;
64 }
65 } // namespace libff
libff::bn128_GT
Definition: bn128_gt.hpp:23
libff
Definition: ffi.cpp:8
libff::operator>>
std::istream & operator>>(std::istream &in, alt_bn128_G1 &g)
Definition: alt_bn128_g1.cpp:446
libff::bn128_GT::operator==
bool operator==(const bn128_GT &other) const
Definition: bn128_gt.cpp:16
libff::bn128_GT::elem
bn::Fp12 elem
Definition: bn128_gt.hpp:27
bn128_gt.hpp
libff::bn128_GT::operator*
bn128_GT operator*(const bn128_GT &other) const
Definition: bn128_gt.cpp:26
OUTPUT_SEPARATOR
#define OUTPUT_SEPARATOR
Definition: serialization.hpp:69
libff::consume_OUTPUT_SEPARATOR
void consume_OUTPUT_SEPARATOR(std::istream &in)
libff::bn128_GT::bn128_GT
bn128_GT()
Definition: bn128_gt.cpp:14
libff::operator<<
std::ostream & operator<<(std::ostream &out, const alt_bn128_G1 &g)
Definition: alt_bn128_g1.cpp:436
libff::bn128_GT::one
static bn128_GT one()
Definition: bn128_gt.cpp:40
libff::bn128_GT::operator!=
bool operator!=(const bn128_GT &other) const
Definition: bn128_gt.cpp:21
libff::bn128_GT::GT_one
static bn128_GT GT_one
Definition: bn128_gt.hpp:26
libff::bn128_GT::unitary_inverse
bn128_GT unitary_inverse() const
Definition: bn128_gt.cpp:33