snarkOS
snarkOS copied to clipboard
[Optimization] Avoid checking certificate signatures twice.
As a validator collects endorsing signatures from other validators, it verifies them. When it has enough signatures, it creates a certificate with BatchCertificate::from(), which verifies the signatures again. We can avoid this duplication by having the validator call BatchCertificate::from_unchecked() instead. BatchCertificate::from() performs a few other simple checks besides verifying signatures; these other simple checks are easy for the validator to perform before calling BatchCertificate::from_unchecked().
There's a similar issue where, after creating a block, the validator adds it to the ledger which re-checks the block's DAG and certificates again.
For both cases, I like the idea of having some inexpensive sanity checks, instead of doing a full check, as proposed in the PR.