|
@@ -5,55 +5,127 @@ Fp12e::Fp12e(const fp12e_t& input)
|
|
fp12e_set(data, input);
|
|
fp12e_set(data, input);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+Fp12e::Fp12e()
|
|
|
|
+{
|
|
|
|
+ fp12e_setzero(data);
|
|
|
|
+}
|
|
|
|
+
|
|
Fp6e::Fp6e(const fp6e_t& input)
|
|
Fp6e::Fp6e(const fp6e_t& input)
|
|
{
|
|
{
|
|
fp6e_set(data, input);
|
|
fp6e_set(data, input);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+Fp6e::Fp6e()
|
|
|
|
+{
|
|
|
|
+ fp6e_setzero(data);
|
|
|
|
+}
|
|
|
|
+
|
|
Fp2e::Fp2e(const fp2e_t& input)
|
|
Fp2e::Fp2e(const fp2e_t& input)
|
|
{
|
|
{
|
|
fp2e_set(data, input);
|
|
fp2e_set(data, input);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+Fp2e::Fp2e()
|
|
|
|
+{
|
|
|
|
+ fp2e_setzero(data);
|
|
|
|
+}
|
|
|
|
+
|
|
Fpe::Fpe(const fpe_t& input)
|
|
Fpe::Fpe(const fpe_t& input)
|
|
{
|
|
{
|
|
fpe_set(data, input);
|
|
fpe_set(data, input);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+Fpe::Fpe()
|
|
|
|
+{
|
|
|
|
+ fpe_setzero(data);
|
|
|
|
+}
|
|
|
|
+
|
|
std::ostream& operator<<(std::ostream& os, const Fp12e& output)
|
|
std::ostream& operator<<(std::ostream& os, const Fp12e& output)
|
|
{
|
|
{
|
|
- os << "(" << Fp6e(output.data->m_a) << " * Z + " << Fp6e(output.data->m_b) << ")";
|
|
|
|
|
|
+ os << Fp6e(output.data->m_a) << Fp6e(output.data->m_b);
|
|
|
|
|
|
return os;
|
|
return os;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+std::istream& operator>>(std::istream& is, Fp12e& input)
|
|
|
|
+{
|
|
|
|
+ Fp6e a, b;
|
|
|
|
+ is >> a >> b;
|
|
|
|
+
|
|
|
|
+ fp6e_set(input.data->m_a, a.data);
|
|
|
|
+ fp6e_set(input.data->m_b, b.data);
|
|
|
|
+
|
|
|
|
+ return is;
|
|
|
|
+}
|
|
|
|
+
|
|
std::ostream& operator<<(std::ostream& os, const Fp6e& output)
|
|
std::ostream& operator<<(std::ostream& os, const Fp6e& output)
|
|
{
|
|
{
|
|
- os << "(" << Fp2e(output.data->m_a) << " * Y^2 + " << Fp2e(output.data->m_b) << " * Y + " << Fp2e(output.data->m_c) << ")";
|
|
|
|
|
|
+ os << Fp2e(output.data->m_a) << Fp2e(output.data->m_b) << Fp2e(output.data->m_c);
|
|
|
|
|
|
return os;
|
|
return os;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+std::istream& operator>>(std::istream& is, Fp6e& input)
|
|
|
|
+{
|
|
|
|
+ Fp2e a, b, c;
|
|
|
|
+ is >> a >> b >> c;
|
|
|
|
+
|
|
|
|
+ fp2e_set(input.data->m_a, a.data);
|
|
|
|
+ fp2e_set(input.data->m_b, b.data);
|
|
|
|
+ fp2e_set(input.data->m_c, c.data);
|
|
|
|
+
|
|
|
|
+ return is;
|
|
|
|
+}
|
|
|
|
+
|
|
std::ostream& operator<<(std::ostream& os, const Fp2e& output)
|
|
std::ostream& operator<<(std::ostream& os, const Fp2e& output)
|
|
{
|
|
{
|
|
fpe_t a, b;
|
|
fpe_t a, b;
|
|
fp2e_to_2fpe(a, b, output.data);
|
|
fp2e_to_2fpe(a, b, output.data);
|
|
|
|
|
|
- os << "(" << Fpe(a) << " * X + " << Fpe(b) << ")";
|
|
|
|
|
|
+ os << Fpe(a) << Fpe(b);
|
|
|
|
|
|
return os;
|
|
return os;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+std::istream& operator>>(std::istream& is, Fp2e& input)
|
|
|
|
+{
|
|
|
|
+ Fpe a, b;
|
|
|
|
+ is >> a >> b;
|
|
|
|
+ _2fpe_to_fp2e(input.data, a.data, b.data);
|
|
|
|
+
|
|
|
|
+ return is;
|
|
|
|
+}
|
|
|
|
+
|
|
std::ostream& operator<<(std::ostream& os, const Fpe& output)
|
|
std::ostream& operator<<(std::ostream& os, const Fpe& output)
|
|
{
|
|
{
|
|
- os << "(";
|
|
|
|
for (int i = 0; i < 12; i++)
|
|
for (int i = 0; i < 12; i++)
|
|
- {
|
|
|
|
- os << std::setw(10) << output.data->v[i] << std::setw(0);
|
|
|
|
- if (i < 11)
|
|
|
|
- os << ", ";
|
|
|
|
- }
|
|
|
|
- os << ")";
|
|
|
|
|
|
+ hex_double(os, output.data->v[i]);
|
|
|
|
|
|
return os;
|
|
return os;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+std::istream& operator>>(std::istream& is, Fpe& input)
|
|
|
|
+{
|
|
|
|
+ for (int i = 0; i < 12; i++)
|
|
|
|
+ hex_double(is, input.data->v[i]);
|
|
|
|
+
|
|
|
|
+ return is;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+std::ostream& hex_double(std::ostream& os, double d)
|
|
|
|
+{
|
|
|
|
+ uint64_t u;
|
|
|
|
+ memcpy(&u, &d, sizeof(d));
|
|
|
|
+ os << std::hex << std::setw(16) << u << std::setw(0) << std::dec;
|
|
|
|
+
|
|
|
|
+ return os;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+std::istream& hex_double(std::istream& is, double& d)
|
|
|
|
+{
|
|
|
|
+ uint64_t u;
|
|
|
|
+ is >> std::hex >> u >> std::dec;
|
|
|
|
+ memcpy(&d, &u, sizeof(u));
|
|
|
|
+
|
|
|
|
+ return is;
|
|
|
|
+}
|