aboutsummaryrefslogtreecommitdiffstats
path: root/sample
diff options
context:
space:
mode:
authorMITSUNARI Shigeo <herumi@nifty.com>2016-08-30 11:51:53 +0800
committerMITSUNARI Shigeo <herumi@nifty.com>2016-08-30 11:51:53 +0800
commitd50143e7909559f745f33090d429b3105af0ee4d (patch)
tree5b197ff2d54e4a3fe2ac26c8d2407f7e41b5cb14 /sample
parent85ccb843bd20ca11c8bb0f3582e420698acc04ee (diff)
downloaddexon-bls-d50143e7909559f745f33090d429b3105af0ee4d.tar
dexon-bls-d50143e7909559f745f33090d429b3105af0ee4d.tar.gz
dexon-bls-d50143e7909559f745f33090d429b3105af0ee4d.tar.bz2
dexon-bls-d50143e7909559f745f33090d429b3105af0ee4d.tar.lz
dexon-bls-d50143e7909559f745f33090d429b3105af0ee4d.tar.xz
dexon-bls-d50143e7909559f745f33090d429b3105af0ee4d.tar.zst
dexon-bls-d50143e7909559f745f33090d429b3105af0ee4d.zip
change id to public menmber and remove id from io
Diffstat (limited to 'sample')
-rw-r--r--sample/bls_smpl.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/sample/bls_smpl.cpp b/sample/bls_smpl.cpp
index 28d2c04..85530dd 100644
--- a/sample/bls_smpl.cpp
+++ b/sample/bls_smpl.cpp
@@ -14,7 +14,7 @@ std::string makeName(const std::string& name, const bls::Id& id)
const std::string suf = ".txt";
if (id.isZero()) return name + suf;
std::ostringstream os;
- os << name << id << suf;
+ os << name << '.' << id << suf;
return os.str();
}
@@ -23,7 +23,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 << t)) {
+ if (!(ofs << std::hex << t)) {
throw cybozu::Exception("can't save") << name;
}
}
@@ -33,9 +33,10 @@ void load(T& t, const std::string& file, const bls::Id& id = 0)
{
const std::string name = makeName(file, id);
std::ifstream ifs(name.c_str(), std::ios::binary);
- if (!(ifs >> t)) {
+ if (!(ifs >> std::hex >> t)) {
throw cybozu::Exception("can't load") << name;
}
+ t.id = id;
}
int init()
@@ -89,7 +90,7 @@ int share(int n, int k)
secVec[i].set(msk, i + 1);
}
for (int i = 0; i < n; i++) {
- const bls::Id& id = secVec[i].getId();
+ const bls::Id& id = secVec[i].id;
save(secFile, secVec[i], id);
bls::PublicKey pub;
secVec[i].getPublicKey(pub);