10 #define MIE_ATE_USE_GMP
33 Mpz(
const Mpz& x) : self_(x.self_) {}
34 Mpz(
int x)
throw(std::exception) : self_(x) {}
35 Mpz(
const std::string& str)
throw(std::exception)
39 void set(
int x)
throw(std::exception) { self_ = x; }
40 void set(
const std::string& str)
throw(std::exception)
42 self_.set_str(str, 0);
46 return self_.get_str();
48 bool equals(
const Mpz& rhs)
const {
return self_ == rhs.self_; }
49 int compareTo(
const Mpz& rhs)
const {
return mpz_cmp(self_.get_mpz_t(), rhs.self_.get_mpz_t()); }
50 void add(
const Mpz& rhs)
throw(std::exception) { self_ += rhs.self_; }
51 void sub(
const Mpz& rhs)
throw(std::exception) { self_ -= rhs.self_; }
52 void mul(
const Mpz& rhs)
throw(std::exception) { self_ *= rhs.self_; }
53 void mod(
const Mpz& rhs)
throw(std::exception) { self_ %= rhs.self_; }
62 Fp(
const Fp& x) : self_(x.self_) {}
63 Fp(
int x) : self_(x) {}
64 Fp(
const std::string& str)
throw(std::exception)
68 void set(
int x) { self_ = x; }
69 void set(
const std::string& str)
throw(std::exception)
77 bool equals(
const Fp& rhs)
const {
return self_ == rhs.self_; }
78 void add(
const Fp& rhs)
throw(std::exception) { self_ += rhs.self_; }
79 void sub(
const Fp& rhs)
throw(std::exception) { self_ -= rhs.self_; }
80 void mul(
const Fp& rhs)
throw(std::exception) { self_ *= rhs.self_; }
92 Fp2(
const Fp2& x) : self_(x.self_) {}
94 Fp2(
int a,
int b) : self_(
a, b) {}
95 Fp2(
const Fp&
a,
const Fp& b)
throw(std::exception)
96 : self_(
a.self_, b.self_)
99 Fp2(
const std::string&
a,
const std::string& b)
throw(std::exception)
100 : self_(
Fp(
a).self_,
Fp(b).self_)
103 Fp&
getA() {
return *
reinterpret_cast<Fp*
>(&self_.a_); }
104 Fp&
getB() {
return *
reinterpret_cast<Fp*
>(&self_.b_); }
105 void set(
const std::string& str)
throw(std::exception)
111 return self_.toString();
113 bool equals(
const Fp2& rhs)
const {
return self_ == rhs.self_; }
114 void add(
const Fp2& rhs)
throw(std::exception) { self_ += rhs.self_; }
115 void sub(
const Fp2& rhs)
throw(std::exception) { self_ -= rhs.self_; }
116 void mul(
const Fp2& rhs)
throw(std::exception) { self_ *= rhs.self_; }
129 void set(
const std::string& str)
throw(std::exception)
131 std::istringstream iss(str);
136 std::ostringstream oss;
140 bool equals(
const Fp12& rhs)
const {
return self_ == rhs.self_; }
141 void add(
const Fp12& rhs)
throw(std::exception) { self_ += rhs.self_; }
142 void sub(
const Fp12& rhs)
throw(std::exception) { self_ -= rhs.self_; }
143 void mul(
const Fp12& rhs)
throw(std::exception) { self_ *= rhs.self_; }
157 Ec1(
const Fp& x,
const Fp& y)
throw(std::exception)
161 Ec1(
const Fp& x,
const Fp& y,
const Fp& z)
throw(std::exception)
166 void set(
const Fp& x,
const Fp& y)
throw(std::exception)
168 self_.
set(x.self_, y.self_);
170 void set(
const Fp& x,
const Fp& y,
const Fp& z)
throw(std::exception)
172 self_.
set(x.self_, y.self_, z.self_);
174 void set(
const std::string& str)
throw(std::exception)
176 std::istringstream iss(str);
181 std::ostringstream oss;
185 bool equals(
const Ec1& rhs)
const {
return self_ == rhs.self_; }
193 Fp&
getX() {
return *
reinterpret_cast<Fp*
>(&self_.
p[0]); }
194 Fp&
getY() {
return *
reinterpret_cast<Fp*
>(&self_.
p[1]); }
195 Fp&
getZ() {
return *
reinterpret_cast<Fp*
>(&self_.
p[2]); }
213 void set(
const Fp2& x,
const Fp2& y)
throw(std::exception)
215 self_.
set(x.self_, y.self_);
217 void set(
const Fp2& x,
const Fp2& y,
const Fp2& z)
throw(std::exception)
219 self_.
set(x.self_, y.self_, z.self_);
221 void set(
const std::string& str)
throw(std::exception)
223 std::istringstream iss(str);
228 std::ostringstream oss;
232 bool equals(
const Ec2& rhs)
const {
return self_ == rhs.self_; }
252 static Mpz r(
"16798108731015832284940804142231733909759579603404752749028378864165570215949");
259#pragma comment(lib, "14/mpird.lib")
260#pragma comment(lib, "14/mpirxxd.lib")
262#pragma comment(lib, "14/mpir.lib")
263#pragma comment(lib, "14/mpirxx.lib")
265#elif _MSC_VER == 1800
267#pragma comment(lib, "12/mpird.lib")
268#pragma comment(lib, "12/mpirxxd.lib")
270#pragma comment(lib, "12/mpir.lib")
271#pragma comment(lib, "12/mpirxx.lib")
275#pragma comment(lib, "mpird.lib")
276#pragma comment(lib, "mpirxxd.lib")
278#pragma comment(lib, "mpir.lib")
279#pragma comment(lib, "mpirxx.lib")
void set(const Fp &x, const Fp &y)
Ec1(const Fp &x, const Fp &y)
std::string toString() const
bool equals(const Ec1 &rhs) const
Ec1(const Fp &x, const Fp &y, const Fp &z)
void set(const std::string &str)
void set(const Fp &x, const Fp &y, const Fp &z)
Ec2(const Fp2 &x, const Fp2 &y)
bool equals(const Ec2 &rhs) const
std::string toString() const
void set(const std::string &str)
void set(const Fp2 &x, const Fp2 &y)
void set(const Fp2 &x, const Fp2 &y, const Fp2 &z)
Ec2(const Fp2 &x, const Fp2 &y, const Fp2 &z)
void mul(const Fp12 &rhs)
bool equals(const Fp12 &rhs) const
void sub(const Fp12 &rhs)
void pairing(const Ec2 &ec2, const Ec1 &ec1)
void set(const std::string &str)
std::string toString() const
void add(const Fp12 &rhs)
std::string toString() const
bool equals(const Fp2 &rhs) const
Fp2(const std::string &a, const std::string &b)
void set(const std::string &str)
Fp2(const Fp &a, const Fp &b)
Fp(const std::string &str)
void set(const std::string &str)
bool equals(const Fp &rhs) const
std::string toString() const
std::string toString() const
Mpz(const std::string &str)
int compareTo(const Mpz &rhs) const
void set(const std::string &str)
bool equals(const Mpz &rhs) const
static void dbl(EcT &R, const EcT &P)
static void sub(EcT &R, const EcT &P, const EcT &Q)
static void add(EcT &R, const EcT &P, const EcT &Q)
static void neg(EcT &R, const EcT &P)
static void mul(EcT &R, const EcT &P, const N &y)
void set(const T &x, const T &y, bool verify=true)
std::string toString(int base=10) const
void opt_atePairing(Fp12T< Fp6T< Fp2T< Fp > > > &f, const Fp2T< Fp > Q[2], const Fp P[2])
T power(const T &x, const S &y)
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
static void init(const CurveParam &cp, int mode=-1, bool useMulx=true)