aboutsummaryrefslogtreecommitdiff
path: root/src/crypto.cpp
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2018-09-10 16:06:27 -0400
committerDeterminant <[email protected]>2018-09-10 16:06:27 -0400
commit6261c95184b86c43755071b351e6928f89e2343c (patch)
tree7a33a5d8ad3b252f629d52c5183eab90efb3438a /src/crypto.cpp
parent05f2c56b909a2cd05a200ad663001696e4a23261 (diff)
finish simple multithreaded verifier
Diffstat (limited to 'src/crypto.cpp')
-rw-r--r--src/crypto.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/crypto.cpp b/src/crypto.cpp
index 88c2f57..0932652 100644
--- a/src/crypto.cpp
+++ b/src/crypto.cpp
@@ -27,4 +27,24 @@ bool QuorumCertSecp256k1::verify(const ReplicaConfig &config) {
return true;
}
+promise_t QuorumCertSecp256k1::verify(const ReplicaConfig &config, VeriPool &vpool) {
+ if (sigs.size() < config.nmajority)
+ return promise_t([](promise_t &pm) { pm.resolve(false); });
+ std::vector<promise_t> vpm;
+ for (size_t i = 0; i < rids.size(); i++)
+ if (rids.get(i))
+ {
+ HOTSTUFF_LOG_DEBUG("checking cert(%d), blk_hash=%s",
+ i, get_hex10(blk_hash).c_str());
+ vpm.push_back(vpool.verify(new Secp256k1VeriTask(blk_hash,
+ static_cast<const PubKeySecp256k1 &>(config.get_pubkey(i)),
+ sigs[i])));
+ }
+ return promise::all(vpm).then([](const promise::values_t &values) {
+ for (const auto &v: values)
+ if (!promise::any_cast<bool>(v)) return false;
+ return true;
+ });
+}
+
}