mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-28 08:05:51 +00:00
Bump version: 0.7.3
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
Reference in New Issue
Block a user