mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-12-06 17:27:59 +00:00
Use elliptic Point#encodeCompressed api
This commit is contained in:
@@ -15,7 +15,7 @@ const {
|
||||
bytesToHex,
|
||||
hasCachedProperty,
|
||||
isVirtual,
|
||||
Sha512,
|
||||
Sha512
|
||||
} = require('./utils');
|
||||
|
||||
/* ---------------------------------- ENUMS --------------------------------- */
|
||||
@@ -52,15 +52,6 @@ function findk256Key(bytes, discrim) {
|
||||
|
||||
/* eslint-disable valid-jsdoc */
|
||||
|
||||
function compressedPoint(p) {
|
||||
const x = p.getX().toArray();
|
||||
const y = p.getY();
|
||||
while (x.length < 32) {
|
||||
x.unshift(0);
|
||||
}
|
||||
return [y.isEven() ? 0x02 : 0x03].concat(x);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Object} [options] -
|
||||
* @param {Number} [options.accountIndex=0] - the account number to generate
|
||||
@@ -86,7 +77,7 @@ function derivek256Secret(seed, opts={}) {
|
||||
// A seed can generate many keypairs as a function of the seed and a uint32.
|
||||
// Almost everyone just uses the first account, `0`.
|
||||
const accountIndex = opts.accountIndex || 0;
|
||||
return findk256Key(compressedPoint(publicGen), accountIndex)
|
||||
return findk256Key(publicGen.encodeCompressed(), accountIndex)
|
||||
.add(privateGen).mod(order);
|
||||
}
|
||||
|
||||
@@ -237,8 +228,8 @@ K256Pair.prototype.verify = function(message, signature) {
|
||||
};
|
||||
|
||||
function keyPairFromSeed(seedString) {
|
||||
var decoded = codec.decodeSeed(seedString);
|
||||
var pair = decoded.type === 'EdSeed' ? Ed25519Pair : K256Pair;
|
||||
const decoded = codec.decodeSeed(seedString);
|
||||
const pair = decoded.type === 'EdSeed' ? Ed25519Pair : K256Pair;
|
||||
return pair.fromSeed(decoded.bytes);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ const {
|
||||
seedFromPhrase,
|
||||
Ed25519Pair,
|
||||
keyPairFromSeed
|
||||
} = keypairs
|
||||
} = keypairs;
|
||||
|
||||
const {SerializedObject} = require('ripple-lib');
|
||||
const TX_HASH_PREFIX_SIGN = [0x53, 0x54, 0x58, 0x00];
|
||||
|
||||
Reference in New Issue
Block a user