Equality seems to be broken when BN created from strings with prefixed 0's
pigfrown opened this issue · comments
> b1 = new BN("1")
BN { negative: 0, words: [ 1 ], length: 1, red: null }
> b2 = new BN("01")
BN { negative: 0, words: [ 1 ], length: 1, red: null }
> b1 == b2
false
JavaScript does not support operators overloading and because BN is an Object you will get true
only when variables contain the same references.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Equality
If the operands are both objects, return true only if both operands reference the same object.
If you want to compare 2 BN objects you need to use methods https://github.com/indutny/bn.js#utilities like .eq
.