Skip to content

Commit

Permalink
Renamed ethereumjs-keys -> keythereum
Browse files Browse the repository at this point in the history
  • Loading branch information
tinybike committed Aug 11, 2015
1 parent 9ead109 commit 5090cd6
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 33 deletions.
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ node_modules
.travis.yml
test
coverage
keystore
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
ethereumjs-keys
===============
keythereum
==========

[![Build Status](https://travis-ci.org/AugurProject/ethereumjs-keys.svg?branch=master)](https://travis-ci.org/AugurProject/ethereumjs-keys)
[![Coverage Status](https://coveralls.io/repos/AugurProject/ethereumjs-keys/badge.svg?branch=master&service=github)](https://coveralls.io/github/AugurProject/ethereumjs-keys?branch=master)
[![Build Status](https://travis-ci.org/AugurProject/keythereum.svg?branch=master)](https://travis-ci.org/AugurProject/keythereum)
[![Coverage Status](https://coveralls.io/repos/AugurProject/keythereum/badge.svg?branch=master&service=github)](https://coveralls.io/github/AugurProject/keythereum?branch=master)

[![NPM](https://nodei.co/npm/ethereumjs-keys.png)](https://nodei.co/npm/ethereumjs-keys/)
[![NPM](https://nodei.co/npm/keythereum.png)](https://nodei.co/npm/keythereum/)

Generate, import and export Ethereum private keys. Uses PBKDF2 or scrypt key derivation functions.

Installation
------------

$ npm install ethereumjs-keys
$ npm install keythereum

Usage
-----

```javascript
var ethKeys = require("ethereumjs-keys");
var keythereum = require("keythereum");

// User-specified password
var password = "wheethereum";
Expand All @@ -26,7 +26,7 @@ var password = "wheethereum";
var kdf = "pbkdf2"; // "scrypt" to use the scrypt kdf

// Generate private key and the salt and initialization vector to encrypt it
var dk = ethKeys.create();
var dk = keythereum.create();
// dk:
{
privateKey: <Buffer ...>,
Expand All @@ -36,7 +36,7 @@ var dk = ethKeys.create();

// Export key data to keystore "secret-storage" format:
// https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition
var json = ethKeys.dump(password, dk.privateKey, dk.salt, dk.iv, kdf);
var json = keythereum.dump(password, dk.privateKey, dk.salt, dk.iv, kdf);
// json:
{
address: '008aeeda4d805471df9b2a5b0f38a0c3bcba786b',
Expand All @@ -60,7 +60,7 @@ var json = ethKeys.dump(password, dk.privateKey, dk.salt, dk.iv, kdf);
}

// In Node, export formatted JSON to file.
ethKeys.exportToFile(json);
keythereum.exportToFile(json);
```
After successful key export, you will see a message like:
```
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* ethereumjs-keys
* keythereum: create/import/export ethereum keys
* @author Jack Peterson (jack@tinybike.net)
*/

Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ethereumjs-keys",
"version": "0.0.3",
"description": "Import and export Ethereum keys",
"name": "keythereum",
"version": "0.1.0",
"description": "Create, import and export Ethereum keys",
"main": "index.js",
"directories": {
"test": "test",
Expand All @@ -13,14 +13,14 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/AugurProject/ethereumjs-keys.git"
"url": "git+https://github.com/AugurProject/keythereum.git"
},
"author": "Jack Peterson <jack@tinybike.net>",
"license": "MIT",
"bugs": {
"url": "https://github.com/AugurProject/ethereumjs-keys/issues"
"url": "https://github.com/AugurProject/keythereum/issues"
},
"homepage": "https://github.com/AugurProject/ethereumjs-keys#readme",
"homepage": "https://github.com/AugurProject/keythereum#readme",
"dependencies": {
"crypto-browserify": "^3.9.14",
"elliptic": "^5.1.0",
Expand Down
35 changes: 19 additions & 16 deletions test/keys.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ var assert = require("chai").assert;
var validator = require("validator");
var pubToAddress = require("ethereumjs-util").pubToAddress;
var ecdsa = new (require("elliptic").ec)("secp256k1");
var ethKeys = require("../");
var keythereum = require("../");

// create private key, get public key and address
var privateKey = crypto.randomBytes(32);

// timeout for asynchronous unit tests
var TIMEOUT = 48000;

ethKeys.create();
keythereum.create();

describe("Crypto", function () {

Expand All @@ -43,11 +43,14 @@ describe("Crypto", function () {
});

it("derive address from private key", function () {
assert.strictEqual(ethKeys.privateKeyToAddress(privateKey), "0x" + address);
assert.strictEqual(
keythereum.privateKeyToAddress(privateKey),
"0x" + address
);
});

it("generate random 256-bit private key & salt, 128-bit initialization vector", function () {
var plaintext = ethKeys.create();
var plaintext = keythereum.create();
assert.property(plaintext, "privateKey");
assert.isNotNull(plaintext.privateKey);
assert.property(plaintext, "iv");
Expand All @@ -66,7 +69,7 @@ describe("Key derivation", function () {
var test = function (t) {
it("[sync] " + t.input.kdf, function () {
this.timeout(TIMEOUT);
var derivedKey = ethKeys.deriveKey(
var derivedKey = keythereum.deriveKey(
t.input.password,
t.input.salt,
t.input.kdf
Expand All @@ -76,7 +79,7 @@ describe("Key derivation", function () {
if (t.input.kdf !== "scrypt") {
it("[async] " + t.input.kdf, function (done) {
this.timeout(TIMEOUT);
ethKeys.deriveKey(
keythereum.deriveKey(
t.input.password,
t.input.salt,
t.input.kdf,
Expand Down Expand Up @@ -119,7 +122,7 @@ describe("Message authentication code", function () {

var test = function (t) {
it("convert " + JSON.stringify(t.input) + " -> " + t.output, function () {
var mac = ethKeys.getMAC(t.input.derivedKey, t.input.ciphertext);
var mac = keythereum.getMAC(t.input.derivedKey, t.input.ciphertext);
assert.strictEqual(mac, t.output);
});
};
Expand Down Expand Up @@ -197,7 +200,7 @@ describe("Dump private key", function () {
var test = function (t) {
it(t.input.kdf, function (done) {
this.timeout(TIMEOUT);
ethKeys.dump(
keythereum.dump(
t.input.password,
t.input.privateKey,
t.input.salt,
Expand All @@ -211,7 +214,7 @@ describe("Dump private key", function () {
assert.strictEqual(json.address, t.expected.address);
assert.strictEqual(
json.Crypto.cipher,
ethKeys.constants.cipher
keythereum.constants.cipher
);
assert.strictEqual(
json.Crypto.cipher,
Expand Down Expand Up @@ -240,23 +243,23 @@ describe("Dump private key", function () {
);
assert.strictEqual(
json.Crypto.kdfparams.n,
ethKeys.constants.scrypt.n
keythereum.constants.scrypt.n
);
assert.strictEqual(
json.Crypto.kdfparams.r,
t.expected.Crypto.kdfparams.r
);
assert.strictEqual(
json.Crypto.kdfparams.r,
ethKeys.constants.scrypt.r
keythereum.constants.scrypt.r
);
assert.strictEqual(
json.Crypto.kdfparams.p,
t.expected.Crypto.kdfparams.p
);
assert.strictEqual(
json.Crypto.kdfparams.p,
ethKeys.constants.scrypt.p
keythereum.constants.scrypt.p
);
} else {
assert.strictEqual(
Expand All @@ -265,15 +268,15 @@ describe("Dump private key", function () {
);
assert.strictEqual(
json.Crypto.kdfparams.c,
ethKeys.constants.pbkdf2.c
keythereum.constants.pbkdf2.c
);
assert.strictEqual(
json.Crypto.kdfparams.prf,
t.expected.Crypto.kdfparams.prf
);
assert.strictEqual(
json.Crypto.kdfparams.prf,
ethKeys.constants.pbkdf2.prf
keythereum.constants.pbkdf2.prf
);
}
assert.strictEqual(
Expand All @@ -282,7 +285,7 @@ describe("Dump private key", function () {
);
assert.strictEqual(
json.Crypto.kdfparams.dklen,
ethKeys.constants.pbkdf2.dklen
keythereum.constants.pbkdf2.dklen
);
assert.strictEqual(
json.Crypto.kdfparams.salt,
Expand Down Expand Up @@ -393,7 +396,7 @@ describe("Export to file", function () {
};

it("export key to json file", function (done) {
ethKeys.exportToFile(json, function (outfile) {
keythereum.exportToFile(json, function (outfile) {
assert.strictEqual(outfile.slice(0, 5), "UTC--");
assert.isAbove(outfile.indexOf(json.address), -1);
done();
Expand Down

0 comments on commit 5090cd6

Please sign in to comment.