Open kincaidoneil opened 5 years ago
If you could create a PR that would be amazing! Very interested in the approach.
I was also facing this problem and couldn't find a simple workaround.
Running into this problem using lambda functions to sign transactions.
This is building cosmos-keys from 81917a898f874d2fc28f13c4c472475d4a95ae96.
I'm running the code below, adapted from this test:
Which errors with:
Error: Signing failed: private key should be a Buffer
I hypothesize this has to do with the way Webpack shims Buffers, which causes issues when using
secp256k1
in Node, because the native version requires buffers, but is probably fine when used in a browser, since it falls back to using elliptic. (And since the test usests-jest
rather than the Webpack bundle, the issue doesn't show up there.)The native code in
secp256k1
seems to complicate cross-platform compatibility. We've had a great experience using this WebAssembly alternative that's more portable (works seamlessly in Electron) and has decent performance, too. (One downside is the API might need to be async to ensure the WASM module is loaded). I'd be happy to PR that if you're interested!