Zilliqa / zq2

Zilliqa 2.0 code base
Apache License 2.0
9 stars 0 forks source link

Batch verification of AggQC #706

Closed n-hutton closed 4 months ago

n-hutton commented 7 months ago

The AggQC is not batch verified: https://github.com/Zilliqa/zq2/blob/main/zilliqa/src/consensus.rs#L1809

DrZoltanFazekas commented 4 months ago

The comment in the code claims that calling verify_messages(agg.signature, &messages, &public_keys) as defined in https://docs.rs/bls-signatures/latest/bls_signatures/fn.verify_messages.html will not work, but unclear why.

@JamesHinshelwood can you have a quick look as agreed before we decide whether to work on it now or rather later?

DrZoltanFazekas commented 4 months ago

I guess I spotted why it didn't work.

The signatures that are aggregated in an AggregateQC were created as part of NewView messages by signing a QC's hash, a view number and the signer's public key in https://github.com/Zilliqa/zq2/blob/main/zilliqa/src/message.rs#L163-L166

However, the batch verification uses the signers' indices in the validator set as stored in the AggregateQC and not their public keys. Thus, we try to verify the signatures against incorrect messages in https://github.com/Zilliqa/zq2/blob/main/zilliqa/src/consensus.rs#L1794-L1798

JamesHinshelwood commented 4 months ago

Well spotted, thank you :)