ethereum / py_ecc

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

Add type check to bytes_to_int if with Python3 #122

Closed 0xaead closed 2 years ago

0xaead commented 2 years ago

Also remove the safe_ord() since its usage introduces ambiguity.

What was wrong?

safe_ord( ) is attempting to tolerate int as input but ord() as a build-in should take 1-byte length byte.

ord(c) Given a string representing one Unicode character, return an integer

As its name suggests, safe_ord( ) or its caller should enforce the input type instead. But since ord( )would raise TypeError if being given a character. The rest thing to do is to enforce the input type to bytes_to_int( ).

How was it fixed?

Said function is removed. Add input type check to bytes_to_int( ).

Cute Animal Picture

![put a cute animal picture link inside the parentheses]()