paulmillr / noble-secp256k1

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

Corrects type of `sign` and `signAsync` #102

Closed MicahZoltu closed 1 year ago

MicahZoltu commented 1 year ago

The only place that priv is used in signAsync and sign is when it is passed to prepSig. The only place priv is used in prepSig is when it is passed to toPriv. toPriv takes a PrivKey, so that means prepSig, sign, and signAsync can also take a PrivKey.

Functionally, this means that bigint is now allowed as a private key. This will make it so users who are storing private keys in memory as bigints will not have to first convert to hex.

Node: Currently if you naively convert your bigint private key to hex using 0x${privateKey.toString(16)} this library will throw an error complaining about the hex for the private key being the wrong length. Arguably this library should accept an odd length hex value for the private key, but in my case just accepting bigints directly would fix the issue and allowing odd length hex strings would require an actual code change rather than just a type change.

MicahZoltu commented 1 year ago

What is the release process like for this project? I know it was audited, and I'm not sure if changes to type info would require a new audit or if this can be done as a patch release before the next major release?

paulmillr commented 1 year ago

release schedule is limited once per 1-2 months unless urgent. that's mostly it. 2.0.1 will follow.

paulmillr commented 1 year ago

also 2.0 wasn't audited, noble-curves were