Skip to content

Serious Bug: BN.js incorrectly computes hexsting #3017

@ricmoo

Description

@ricmoo

Ethers Version

5.6.7

Search Terms

No response

Describe the Problem

There was a serious bug identified in BN.js, which results in hex strings being incorrectly computed in some cases (analysis will be performed shortly, after I get the CI off and running).

The hexstring is used extensively in ethers v5 BigNumber library, to ensure immutability. This does not affect the v6-beta branch, as it does not use BN.js.

There is a fix published in that repository, so I just need to update the version, verify correctness, and lock the versions in the package.json files.

h/t: @alexdupre

Code Snippet

// Two numbers, which *should* be different:
const a = BigNumber.from(2).pow(336);
const b = BigNumber.from(2).pow(316);

// Should log `false`, but actually logs `true`
console.log(a.eq(b))

Contract ABI

No response

Errors

No response

Environment

No response

Environment (Other)

No response

Metadata

Metadata

Assignees

Labels

bugVerified to be an issue.fixed/completeThis Bug is fixed or Enhancement is complete and published.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions