Browse Source

upgraded ecurve from 0.8.0 to 1.0.0

master
JP Richardson 10 years ago
parent
commit
f065319f65
  1. 4
      CHANGELOG.md
  2. 6
      lib/hdkey.js
  3. 2
      package.json
  4. 4
      test/hdkey.test.js

4
CHANGELOG.md

@ -1,3 +1,7 @@
0.2.0 / 2014-06-25
------------------
- upgraded `"ecurve": "^0.8.0"` to `"ecurve": "^1.0.0"`
0.1.0 / 2014-06-16
------------------
- removed semicolons per http://cryptocoinjs.com/about/contributing/#semicolons

6
lib/hdkey.js

@ -39,7 +39,7 @@ Object.defineProperty(HDKey.prototype, 'privateKey', {
assert.equal(value.length, 32, 'Private key must be 32 bytes.')
this._privateKey = value
this._privateKeyInteger = BigInteger.fromBuffer(this._privateKey)
this._publicKey = ecparams.params.G.multiply(this._privateKeyInteger).getEncoded(true) //force compressed point
this._publicKey = ecparams.G.multiply(this._privateKeyInteger).getEncoded(true) //force compressed point
this._identifier = hash160(this.publicKey)
this._fingerprint = this._identifier.slice(0, 4).readUInt32BE(0)
}
@ -128,10 +128,10 @@ HDKey.prototype.deriveChild = function(index) {
// Private parent key -> private child key
if (this.privateKey) {
// ki = parse256(IL) + kpar (mod n)
var ki = pIL.add(BigInteger.fromBuffer(this.privateKey)).mod(ecparams.params.n)
var ki = pIL.add(BigInteger.fromBuffer(this.privateKey)).mod(ecparams.n)
// In case parse256(IL) >= n or ki == 0, one should proceed with the next value for i
if (pIL.compareTo(ecparams.params.n) >= 0 || ki.signum() === 0) {
if (pIL.compareTo(ecparams.n) >= 0 || ki.signum() === 0) {
return this.derive(index + 1)
}

2
package.json

@ -33,7 +33,7 @@
"dependencies": {
"sha512": "0.0.1",
"bigi": "^1.1.0",
"ecurve": "^0.8.0"
"ecurve": "^1.0.0"
},
"scripts": {
"unit": "./node_modules/.bin/mocha",

4
test/hdkey.test.js

@ -48,7 +48,7 @@ describe('hdkey', function() {
it('should not throw if key is 33 bytes (compressed)', function() {
var priv = secureRandom.randomBuffer(32)
var pub = ecparams.params.G.multiply(BigInteger.fromBuffer(priv)).getEncoded(true)
var pub = ecparams.G.multiply(BigInteger.fromBuffer(priv)).getEncoded(true)
assert.equal(pub.length, 33)
var hdkey = new HDKey()
hdkey.publicKey = pub
@ -56,7 +56,7 @@ describe('hdkey', function() {
it('should not throw if key is 65 bytes (not compressed)', function() {
var priv = secureRandom.randomBuffer(32)
var pub = ecparams.params.G.multiply(BigInteger.fromBuffer(priv)).getEncoded(false)
var pub = ecparams.G.multiply(BigInteger.fromBuffer(priv)).getEncoded(false)
assert.equal(pub.length, 65)
var hdkey = new HDKey()
hdkey.publicKey = pub

Loading…
Cancel
Save