aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sample/bls_smpl.cpp2
-rw-r--r--sample/bls_tool.cpp5
-rw-r--r--src/bls.cpp16
3 files changed, 16 insertions, 7 deletions
diff --git a/sample/bls_smpl.cpp b/sample/bls_smpl.cpp
index dd73ed3..f87294b 100644
--- a/sample/bls_smpl.cpp
+++ b/sample/bls_smpl.cpp
@@ -21,7 +21,7 @@ void save(const std::string& file, const T& t, const bls::Id& id = 0)
{
const std::string name = makeName(file, id);
std::ofstream ofs(name.c_str(), std::ios::binary);
- if (!(ofs << std::hex << std::showbase << t)) {
+ if (!(ofs << t)) {
throw cybozu::Exception("can't save") << name;
}
}
diff --git a/sample/bls_tool.cpp b/sample/bls_tool.cpp
index 2dae6d4..a5c2abd 100644
--- a/sample/bls_tool.cpp
+++ b/sample/bls_tool.cpp
@@ -95,12 +95,13 @@ void recover_sig()
size_t k;
read(k);
bls::SecretKeyVec msk(k);
+ bls::IdVec idVec(k);
for (size_t i = 0; i < k; i++) {
- read(msk[i].id);
+ read(idVec[i]);
read(msk[i]);
}
bls::SecretKey sec;
- sec.recover(msk);
+ sec.recover(msk, idVec);
write(sec);
}
diff --git a/src/bls.cpp b/src/bls.cpp
index 096fe36..2fce4b3 100644
--- a/src/bls.cpp
+++ b/src/bls.cpp
@@ -174,6 +174,14 @@ void LagrangeInterpolation(G& r, const T& vec, const IdVec& S)
}
}
+template<class T>
+std::ostream& writeAsHex(std::ostream& os, const T& t)
+{
+ std::string str;
+ t.getStr(str, 16, true);
+ return os << str;
+}
+
Id::Id(unsigned int id)
: self_(new impl::Id())
{
@@ -203,7 +211,7 @@ bool Id::operator==(const Id& rhs) const
std::ostream& operator<<(std::ostream& os, const Id& id)
{
- return os << id.self_->v;
+ return writeAsHex(os, id.self_->v);
}
std::istream& operator>>(std::istream& is, Id& id)
@@ -249,7 +257,7 @@ bool Sign::operator==(const Sign& rhs) const
std::ostream& operator<<(std::ostream& os, const Sign& s)
{
- return os << s.self_->sHm;
+ return writeAsHex(os, s.self_->sHm);
}
std::istream& operator>>(std::istream& os, Sign& s)
@@ -312,7 +320,7 @@ bool PublicKey::operator==(const PublicKey& rhs) const
std::ostream& operator<<(std::ostream& os, const PublicKey& pub)
{
- return os << pub.self_->sQ;
+ return writeAsHex(os, pub.self_->sQ);
}
std::istream& operator>>(std::istream& is, PublicKey& pub)
@@ -364,7 +372,7 @@ bool SecretKey::operator==(const SecretKey& rhs) const
std::ostream& operator<<(std::ostream& os, const SecretKey& sec)
{
- return os << sec.self_->s;
+ return writeAsHex(os, sec.self_->s);
}
std::istream& operator>>(std::istream& is, SecretKey& sec)