Comparing version 0.8.0 to 1.0.0
@@ -0,1 +1,5 @@ | ||
1.0.0 / 2016-03-26 | ||
------------------ | ||
- upgraded to `secp256k1`. [#15][#15] | ||
0.8.0 / 2014-09-29 | ||
@@ -47,3 +51,3 @@ ------------------ | ||
* removed `sign()` and `verify()`, methods can be accessed from [ecdsa](https://github.com/cryptocoinjs/ecdsa) | ||
* added `privateExportKey` | ||
* added `privateExportKey` | ||
* removed `getExportedPrivateKey`, note that `getExportedPrivateKey` was essentially just a way to get WIF | ||
@@ -80,3 +84,3 @@ * removed `decodeString()`, use package [coinstring][coinstring] in its place | ||
------------------ | ||
* changed package name | ||
* changed package name | ||
* removed AMD support | ||
@@ -88,2 +92,31 @@ | ||
[coinstring]: https://github.com/cryptocoinjs/coinstring | ||
[coinstring]: https://github.com/cryptocoinjs/coinstring | ||
<!--- secp256k1 instead ecurve --> | ||
[#14]: https://github.com/cryptocoinjs/eckey/pull/14 | ||
<!--- Private key [1, n - 1] range --> | ||
[#13]: https://github.com/cryptocoinjs/eckey/issues/13 | ||
<!--- Pass the `compressed` flag when used without `new` --> | ||
[#12]: https://github.com/cryptocoinjs/eckey/pull/12 | ||
<!--- Fixed variable name --> | ||
[#11]: https://github.com/cryptocoinjs/eckey/pull/11 | ||
<!--- Repository description --> | ||
[#10]: https://github.com/cryptocoinjs/eckey/issues/10 | ||
<!--- Input is undefined --> | ||
[#9]: https://github.com/cryptocoinjs/eckey/issues/9 | ||
<!--- Retarget for just NodeJS and Browserify --> | ||
[#8]: https://github.com/cryptocoinjs/eckey/issues/8 | ||
<!--- Transition from convert-hex to binstring --> | ||
[#7]: https://github.com/cryptocoinjs/eckey/issues/7 | ||
<!--- More explicit setting of testnet / prod net --> | ||
[#6]: https://github.com/cryptocoinjs/eckey/issues/6 | ||
<!--- Adding checksum checks in ECkey decode strings --> | ||
[#5]: https://github.com/cryptocoinjs/eckey/pull/5 | ||
<!--- update deps - makes eckey npm installable --> | ||
[#4]: https://github.com/cryptocoinjs/eckey/pull/4 | ||
<!--- doesn't install: npm ERR! 404 'cryptocoin-base58' is not in the npm registry --> | ||
[#3]: https://github.com/cryptocoinjs/eckey/issues/3 | ||
<!--- Fixed getExportedPrivateKey() returning uncompressed private key --> | ||
[#2]: https://github.com/cryptocoinjs/eckey/pull/2 | ||
<!--- fix code typo [bug] --> | ||
[#1]: https://github.com/cryptocoinjs/eckey/issues/1 |
var crypto = require('crypto') | ||
var secp256k1 = require('secp256k1') | ||
var ecurve = require('ecurve') | ||
var ecparams = ecurve.getCurveByName('secp256k1') | ||
var BigInteger = require('bigi') | ||
function ECKey (bytes, compressed) { | ||
if (!(this instanceof ECKey)) return new ECKey(bytes, compressed) | ||
if (typeof compressed == 'boolean') | ||
this._compressed = compressed | ||
else | ||
this._compressed = true | ||
if (bytes) | ||
this.privateKey = bytes | ||
this._compressed = typeof compressed === 'boolean' ? compressed : true | ||
if (bytes) this.privateKey = bytes | ||
} | ||
/******************** | ||
* GET/SET PROPERTIES | ||
********************/ | ||
Object.defineProperty(ECKey.prototype, 'privateKey', { | ||
enumerable: true, configurable: true, | ||
get: function() { | ||
get: function () { | ||
return this.key | ||
}, | ||
set: function(bytes) { | ||
set: function (bytes) { | ||
var byteArr | ||
@@ -43,15 +31,13 @@ if (Buffer.isBuffer(bytes)) { | ||
if (bytes.length != 32) | ||
throw new Error("private key bytes must have a length of 32") | ||
if (bytes.length !== 32) throw new Error('private key bytes must have a length of 32') | ||
//_exportKey => privateKey + (0x01 if compressed) | ||
if (this._compressed) | ||
// _exportKey => privateKey + (0x01 if compressed) | ||
if (this._compressed) { | ||
this._exportKey = Buffer.concat([ this.key, new Buffer([0x01]) ]) | ||
else | ||
this._exportKey = Buffer.concat([ this.key ]) //clone key as opposed to passing a reference (relevant to Node.js only) | ||
} else { | ||
this._exportKey = Buffer.concat([ this.key ]) // clone key as opposed to passing a reference (relevant to Node.js only) | ||
} | ||
this.keyBigInteger = BigInteger.fromByteArrayUnsigned(byteArr) | ||
//reset | ||
this._publicPoint = null | ||
// reset | ||
this._publicKey = null | ||
this._pubKeyHash = null | ||
@@ -62,3 +48,3 @@ } | ||
Object.defineProperty(ECKey.prototype, 'privateExportKey', { | ||
get: function() { | ||
get: function () { | ||
return this._exportKey | ||
@@ -69,3 +55,3 @@ } | ||
Object.defineProperty(ECKey.prototype, 'publicHash', { | ||
get: function() { | ||
get: function () { | ||
return this.pubKeyHash | ||
@@ -76,3 +62,3 @@ } | ||
Object.defineProperty(ECKey.prototype, 'pubKeyHash', { | ||
get: function() { | ||
get: function () { | ||
if (this._pubKeyHash) return this._pubKeyHash | ||
@@ -86,25 +72,17 @@ var sha = crypto.createHash('sha256').update(this.publicKey).digest() | ||
Object.defineProperty(ECKey.prototype, 'publicKey', { | ||
get: function() { | ||
return new Buffer(this.publicPoint.getEncoded(this.compressed)) | ||
get: function () { | ||
if (!this._publicKey) this._publicKey = secp256k1.publicKeyCreate(this.key, this.compressed) | ||
return new Buffer(this._publicKey) | ||
} | ||
}) | ||
Object.defineProperty(ECKey.prototype, 'publicPoint', { | ||
get: function() { | ||
if (!this._publicPoint) { | ||
this._publicPoint = ecparams.G.multiply(this.keyBigInteger) | ||
} | ||
return this._publicPoint | ||
} | ||
}) | ||
Object.defineProperty(ECKey.prototype, 'compressed', { | ||
get: function() { | ||
get: function () { | ||
return this._compressed | ||
}, | ||
set: function(val) { | ||
}, | ||
set: function (val) { | ||
var c = !!val | ||
if (c === this._compressed) return | ||
//reset key stuff | ||
// reset key stuff | ||
var pk = this.privateKey | ||
@@ -116,6 +94,2 @@ this._compressed = c | ||
/************ | ||
* METHODS | ||
************/ | ||
ECKey.prototype.toString = function (format) { | ||
@@ -126,2 +100,1 @@ return this.privateKey.toString('hex') | ||
module.exports = ECKey | ||
{ | ||
"name": "eckey", | ||
"version": "0.8.0", | ||
"version": "1.0.0", | ||
"description": "Handle private key and public keys associated with elliptic curve cryptography. Used with crypto currencies such as Bitcoin, Litecoin, Dogecoin, etc. Works in both Node.js and the browser.", | ||
@@ -17,10 +17,6 @@ "keywords": [ | ||
"devDependencies": { | ||
"mocha": "^1.20.0", | ||
"crypto-browserify": "^3.2.5", | ||
"mocha": "2.x", | ||
"secure-random": "^1.0.0", | ||
"mochify": "^1.1.3", | ||
"coveralls": "^2.10.0", | ||
"mocha-lcov-reporter": "0.0.1", | ||
"istanbul": "^0.2.10", | ||
"string": "^1.8.1", | ||
"crypto-browserify": "^3.2.5" | ||
"standard": "6.x" | ||
}, | ||
@@ -33,23 +29,9 @@ "repository": { | ||
"dependencies": { | ||
"ecurve": "^1.0.0", | ||
"bigi": "^1.1.0" | ||
"secp256k1": "^3.0.1" | ||
}, | ||
"scripts": { | ||
"test": "mocha --ui bdd", | ||
"unit": "./node_modules/.bin/mocha", | ||
"coverage": "./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha -- --reporter list test/*.js", | ||
"coveralls": "npm run-script coverage && node ./node_modules/.bin/coveralls < coverage/lcov.info" | ||
}, | ||
"testling": { | ||
"files": "test/*.js", | ||
"harness": "mocha", | ||
"browsers": [ | ||
"firefox/latest", | ||
"chrome/latest", | ||
"ie/9..latest", | ||
"safari/6..latest", | ||
"iphone/6.0..latest", | ||
"android-browser/4.2..latest" | ||
] | ||
"lint": "standard", | ||
"test": "standard && mocha --ui bdd", | ||
"unit": "mocha --ui bdd" | ||
} | ||
} |
@@ -5,7 +5,4 @@ eckey | ||
[![build status](https://secure.travis-ci.org/cryptocoinjs/eckey.png)](http://travis-ci.org/cryptocoinjs/eckey) | ||
[![Coverage Status](https://img.shields.io/coveralls/cryptocoinjs/eckey.svg)](https://coveralls.io/r/cryptocoinjs/eckey) | ||
[![Version](http://img.shields.io/npm/v/eckey.svg)](https://www.npmjs.org/package/eckey) | ||
[![browser support](https://ci.testling.com/cryptocoinjs/eckey.png)](https://ci.testling.com/cryptocoinjs/eckey) | ||
JavaScript component to handle private key and public keys associated with elliptic curve cryptography. Used with crypto currencies such as Bitcoin, Litecoin, Dogecoin, etc. Works in both Node.js and the browser. | ||
@@ -16,2 +13,2 @@ | ||
http://cryptocoinjs.com/modules/currency/eckey/ | ||
http://cryptocoinjs.com/modules/currency/eckey/ |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1
4
1
8553
5
79
13
1
+ Addedsecp256k1@^3.0.1
+ Addedbindings@1.5.0(transitive)
+ Addedbip66@1.1.5(transitive)
+ Addedbn.js@4.12.0(transitive)
+ Addedbrorand@1.1.0(transitive)
+ Addedbrowserify-aes@1.2.0(transitive)
+ Addedbuffer-xor@1.0.3(transitive)
+ Addedcipher-base@1.0.4(transitive)
+ Addedcreate-hash@1.2.0(transitive)
+ Addedcreate-hmac@1.1.7(transitive)
+ Addeddrbg.js@1.0.1(transitive)
+ Addedelliptic@6.6.0(transitive)
+ Addedevp_bytestokey@1.0.3(transitive)
+ Addedfile-uri-to-path@1.0.0(transitive)
+ Addedhash-base@3.1.0(transitive)
+ Addedhash.js@1.1.7(transitive)
+ Addedhmac-drbg@1.0.1(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedmd5.js@1.3.5(transitive)
+ Addedminimalistic-assert@1.0.1(transitive)
+ Addedminimalistic-crypto-utils@1.0.1(transitive)
+ Addednan@2.22.0(transitive)
+ Addedreadable-stream@3.6.2(transitive)
+ Addedripemd160@2.0.2(transitive)
+ Addedsecp256k1@3.8.1(transitive)
+ Addedsha.js@2.4.11(transitive)
+ Addedstring_decoder@1.3.0(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
- Removedbigi@^1.1.0
- Removedecurve@^1.0.0
- Removedbigi@1.4.2(transitive)
- Removedecurve@1.0.6(transitive)