bip32 icon indicating copy to clipboard operation
bip32 copied to clipboard

Alternatives to tiny-secp256k1?

Open taylorjdawson opened this issue 3 years ago • 10 comments
trafficstars

The library tiny-secp256k1 breaks builds both in vite/rollup, as well as, some webpack configurations. This library's dependency on tiny-secp256k1 makes it unusable. Can you suggests alternatives to tiny-secp256k1? Thank you 🙏🏾

taylorjdawson avatar Feb 02 '22 21:02 taylorjdawson

You can use tiny-secp256k1 v1 without schnorr support.

For schnorr support, convince your bundlers to support WASM out of the box with 0 configuration.

junderw avatar Feb 02 '22 23:02 junderw

Is there a good way to support it in chrome extensions? It doesn't support WASM by default in browser extensions. Would be great to have an alternative that works by default. I totally understand if not though.

Screen Shot 2022-02-10 at 10 02 09 PM

monsonjeremy avatar Feb 11 '22 06:02 monsonjeremy

Thanks @junderw ! v1 worked for me.

I see v1 has functions signSchnorr and verifySchnorr. Will these not work? (edit: my mistake, those functions are in bip32, but not in tiny-secp256k1@1, leaving for posterity).

convince your bundlers to support WASM out of the box with 0 configuration.

I'm still on newish to JavaScript, what's needed to support V2. What config can I do on my own to support V2? (i.e. would rather not be on V1...)

miketery avatar May 29 '22 04:05 miketery

correct. Those will not work.

There's a pure JS implementation out there, but it uses Native JS BigInt, which is newer than WASM.

junderw avatar May 29 '22 04:05 junderw

Had same problem here with webpack 5 and CRA. Even with experimental wasm flags or wasm loader it won't work. Downgraded tiny-secp256k1 to last 1.* (1.1.6) and worked from first try.

renie avatar Jun 09 '22 18:06 renie

Had same problem here with webpack 5 and CRA. Even with experimental wasm flags or wasm loader it won't work. Downgraded tiny-secp256k1 to last 1.* (1.1.6) and worked from first try.

Thank for this comment, it seem that bip32 don't work with the 2.0 version of tiny-secp256k1. I was having this error: ecc library invalid So I downgraded to 1.1.6 and no more error.

Nlarou avatar Aug 12 '22 19:08 Nlarou

bip32 works with the latest tiny-secp256k1

junderw avatar Aug 13 '22 03:08 junderw

bip32 works with the latest tiny-secp256k1

@junderw does this include React Native / web based or are you talking Node?

miketery avatar Aug 13 '22 16:08 miketery

React Native always lags behind on implementing every single standard API in JavaScript.

Node has been much better with keeping up with browsers in recent years.

The current tiny-secp256k1 will work with webpack/browserify etc. as long as your browser environment supports WebAssembly, and you have the correct config in your webpack config etc.

That said, if you have no use for schnorr signatures, using v1 with latest bip32 (which is pure JS for browser builds) is fine.

junderw avatar Aug 14 '22 09:08 junderw

Last I checked there was a polyfill that enables WASM in RN. If you want schnorr, you'll have to look into that, or create a thin wrapper library around another crypto library so it matches the required interface.

junderw avatar Aug 14 '22 09:08 junderw

If you are encountering this issue, you may want to try using this alternative module that does not require WASM:

https://github.com/bitcoinerlab/secp256k1 (disclaimer: I'm the dev of that module).

Also, @Hyunhum has proposed PR #69 that will make tiny-secp256k1 version 1 compatible again.

landabaso avatar Jan 27 '23 14:01 landabaso