diff options
author | MITSUNARI Shigeo <herumi@nifty.com> | 2016-08-27 21:36:08 +0800 |
---|---|---|
committer | MITSUNARI Shigeo <herumi@nifty.com> | 2016-08-27 21:36:08 +0800 |
commit | 4d956aa85c0afcb6278b25a84b162349c8a00750 (patch) | |
tree | 8e929ac46583d01b357701c1e242a5f55e41ad14 /sample/bls_smpl.cpp | |
parent | fb67a31a6c7720e9499301127bfe57d5342c1d35 (diff) | |
download | dexon-bls-4d956aa85c0afcb6278b25a84b162349c8a00750.tar dexon-bls-4d956aa85c0afcb6278b25a84b162349c8a00750.tar.gz dexon-bls-4d956aa85c0afcb6278b25a84b162349c8a00750.tar.bz2 dexon-bls-4d956aa85c0afcb6278b25a84b162349c8a00750.tar.lz dexon-bls-4d956aa85c0afcb6278b25a84b162349c8a00750.tar.xz dexon-bls-4d956aa85c0afcb6278b25a84b162349c8a00750.tar.zst dexon-bls-4d956aa85c0afcb6278b25a84b162349c8a00750.zip |
change type of id to Id class
Diffstat (limited to 'sample/bls_smpl.cpp')
-rw-r--r-- | sample/bls_smpl.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/sample/bls_smpl.cpp b/sample/bls_smpl.cpp index 7c08a39..28d2c04 100644 --- a/sample/bls_smpl.cpp +++ b/sample/bls_smpl.cpp @@ -9,15 +9,17 @@ const std::string pubFile = "sample/publickey"; const std::string secFile = "sample/secretkey"; const std::string signFile = "sample/sign"; -std::string makeName(const std::string& name, int id) +std::string makeName(const std::string& name, const bls::Id& id) { const std::string suf = ".txt"; - if (id == 0) return name + suf; - return name + cybozu::itoa(id) + suf; + if (id.isZero()) return name + suf; + std::ostringstream os; + os << name << id << suf; + return os.str(); } template<class T> -void save(const std::string& file, const T& t, int id = 0) +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); @@ -27,7 +29,7 @@ void save(const std::string& file, const T& t, int id = 0) } template<class T> -void load(T& t, const std::string& file, int id = 0) +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); @@ -87,7 +89,7 @@ int share(int n, int k) secVec[i].set(msk, i + 1); } for (int i = 0; i < n; i++) { - int id = secVec[i].getId(); + const bls::Id& id = secVec[i].getId(); save(secFile, secVec[i], id); bls::PublicKey pub; secVec[i].getPublicKey(pub); |