BitcoinPHP / BitcoinECDSA.php

PHP library to generate BTC addresses and signatures from private keys.
222 stars 106 forks source link

On 32bit systems int overflows when generating random 256bits hexa string #34

Closed vasimi closed 7 years ago

vasimi commented 7 years ago

In BitcoinECDSA.php on line 149, there is rand() with parameters 100000000000 and 1000000000000. Everything is okay on 64bit systems, but on 32bit systems, those ints overflow and they become float which causes that no number is generated. Possible solution is to use constant PHP_INT_MAX and generate this random number in range which is supported on current system.

rgex commented 7 years ago

Thanks for the info. The rand() can be removed as openssl_random_pseudo_bytes() already provides more than enough entropy.

rgex commented 7 years ago

I just fixed it in release 1.3.2