diff options
author | Determinant <tederminant@gmail.com> | 2018-07-27 17:33:23 -0400 |
---|---|---|
committer | Determinant <tederminant@gmail.com> | 2018-07-27 17:33:23 -0400 |
commit | ec6a1f84324faf8e7c92f32137464db57410f58a (patch) | |
tree | 10a0f289a255eb5c78be2cb4a5e2702fc7995182 /include/hotstuff/crypto.h | |
parent | 5f00c067f863f812a740dc209b1fb829f04042eb (diff) |
fix signature verification bug
Diffstat (limited to 'include/hotstuff/crypto.h')
-rw-r--r-- | include/hotstuff/crypto.h | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/include/hotstuff/crypto.h b/include/hotstuff/crypto.h index 32997c8..40c9140 100644 --- a/include/hotstuff/crypto.h +++ b/include/hotstuff/crypto.h @@ -340,7 +340,7 @@ class PartCertSecp256k1: public SigSecp256k1, public PartCert { class QuorumCertSecp256k1: public QuorumCert { uint256_t blk_hash; salticidae::Bits rids; - std::vector<SigSecp256k1> sigs; + std::unordered_map<ReplicaID, SigSecp256k1> sigs; public: QuorumCertSecp256k1() = default; @@ -349,11 +349,9 @@ class QuorumCertSecp256k1: public QuorumCert { void add_part(ReplicaID rid, const PartCert &pc) override { if (pc.get_blk_hash() != blk_hash) throw std::invalid_argument("PartCert does match the block hash"); - if (!rids.get(rid)) - { - rids.set(rid); - sigs.push_back(static_cast<const PartCertSecp256k1 &>(pc)); - } + sigs.insert(std::make_pair( + rid, static_cast<const PartCertSecp256k1 &>(pc))); + rids.set(rid); } void compute() override {} @@ -368,13 +366,14 @@ class QuorumCertSecp256k1: public QuorumCert { void serialize(DataStream &s) const override { s << blk_hash << rids; - for (const auto &sig: sigs) s << sig; + for (size_t i = 0; i < rids.size(); i++) + if (rids.get(i)) s << sigs.at(i); } void unserialize(DataStream &s) override { s >> blk_hash >> rids; - sigs.resize(rids.size()); - for (auto &sig: sigs) s >> sig; + for (size_t i = 0; i < rids.size(); i++) + if (rids.get(i)) s >> sigs[i]; } }; |