js-bigchaindb-driver icon indicating copy to clipboard operation
js-bigchaindb-driver copied to clipboard

Ed25519Keypair() Error

Open hyungnoh opened this issue 7 years ago • 9 comments
trafficstars

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.

hyungnoh avatar Nov 23 '18 01:11 hyungnoh

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.

pboueke avatar Nov 23 '18 17:11 pboueke

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.

ttmc avatar Nov 24 '18 08:11 ttmc

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

OzanAlpay avatar Dec 08 '18 12:12 OzanAlpay

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)));

hyungnoh avatar Dec 10 '18 03:12 hyungnoh

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?).

OzanAlpay avatar Dec 10 '18 08:12 OzanAlpay

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"
  }

scottpaulin avatar Dec 11 '18 01:12 scottpaulin

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.

abhisheq6u avatar Jan 04 '19 07:01 abhisheq6u

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

julianrodriguezcasas avatar Feb 13 '19 11:02 julianrodriguezcasas

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.

ttmc avatar Apr 12 '19 11:04 ttmc