Skip to content
This repository has been archived by the owner on Oct 30, 2024. It is now read-only.

Cannot read property 'kdf' of undefined #23

Closed
mandys opened this issue Jan 9, 2018 · 5 comments
Closed

Cannot read property 'kdf' of undefined #23

mandys opened this issue Jan 9, 2018 · 5 comments

Comments

@mandys
Copy link

mandys commented Jan 9, 2018

Hi,

I am trying to use fromV3 method for deploying a smart contract.

Here is a snippet from my truffle.js.

var WalletProvider = require("truffle-wallet-provider");
var keystore = require('fs').readFileSync('./test/keystore/key.json').toString();
var pass = require('fs').readFileSync('./test/keystore/pass').toString();
var wallet = require('ethereumjs-wallet').fromV3(keystore, pass);

The execution stops and I get an error -

TypeError: Cannot read property 'kdf' of undefined

The files are being read properly when checked by doing console.log.

The key.json file has been exported from My Ether Wallet and looks something like:

Replaced actual values with some variables to post here.

{
"version":3,
"id":"myId",
"address":"myAddress",
"Crypto":{
"ciphertext":"myCiperText",
"cipherparams":{
"iv":"4d358169efe50d20f1f68f66c77b97b1"
},
"cipher":"aes-128-ctr",
"kdf":"scrypt",
"kdfparams":{
"dklen":32,
"salt":"mySalt",
"n":1024,
"r":8,
"p":1
},
"mac":"myMac"
}
}

Could someone let me know if the key.json file format is incorrect ?

BTW, the following works just fine.

var WalletProvider = require("truffle-wallet-provider");
var pkey_str = require('fs').readFileSync('./test/keystore/key').toString();
var prkey_buff = new Buffer(pkey_str, 'hex')
var wallet = require('ethereumjs-wallet').fromPrivateKey(prkey_buff)

So, issue is just with fromV3()

Thanks.

@holgerd77
Copy link
Member

Could you paste the whole error stack trace below TypeError: Cannot read property 'kdf' of undefined?

@mandys
Copy link
Author

mandys commented Jan 9, 2018

TypeError: Cannot read property 'kdf' of undefined
at Function.Wallet.fromV3 (/Users/mandys/myToken/node_modules/ethereumjs-wallet/index.js:237:18)
at Object. (/Users/mandys/myToken/truffle.js:6:51)
at Module._compile (module.js:624:30)
at Object.Module._extensions..js (module.js:635:10)
at Module.load (module.js:545:32)
at tryModuleLoad (module.js:508:12)
at Function.Module._load (module.js:500:3)
at Module.require (module.js:568:17)
at require (internal/module.js:11:18)
at Function.Config.load (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:3143:23)

@holgerd77
Copy link
Member

Ah, just remembered, the current release of this library is pretty outdated (>1yo). We really have to do a new release on this, lot of PRs were merged in between. Please try again and let's eventually investigate further once this new release is out.

If you need this urgently you might have to manually install/update to the master branch version.

@mandys
Copy link
Author

mandys commented Jan 9, 2018

Cool. Thanks @holgerd77 .

Not urgent for now as the following is working
var wallet = require('ethereumjs-wallet').fromPrivateKey(prkey_buff)

@plur9
Copy link

plur9 commented Jan 15, 2018

works with setting nonStrict to true i.e. wallet.fromV3(input,password, true)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants