blockstack-keychains
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -6,2 +6,3 @@ 'use strict'; | ||
}); | ||
exports.getChildKeypair = getChildKeypair; | ||
@@ -79,4 +80,2 @@ require('core-js/shim'); | ||
} | ||
} | ||
exports.default = getChildKeypair; | ||
} |
@@ -10,2 +10,5 @@ 'use strict'; | ||
}); | ||
exports.PublicKeychain = exports.PrivateKeychain = undefined; | ||
exports.isWIF = isWIF; | ||
exports.numberToEntropy = numberToEntropy; | ||
@@ -24,4 +27,6 @@ require('core-js/shim'); | ||
var _derivation2 = _interopRequireDefault(_derivation); | ||
var _bip = require('bip39'); | ||
var _bip2 = _interopRequireDefault(_bip); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -53,3 +58,3 @@ | ||
var PrivateKeychain = function () { | ||
var PrivateKeychain = exports.PrivateKeychain = function () { | ||
function PrivateKeychain(privateKey) { | ||
@@ -89,2 +94,7 @@ _classCallCheck(this, PrivateKeychain); | ||
}, { | ||
key: 'mnemonic', | ||
value: function mnemonic() { | ||
return _bip2.default.entropyToMnemonic(this.privateKey('hex')); | ||
} | ||
}, { | ||
key: 'wif', | ||
@@ -105,3 +115,3 @@ value: function wif() { | ||
} | ||
var childKeypair = (0, _derivation2.default)(this.ecPair, entropy); | ||
var childKeypair = (0, _derivation.getChildKeypair)(this.ecPair, entropy); | ||
return new PrivateKeychain(childKeypair); | ||
@@ -129,3 +139,3 @@ } | ||
var PublicKeychain = function () { | ||
var PublicKeychain = exports.PublicKeychain = function () { | ||
function PublicKeychain(publicKey) { | ||
@@ -176,3 +186,3 @@ _classCallCheck(this, PublicKeychain); | ||
} | ||
var childKeypair = (0, _derivation2.default)(this.ecPair, entropy); | ||
var childKeypair = (0, _derivation.getChildKeypair)(this.ecPair, entropy); | ||
return new PublicKeychain(childKeypair); | ||
@@ -198,8 +208,2 @@ } | ||
return PublicKeychain; | ||
}(); | ||
exports.default = { | ||
PrivateKeychain: PrivateKeychain, | ||
PublicKeychain: PublicKeychain, | ||
numberToEntropy: numberToEntropy | ||
}; | ||
}(); |
@@ -6,2 +6,3 @@ 'use strict'; | ||
}); | ||
exports.getEntropy = getEntropy; | ||
@@ -13,8 +14,6 @@ require('core-js/shim'); | ||
function getEntropy(numberOfBytes) { | ||
if (!numberOfBytes) numberOfBytes = 32; | ||
if (!numberOfBytes) { | ||
numberOfBytes = 32; | ||
} | ||
return (0, _crypto.randomBytes)(numberOfBytes); | ||
} | ||
exports.default = { | ||
getEntropy: getEntropy | ||
}; | ||
} |
{ | ||
"name": "blockstack-keychains", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Library for creating elliptic curve keypairs and deriving child keys", | ||
"main": "index.js", | ||
"main": "lib/index", | ||
"scripts": { | ||
"compile": "babel --presets es2015 src -d lib", | ||
"test": "npm run compile; node test.js", | ||
"test": "npm run compile; node lib/unitTests.js", | ||
"prepublish": "npm run compile" | ||
@@ -19,2 +19,3 @@ }, | ||
"bigi": "^1.4.1", | ||
"bip39": "^2.2.0", | ||
"bitcoinjs-lib": "^2.1.4", | ||
@@ -21,0 +22,0 @@ "bs58check": "^1.0.8", |
@@ -68,2 +68,8 @@ # Blockstack Keychains JS | ||
### Private Keys | ||
```es6 | ||
let privateKey = privateKeychain.privateKey('hex') | ||
``` | ||
### Public Keychains | ||
@@ -73,6 +79,20 @@ | ||
let publicKeychain = privateKeychain.publicKeychain() | ||
let publicKeyString = '023db6b4e3cb22097a9b6b9c82ff6becb8cb01561fd46c3484abf22ff4dc30ee58' | ||
let publicKeychain2 = new PublicKeychain(publicKeyString) | ||
let publicKeyString = '023db6b4e3cb22097a9b6b9c82ff6becb8cb01561fd46c3484abf22ff4dc30ee58', | ||
publicKeychain2 = new PublicKeychain(publicKeyString) | ||
``` | ||
### Public Keys | ||
```es6 | ||
let publicKey = publicKeychain.publicKey('hex') | ||
``` | ||
### Mnemonics | ||
```es6 | ||
let mnemonic = privateKeychain.mnemonic() | ||
console.log(mnemonic) | ||
'aim elbow hungry involve ranch source car connect come wasp spread pet board welcome give garden virtual goose juice today over illness shove slam' | ||
``` | ||
### Entropy-derived Child Keychains | ||
@@ -79,0 +99,0 @@ |
27353
440
145
7
+ Addedbip39@^2.2.0
+ Addedbip39@2.6.0(transitive)
+ Addedpbkdf2@3.1.2(transitive)
+ Addedunorm@1.6.0(transitive)