Can `int()` raise on anything other than an invalid hex string in this case? I guess you could get an invalid hex string if bn2hex didn't error but returned non-hexadecimal (memory bit flip?).