mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-12-06 01:08:02 +00:00
Misc cleanups
This commit is contained in:
@@ -11,7 +11,6 @@ const {
|
|||||||
} = require('./utils');
|
} = require('./utils');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@private
|
|
||||||
@param {Array} seed bytes
|
@param {Array} seed bytes
|
||||||
*/
|
*/
|
||||||
function deriveEdKeyPairSeed(seed) {
|
function deriveEdKeyPairSeed(seed) {
|
||||||
@@ -20,8 +19,6 @@ function deriveEdKeyPairSeed(seed) {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* @class
|
* @class
|
||||||
* @private
|
|
||||||
* @param {Object} - key
|
|
||||||
*/
|
*/
|
||||||
function Ed25519Pair() {
|
function Ed25519Pair() {
|
||||||
KeyPair.apply(this, arguments);
|
KeyPair.apply(this, arguments);
|
||||||
@@ -66,4 +63,4 @@ Ed25519Pair.prototype.verify = function(message, signature) {
|
|||||||
return this.key().verify(message, signature);
|
return this.key().verify(message, signature);
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {Ed25519Pair};
|
module.exports = Ed25519Pair;
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ const rand = require('brorand');
|
|||||||
|
|
||||||
const {seedFromPhrase, createAccountID} = require('./utils');
|
const {seedFromPhrase, createAccountID} = require('./utils');
|
||||||
const {KeyPair, KeyType} = require('./keypair');
|
const {KeyPair, KeyType} = require('./keypair');
|
||||||
const {Ed25519Pair} = require('./ed25519');
|
const Ed25519Pair = require('./ed25519');
|
||||||
const {K256Pair} = require('./secp256k1');
|
const K256Pair = require('./secp256k1');
|
||||||
|
|
||||||
function keyPairFromSeed(seedString, options) {
|
function keyPairFromSeed(seedString, options) {
|
||||||
const decoded = codec.decodeSeed(seedString);
|
const decoded = codec.decodeSeed(seedString);
|
||||||
|
|||||||
@@ -35,10 +35,10 @@ function findk256Key(bytes, discrim) {
|
|||||||
* @param {Number} [opts.accountIndex=0] - the account number to generate
|
* @param {Number} [opts.accountIndex=0] - the account number to generate
|
||||||
* @param {Boolean} [opts.validator=false] - generate root key-pair,
|
* @param {Boolean} [opts.validator=false] - generate root key-pair,
|
||||||
* as used by validators.
|
* as used by validators.
|
||||||
* @return {bn.js} - bignumber
|
* @return {bn.js} - 256 bit scalar value
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function derivek256Secret(seed, opts={}) {
|
function derivek256Scalar(seed, opts={}) {
|
||||||
const root = opts.validator;
|
const root = opts.validator;
|
||||||
const order = secp256k1.curve.n;
|
const order = secp256k1.curve.n;
|
||||||
|
|
||||||
@@ -59,7 +59,6 @@ function derivek256Secret(seed, opts={}) {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* @class
|
* @class
|
||||||
* @private
|
|
||||||
*/
|
*/
|
||||||
function K256Pair({validator}) {
|
function K256Pair({validator}) {
|
||||||
KeyPair.apply(this, arguments);
|
KeyPair.apply(this, arguments);
|
||||||
@@ -76,7 +75,7 @@ K256Pair.fromSeed = function(seedBytes, opts={}) {
|
|||||||
hasCachedProperty(K256Pair, 'key', function() {
|
hasCachedProperty(K256Pair, 'key', function() {
|
||||||
if (this.seedBytes) {
|
if (this.seedBytes) {
|
||||||
const options = {validator: this.validator};
|
const options = {validator: this.validator};
|
||||||
return secp256k1.keyFromPrivate(derivek256Secret(this.seedBytes, options));
|
return secp256k1.keyFromPrivate(derivek256Scalar(this.seedBytes, options));
|
||||||
}
|
}
|
||||||
return secp256k1.keyFromPublic(this.pubKeyCanonicalBytes());
|
return secp256k1.keyFromPublic(this.pubKeyCanonicalBytes());
|
||||||
});
|
});
|
||||||
@@ -117,8 +116,4 @@ K256Pair.prototype.verify = function(message, signature) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = K256Pair;
|
||||||
derivek256Secret,
|
|
||||||
findk256Key,
|
|
||||||
K256Pair
|
|
||||||
};
|
|
||||||
|
|||||||
Reference in New Issue
Block a user