bitpay / bitcore-lib

A pure and powerful JavaScript Bitcoin library
https://bitcore.io/
Other
613 stars 1.03k forks source link

Cant use this library due to crypto #122

Open gkucmierz opened 7 years ago

gkucmierz commented 7 years ago

It is trying to use crypto.createHash method but it is reserved in browser and it has another methods.

bijeebuss commented 7 years ago

Im getting an Invalid y value for curve. error in my Ionic app when calling

var mnemonic = new Mnemonic(seed);
this.walletHdPrivKey = mnemonic.toHDPrivateKey();

would that be related to this issue? I was also getting the bs58 error but after installing bs58 2.0.0 now im getting this. If so are there currently any work-arounds?

carlosfaria94 commented 7 years ago

I think I have a similar problem with this.

TypeError: crypto.createHash is not a function
    at Object.Hash.sha256 (hash.js:18)
    at Object.Hash.sha256ripemd160 (hash.js:35)
    at Function.Address._transformPublicKey (address.js:227)
    at Function.Address.fromPublicKey (address.js:292)
    at PrivateKey.toAddress (privatekey.js:363)

I'm trying to use this lib with Angular 2 (webpack) and using crypto.createHash is getting me in troubles.

Any solution?

bijeebuss commented 7 years ago

I manually installed all of bitcore-libs dependencies at their exact versions into my project and it fixed the issue for me (using ionic2).

carlosfaria94 commented 7 years ago

I fixed my problem, changing webpack config file:

node: {
           ...
            crypto: true,
            ...
        }
rlim19 commented 7 years ago

could you point the path for the webpack config file on angular 1.0.3, please? Thanks in advance

carlosfaria94 commented 7 years ago

@rlim19

/node_modules/@angular/cli/models/webpack-configs/common.js

ben-tuttle commented 6 years ago

I am also getting the Invalid y value for curve. error on a Ionic 2.

I am calling Wallet = HDPrivateKey.fromSeed(seed);

I have manually installed the dependencies, but that seems to have no effect. I have setup local testing and the seeds I am generating work there, but not when I serve the ionic application.

ben-tuttle commented 6 years ago

I can confirm, if you install the dependencies at the give version it works. Is this a bug with your package and how npm installs it?

matiu commented 6 years ago

please see:

https://github.com/bitpay/copay-recovery/tree/master#installation

You need to enable crypto in Angular 2, explicity.

On Thu, Sep 21, 2017 at 7:43 PM, theDe¢entralizer notifications@github.com wrote:

I can confirm, if you install the dependencies at the give version it works. Is this a bug with your package and how npm installs it?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/bitpay/bitcore-lib/issues/122#issuecomment-331301989, or mute the thread https://github.com/notifications/unsubscribe-auth/AAGCHASMRmV6Nx9sLJ2JaiZraPRmaBYwks5skuaMgaJpZM4L-SAB .

-- BitPay.com

Dkdaniz commented 6 years ago

hello all,

I'm with the same error, but in Angular 5 + Ionic 3

Can someone help me?

can you tell me the step by step to solve this problem please? I've been trying to solve it for days and I'm not getting it.

` var global_keystore;
var randomSeed = Lightwallet.keystore.generateRandomSeed();
var password = "123";

console.log(randomSeed);
console.log(password);

Lightwallet.keystore.createVault({
  password: password,
  seedPhrase: randomSeed,
  //random salt 
  hdPathString: "m/0'/0'/0'"
}, function (err, ks) {

  global_keystore = ks   
  console.log(global_keystore)          

  });

} `

Console.log: ` fire coast daring wheat road company switch that banana unusual other kit 123

ERRO: polyfills.js:3 Uncaught Error: Invalid y value for curve. at Point.validate (point.js:123) at new PublicKey (publickey.js:53) at Function.PublicKey.fromPrivateKey (publickey.js:221) at PrivateKey.toPublicKey (privatekey.js:362) at HDPrivateKey._buildFromBuffers (hdprivatekey.js:486) at HDPrivateKey._buildFromObject (hdprivatekey.js:376) at new HDPrivateKey (hdprivatekey.js:61) at Function.HDPrivateKey.fromSeed (hdprivatekey.js:422) at Mnemonic.toHDPrivateKey (mnemonic.js:207) at KeyStore.init (keystore.js:86)`

txreplay commented 6 years ago

@Dkdaniz What is your elliptic version in package.json ? I had the same error and update to "^6.4.0" and it's working now.

aasif commented 6 years ago

@txreplay I had a similar issue. Updating elliptic@6.4.0 solved my issue. I was using Ionic 3