indutny / bn.js

BigNum in pure javascript
MIT License
1.19k stars 150 forks source link

BN.muln with number bigger than 0x4000000 #306

Closed youPickItUp closed 8 months ago

youPickItUp commented 8 months ago

BN.muln throws when called with number bigger than 0x4000000

I haven't came across this information until it has blown up on a website :cry:

I wanted to make sure it's true and ask for some warning / info in the README / docs. I can do the PR just let me know if that's correct.

fanatid commented 8 months ago

This is expected, internally BN operates 26 bits numbers, so you need to use mul https://github.com/indutny/bn.js/blob/5df40f81ea8afb835b909bb7c21e0833cdeb6a30/lib/bn.js#L1993

Would be nice to have that info in the docs, PRs are welcome!