bitcoinjs / tiny-secp256k1

A tiny secp256k1 native/JS wrapper
MIT License
92 stars 54 forks source link

import tiny-secp256k1 in browser causes TypeError [ERR_INVALID_FILE_URL_PATH]: File URL path must be absolute #129

Closed bomzj closed 1 year ago

bomzj commented 1 year ago

The following line causes crash in browser environment, but works in Node.

import * as ecc from 'tiny-secp256k1'

Note: tiny-secp256k1 version is 2.2.3.

junderw commented 1 year ago

Try 'tiny-secp256k1-asmjs' package for browser environments.

bomzj commented 1 year ago

@junderw thank you for pointing out!

Just wondering should one use 'tiny-secp256k1-asmjs' for just one thing to generate bitcoin private key only? Is it an overkill for that purpose?

My assumption is that I can use window.crypto.getRandomValues instead

const privateKeyBytes = new Uint8Array(32)
window.crypto.getRandomValues(privateKeyBytes)

But I'm not sure how reliable it is.

What would you suggest in this case?