diff options
-rw-r--r-- | include/bls.hpp | 8 | ||||
-rw-r--r-- | src/bls.cpp | 39 | ||||
-rw-r--r-- | test/bls_test.cpp | 34 |
3 files changed, 14 insertions, 67 deletions
diff --git a/include/bls.hpp b/include/bls.hpp index fc29d5c..6101381 100644 --- a/include/bls.hpp +++ b/include/bls.hpp @@ -35,8 +35,6 @@ public: ~Sign(); Sign(const Sign& rhs); Sign& operator=(const Sign& rhs); - void setStr(const std::string& str); - void getStr(std::string& str) const; bool operator==(const Sign& rhs) const; bool operator!=(const Sign& rhs) const { return !(*this == rhs); } int getId() const { return id_; } @@ -78,8 +76,6 @@ public: ~PublicKey(); PublicKey(const PublicKey& rhs); PublicKey& operator=(const PublicKey& rhs); - void setStr(const std::string& str); - void getStr(std::string& str) const; bool operator==(const PublicKey& rhs) const; bool operator!=(const PublicKey& rhs) const { return !(*this == rhs); } int getId() const { return id_; } @@ -106,8 +102,6 @@ public: ~PrivateKey(); PrivateKey(const PrivateKey& rhs); PrivateKey& operator=(const PrivateKey& rhs); - void setStr(const std::string& str); - void getStr(std::string& str) const; bool operator==(const PrivateKey& rhs) const; bool operator!=(const PrivateKey& rhs) const { return !(*this == rhs); } int getId() const { return id_; } @@ -127,4 +121,4 @@ public: void recover(const std::vector<PrivateKey>& prvVec); }; -} // bls +} //bls diff --git a/src/bls.cpp b/src/bls.cpp index 898542b..3747c18 100644 --- a/src/bls.cpp +++ b/src/bls.cpp @@ -213,19 +213,6 @@ Sign& Sign::operator=(const Sign& rhs) return *this; } -void Sign::setStr(const std::string& str) -{ - std::istringstream iss(str); - iss >> *this; -} - -void Sign::getStr(std::string& str) const -{ - std::ostringstream oss(str); - oss << *this; - str = oss.str(); -} - bool Sign::operator==(const Sign& rhs) const { return id_ == rhs.id_ && self_->sHm == rhs.self_->sHm; @@ -320,19 +307,6 @@ PublicKey& PublicKey::operator=(const PublicKey& rhs) return *this; } -void PublicKey::setStr(const std::string& str) -{ - std::istringstream iss(str); - iss >> *this; -} - -void PublicKey::getStr(std::string& str) const -{ - std::ostringstream oss(str); - oss << *this; - str = oss.str(); -} - bool PublicKey::operator==(const PublicKey& rhs) const { return id_ == rhs.id_ && self_->sQ == rhs.self_->sQ; @@ -392,19 +366,6 @@ PrivateKey& PrivateKey::operator=(const PrivateKey& rhs) return *this; } -void PrivateKey::setStr(const std::string& str) -{ - std::istringstream iss(str); - iss >> *this; -} - -void PrivateKey::getStr(std::string& str) const -{ - std::ostringstream oss(str); - oss << *this; - str = oss.str(); -} - bool PrivateKey::operator==(const PrivateKey& rhs) const { return id_ == rhs.id_ && self_->s == rhs.self_->s; diff --git a/test/bls_test.cpp b/test/bls_test.cpp index a2bcc08..3cfc78c 100644 --- a/test/bls_test.cpp +++ b/test/bls_test.cpp @@ -3,27 +3,25 @@ #include <iostream> #include <sstream> +template<class T> +void streamTest(const T& t) +{ + std::ostringstream oss; + oss << t; + std::istringstream iss(oss.str()); + T t2; + iss >> t2; + CYBOZU_TEST_EQUAL(t, t2); +} CYBOZU_TEST_AUTO(bls) { bls::init(); bls::PrivateKey prv; prv.init(); - { - std::string str; - prv.getStr(str); - bls::PrivateKey prv2; - prv2.setStr(str); - CYBOZU_TEST_EQUAL(prv, prv2); - } + streamTest(prv); bls::PublicKey pub; prv.getPublicKey(pub); - { - std::string str; - pub.getStr(str); - bls::PublicKey pub2; - pub2.setStr(str); - CYBOZU_TEST_EQUAL(pub, pub2); - } + streamTest(pub); for (int i = 0; i < 5; i++) { std::string m = "hello"; m += char('0' + i); @@ -31,13 +29,7 @@ CYBOZU_TEST_AUTO(bls) prv.sign(s, m); CYBOZU_TEST_ASSERT(pub.verify(s, m)); CYBOZU_TEST_ASSERT(!pub.verify(s, m + "a")); - { - std::string str; - s.getStr(str); - bls::Sign s2; - s2.setStr(str); - CYBOZU_TEST_EQUAL(s, s2); - } + streamTest(s); } } |