Closed codablock closed 6 years ago
Yeah, the purpose of this check was to prevent rogue public key attack (two identical messages). And it was supposed to be called with sorted messages.
However, now it's just called by Verify, and message are guaranteed to be distinct. I think we should just remove this check, keep this method private, and add a comment.
Will add to the latest PR.
https://github.com/Chia-Network/bls-signatures/blob/f1570dfeb7e5c9741fd8f42ced93ec811e6944ae/src/bls.cpp#L555
Is this supposed to catch non-distinct messages? If yes, it'll only catch these if they are direct neighbors in
mappedHashes
. I assume you're relying on the messages being sorted here, but that's something that IMHO could go wrong easily if VerifyNative is called in a different way at any time in the future.I'd suggest to either add a check for correct sorting in the same loop (
g2_cmp(...) != CMP_GT
instead ofg2_cmp(...) == CMP_EQ
) and add a proper comment so that the requirement is clear or add a real duplicate check (e.g., based on std::set)