some more optimization.
This commit is contained in:
parent
83239112e4
commit
6cf17c2b6d
@ -722,7 +722,7 @@ HDPrivateKey.prototype._build = function _build(data) {
|
||||
this.hdPrivateKey = this;
|
||||
|
||||
this.xpubkey = this.hdPublicKey.xpubkey;
|
||||
this.key = bcoin.keypair({ privateKey: this.privateKey });
|
||||
this.key = key;
|
||||
};
|
||||
|
||||
HDPrivateKey.prototype.derive = function derive(index, hardened) {
|
||||
|
||||
@ -28,18 +28,38 @@ function KeyPair(options) {
|
||||
|
||||
if (!options.privateKey && !options.publicKey)
|
||||
throw new Error('No options for keypair');
|
||||
|
||||
this.key = bcoin.ecdsa.keyPair({
|
||||
priv: options.privateKey,
|
||||
pub: options.publicKey
|
||||
});
|
||||
|
||||
this.privatePoint = this.key.getPrivate();
|
||||
this.publicPoint = this.key.getPublic();
|
||||
this.privateKey = this.getPrivateKey();
|
||||
this.publicKey = this.getPublicKey();
|
||||
}
|
||||
|
||||
KeyPair.prototype.__defineGetter__('key', function() {
|
||||
if (!this._key) {
|
||||
this._key = bcoin.ecdsa.keyPair({
|
||||
priv: this.options.privateKey,
|
||||
pub: this.options.publicKey
|
||||
});
|
||||
}
|
||||
return this._key;
|
||||
});
|
||||
|
||||
KeyPair.prototype.__defineGetter__('privatePoint', function() {
|
||||
if (!this._privatePoint)
|
||||
this._privatePoint = this.key.getPrivate();
|
||||
return this._privatePoint;
|
||||
});
|
||||
|
||||
KeyPair.prototype.__defineGetter__('publicPoint', function() {
|
||||
if (!this._publicPoint)
|
||||
this._publicPoint = this.key.getPublic();
|
||||
return this._publicPoint;
|
||||
});
|
||||
|
||||
KeyPair.prototype.__defineGetter__('privateKey', function() {
|
||||
return this.getPrivateKey();
|
||||
});
|
||||
|
||||
KeyPair.prototype.__defineGetter__('publicKey', function() {
|
||||
return this.getPublicKey();
|
||||
});
|
||||
|
||||
KeyPair.generate = function() {
|
||||
return new KeyPair(bcoin.ec.generate());
|
||||
};
|
||||
|
||||
@ -355,8 +355,7 @@ Wallet.prototype.deriveAddress = function deriveAddress(change, index) {
|
||||
key = this.accountKey.derive(data.path);
|
||||
|
||||
options = {
|
||||
privateKey: key.privateKey,
|
||||
publicKey: key.publicKey,
|
||||
key: key.key,
|
||||
compressed: key.compressed,
|
||||
change: data.change,
|
||||
index: data.index,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user