ethereum / py_ecc

Python implementation of ECC pairing and bn_128 and bls12_381 curve operations
MIT License
183 stars 82 forks source link

Update to IETF BLS draft 04 and add some input validations #103

Closed hwwhww closed 3 years ago

hwwhww commented 3 years ago

What was wrong?

Update to IETF BLS draft 04

How was it fixed?

  1. SK=0 (point at infinity PK) is disallowed in -04 spec. Update KeyGen, KeyValidate correspondingly.
  2. Add the missing KeyValidate to _CoreAggregateVerify: It wasn't a bug because _CoreAggregateVerify itself has checked pubkey_to_G1, but now it also needs to check the point at infinity PK.
  3. Add input validations APIs _is_valid_privkey, _is_valid_pubkey, _is_valid_message, and _is_valid_signature. Reasons:
    • To check input types strictly since Python is a dynamically-typed language.
    • To follow the spec description more tightly.
    • As a workaround for PopVerify-able checks. e.g., ensure PK is not the point at infinity in FastAggregateVerify.

Cute Animal Picture

moose-70254_640