paulmillr / noble-secp256k1

Fastest 4KB JS implementation of secp256k1 signatures and ECDH
https://paulmillr.com/noble
MIT License
757 stars 114 forks source link

Speedup bytesToNumber conversion #67

Closed mahnunchik closed 2 years ago

mahnunchik commented 2 years ago

Current implementation https://github.com/paulmillr/noble-secp256k1/blob/5064c9b1f4d2c3cc441c3be746838373e4ead154/index.ts#L741-L743

uses approach to convert Buffer/Uint8Array to hex string and convert hex string to BigInt.

I think I can be speedup by direct conversion or using library such https://github.com/no2chem/bigint-buffer

paulmillr commented 2 years ago

You can rewrite the function and measure the performance with npm run bench

If you'll have some code that would speed up it measurably, let's discuss it. Otherwise, not interested.