Bump version: 0.7.3

This commit is contained in:
Nicholas Dudfield
2015-08-08 12:03:34 +07:00
parent 443d8a3b18
commit abe8d54401
3 changed files with 29 additions and 29 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "ripple-keypairs",
"version": "0.7.2",
"version": "0.7.3",
"description": "ripple key pairs",
"files": [
"dist/npm/*",
@@ -50,15 +50,15 @@
},
"repository": {
"type": "git",
"url": "git://github.com/ripple/ripple-keypairs.git"
"url": "git://github.com/sublimator/ripple-keypairs.git"
},
"engines": {
"node": ">=0.12.0"
},
"bugs": {
"url": "https://github.com/ripple/ripple-keypairs/issues"
"url": "https://github.com/sublimator/ripple-keypairs/issues"
},
"homepage": "https://github.com/ripple/ripple-keypairs#readme",
"homepage": "https://github.com/sublimator/ripple-keypairs#readme",
"author": "ndudfield@gmail.com",
"license": "ISC",
"readmeFilename": "README.md"

View File

@@ -9,7 +9,7 @@ const {Sha512, cached} = require('./utils');
/*
@param {Array} seed bytes
*/
function deriveEdKeyPairSeed(seed) {
function deriveEdKeyPairSecret(seed) {
return new Sha512().add(seed).first256();
}
@@ -45,17 +45,16 @@ class Ed25519Pair extends KeyPair {
}
@cached
key() {
if (this.seedBytes) {
const seed256 = deriveEdKeyPairSeed(this.seedBytes);
return Ed25519.keyFromSecret(seed256);
}
return Ed25519.keyFromPublic(this.pubKeyCanonicalBytes().slice(1));
pubKeyCanonicalBytes() {
return [0xED].concat(this.key().pubBytes());
}
@cached
pubKeyCanonicalBytes() {
return [0xED].concat(this.key().pubBytes());
key() {
if (this.seedBytes) {
return Ed25519.keyFromSecret(deriveEdKeyPairSecret(this.seedBytes));
}
return Ed25519.keyFromPublic(this.pubKeyCanonicalBytes().slice(1));
}
}

View File

@@ -79,18 +79,6 @@ class K256Pair extends KeyPair {
return this._createSignature(message).toDER();
}
_createSignature(message) {
return this.key().sign(this.hashMessage(message), {canonical: true});
}
/*
@param {Array<Byte>} message - (bytes)
@return {Array<Byte>} - 256 bit hash of the message
*/
hashMessage(message) {
return hashjs.sha512().update(message).digest().slice(0, 32);
}
/*
@param {Array<Byte>} message - bytes
@param {Array<Byte>} signature - DER encoded signature bytes
@@ -105,6 +93,23 @@ class K256Pair extends KeyPair {
}
}
@cached
pubKeyCanonicalBytes() {
return this.key().getPublic().encodeCompressed();
}
_createSignature(message) {
return this.key().sign(this.hashMessage(message), {canonical: true});
}
/*
@param {Array<Byte>} message - (bytes)
@return {Array<Byte>} - 256 bit hash of the message
*/
hashMessage(message) {
return hashjs.sha512().update(message).digest().slice(0, 32);
}
@cached
key() {
if (this.seedBytes) {
@@ -114,10 +119,6 @@ class K256Pair extends KeyPair {
return secp256k1.keyFromPublic(this.pubKeyCanonicalBytes());
}
@cached
pubKeyCanonicalBytes() {
return this.key().getPublic().encodeCompressed();
}
}
module.exports = {