Skip to content

Commit

Permalink
Use 65536 hashing rounds by default (instead of 262144); fixed file e…
Browse files Browse the repository at this point in the history
…xport bug
  • Loading branch information
tinybike committed Aug 13, 2015
1 parent 641f214 commit 07cbea6
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ keystore/UTC--2015-08-11T06:13:53.359Z--008aeeda4d805471df9b2a5b0f38a0c3bcba786b
To use with geth, copy this file to your Ethereum keystore folder
(usually ~/.ethereum/keystore).
```
Note: by default, keythereum uses 65536 hashing rounds in its key derivation functions, compared to the 262144 geth uses by default. (Keythereum's JSON output files are still compatible with geth, however, since they tell geth how many rounds to use.) These values are user-editable: `keythereum.constants.pbkdf2.c` is the number of rounds for PBKDF2, and `keythereum.constants.scrypt.n` is the number of rounds for scrypt.

Tests
-----
Expand Down
6 changes: 3 additions & 3 deletions dist/keythereum.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ module.exports = {

// Key derivation function parameters
pbkdf2: {
c: 262144,
c: 65536,
dklen: 32,
hash: "sha256",
prf: "hmac-sha256"
},
scrypt: {
dklen: 32,
n: 262144,
n: 65536,
r: 1,
p: 8
}
Expand Down Expand Up @@ -347,7 +347,7 @@ module.exports = {
c: this.constants.pbkdf2.c,
dklen: this.constants.pbkdf2.dklen,
prf: this.constants.pbkdf2.prf,
salt: salt
salt: salt.toString("hex")
};
}

Expand Down
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ module.exports = {

// Key derivation function parameters
pbkdf2: {
c: 262144,
c: 65536,
dklen: 32,
hash: "sha256",
prf: "hmac-sha256"
},
scrypt: {
dklen: 32,
n: 262144,
n: 65536,
r: 1,
p: 8
}
Expand Down Expand Up @@ -339,7 +339,7 @@ module.exports = {
c: this.constants.pbkdf2.c,
dklen: this.constants.pbkdf2.dklen,
prf: this.constants.pbkdf2.prf,
salt: salt
salt: salt.toString("hex")
};
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "keythereum",
"version": "0.1.2",
"version": "0.1.3",
"description": "Create, import and export Ethereum keys",
"main": "index.js",
"directories": {
Expand Down
6 changes: 5 additions & 1 deletion test/keys.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ var pubToAddress = require("ethereumjs-util").pubToAddress;
var ecdsa = new (require("elliptic").ec)("secp256k1");
var keythereum = require("../");

// change hashing rounds to match geth's default
keythereum.constants.pbkdf2.c = 262144;
keythereum.constants.scrypt.n = 262144;

// create private key
var privateKey = crypto.randomBytes(32);

Expand Down Expand Up @@ -76,7 +80,7 @@ describe("Crypto", function () {
// datadir: null
// },
// expected: {

// }
// });

Expand Down

0 comments on commit 07cbea6

Please sign in to comment.