diff options
author | MITSUNARI Shigeo <herumi@nifty.com> | 2016-08-21 07:00:02 +0800 |
---|---|---|
committer | MITSUNARI Shigeo <herumi@nifty.com> | 2016-08-21 07:00:02 +0800 |
commit | ade6ac7396e497b1509bec9234440029ad4323cf (patch) | |
tree | 53a507656314ce5eb6fcc7af43c0b4e4d4d974a7 /src/bls.cpp | |
parent | ada94f774905651cac581462af96dd959dde746a (diff) | |
download | dexon-bls-ade6ac7396e497b1509bec9234440029ad4323cf.tar dexon-bls-ade6ac7396e497b1509bec9234440029ad4323cf.tar.gz dexon-bls-ade6ac7396e497b1509bec9234440029ad4323cf.tar.bz2 dexon-bls-ade6ac7396e497b1509bec9234440029ad4323cf.tar.lz dexon-bls-ade6ac7396e497b1509bec9234440029ad4323cf.tar.xz dexon-bls-ade6ac7396e497b1509bec9234440029ad4323cf.tar.zst dexon-bls-ade6ac7396e497b1509bec9234440029ad4323cf.zip |
change PublicKey::verify to Sign::verify
Diffstat (limited to 'src/bls.cpp')
-rw-r--r-- | src/bls.cpp | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/src/bls.cpp b/src/bls.cpp index 50e7a1e..949cdf6 100644 --- a/src/bls.cpp +++ b/src/bls.cpp @@ -144,6 +144,7 @@ namespace impl { struct Sign { G1 sHm; // s Hash(m) const G1& get() const { return sHm; } + bool verify(const PublicKey& pub, const std::string& m) const; }; struct PublicKey { @@ -152,18 +153,19 @@ struct PublicKey { { G2::mul(sQ, getQ(), s); } - bool verify(const Sign& sign, const std::string& m) const - { - G1 Hm; - HashAndMapToG1(Hm, m); // Hm = Hash(m) - Fp12 e1, e2; - BN::pairing(e1, getQ(), sign.sHm); // e(Q, s Hm) - BN::pairing(e2, sQ, Hm); // e(sQ, Hm) - return e1 == e2; - } const G2& get() const { return sQ; } }; +inline bool Sign::verify(const PublicKey& pub, const std::string& m) const +{ + G1 Hm; + HashAndMapToG1(Hm, m); // Hm = Hash(m) + Fp12 e1, e2; + BN::pairing(e1, getQ(), sHm); // e(Q, s Hm) + BN::pairing(e2, pub.sQ, Hm); // e(sQ, Hm) + return e1 == e2; +} + struct MasterPublicKey { std::vector<G2> vecR; }; @@ -228,6 +230,10 @@ std::istream& operator>>(std::istream& os, Sign& s) return os >> s.id_ >> s.self_->sHm; } +bool Sign::verify(const PublicKey& pub, const std::string& m) const +{ + return self_->verify(*pub.self_, m); +} void Sign::recover(const std::vector<Sign>& signVec) { G1 sHm; @@ -328,11 +334,6 @@ std::istream& operator>>(std::istream& is, PublicKey& pub) return is >> pub.id_ >> pub.self_->sQ; } -bool PublicKey::verify(const Sign& sign, const std::string& m) const -{ - return self_->verify(*sign.self_, m); -} - void PublicKey::recover(const std::vector<PublicKey>& pubVec) { G2 sQ; |