bigchaindb / js-bigchaindb-driver

Official BigchainDB JavaScript driver for Node.js and the browser
https://docs.bigchaindb.com/projects/js-driver/en/latest/usage.html
Apache License 2.0
216 stars 92 forks source link

Ed25519Keypair() Error #268

Open hyungnoh opened 5 years ago

hyungnoh commented 5 years ago

Hi guys.

I have installed bigchaindb-driver using command below. npm install bigchaindb-driver

and I have executed following program code.

const driver = require('bigchaindb-driver') const API_PATH = 'http://localhost:9984/api/v1/' const alice = new driver.Ed25519Keypair()

then An error occurred as follows.

TypeError: Expected Buffer at Object.encode (/home/hyung/node_modules/base-x/index.js:29:41) at Object.Ed25519Keypair (/home/hyung/node_modules/bigchaindb-driver/dist/node/Ed25519Keypair.js:28:33)

is there anybody knowing this errors? any suggestions are appreciated.

pboueke commented 5 years ago

I had the same problem, the version I got from NPM has a bug in this file:

https://github.com/bigchaindb/js-bigchaindb-driver/blob/master/src/Ed25519Keypair.js

In the NPM package the keys are not transformed to Buffers. You can copy the file to your dev environment and it will work.

ttmc commented 5 years ago

In other words, the dev version (master branch) of the JavaScript driver doesn't have this issue.

I'll see about getting a new release into npm. BigchainDB is in a transition phase right now, so that's not as trivial as it sounds.

OzanAlpay commented 5 years ago

Any news on this topic?, I still get this error, when I am trying to use it bcdb-driver from npm

hyungnoh commented 5 years ago

Hi Ozan To resolve the error

  1. mv bigchaindb-driver/dist/node
  2. vi Ed25519Keypair.js
  3. Edit codes this.publicKey = _bs2.default.encode(Buffer.from(keyPair.publicKey)); this.privateKey = _bs2.default.encode(Buffer.from(keyPair.secretKey.slice(0, 32)));
OzanAlpay commented 5 years ago

Hi hyungnoh,

Thanks for your help, btw I am using the solution which described in: #265, but I think someone should update npm package, since just changing node files manually is not the best solution(I guess?).

scottpaulin commented 5 years ago

This might be caused by the base-x package being updated. bigchaindb-driver (or one of its dependencies) currently pulls in base-x version 3.0.5. Specifying version 3.0.4 seems to be a workaround for now. e.g.

  "dependencies": {
    "bigchaindb-driver": "^4.1.0",
    "bip39": "^2.5.0",
    "base-x": "3.0.4"
  }
abhisheq6u commented 5 years ago

Hi Ozan To resolve the error

1. mv   bigchaindb-driver/dist/node

2. vi  Ed25519Keypair.js

3. Edit codes
   this.publicKey = _bs2.default.encode(**Buffer.from(keyPair.publicKey)**);
   this.privateKey = _bs2.default.encode(**Buffer.from(keyPair.secretKey.slice(0, 32))**);

Worked for me! Thanks.

julianrodriguezcasas commented 5 years ago

Could you make a new release with the version that is in master branch ????

ttmc commented 5 years ago

The process to transition the governance of all BigchainDB software to the IPDB Foundation is moving along. I anticipate that they will be able to take care of this soon.