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.hdPrivateKey = this;
|
||||||
|
|
||||||
this.xpubkey = this.hdPublicKey.xpubkey;
|
this.xpubkey = this.hdPublicKey.xpubkey;
|
||||||
this.key = bcoin.keypair({ privateKey: this.privateKey });
|
this.key = key;
|
||||||
};
|
};
|
||||||
|
|
||||||
HDPrivateKey.prototype.derive = function derive(index, hardened) {
|
HDPrivateKey.prototype.derive = function derive(index, hardened) {
|
||||||
|
|||||||
@ -28,18 +28,38 @@ function KeyPair(options) {
|
|||||||
|
|
||||||
if (!options.privateKey && !options.publicKey)
|
if (!options.privateKey && !options.publicKey)
|
||||||
throw new Error('No options for keypair');
|
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() {
|
KeyPair.generate = function() {
|
||||||
return new KeyPair(bcoin.ec.generate());
|
return new KeyPair(bcoin.ec.generate());
|
||||||
};
|
};
|
||||||
|
|||||||
@ -355,8 +355,7 @@ Wallet.prototype.deriveAddress = function deriveAddress(change, index) {
|
|||||||
key = this.accountKey.derive(data.path);
|
key = this.accountKey.derive(data.path);
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
privateKey: key.privateKey,
|
key: key.key,
|
||||||
publicKey: key.publicKey,
|
|
||||||
compressed: key.compressed,
|
compressed: key.compressed,
|
||||||
change: data.change,
|
change: data.change,
|
||||||
index: data.index,
|
index: data.index,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user