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