fix xPubKeySignature verification

This commit is contained in:
Ivan Socolsky 2015-02-13 10:58:49 -03:00
parent ecf1e03480
commit 9421f0854d
1 changed files with 9 additions and 6 deletions

View File

@ -80,14 +80,17 @@ CliLib.prototype.createWallet = function(walletName, copayerName, m, n, network,
var data = this._load();
if (data) return cb('Only one wallet is supported in this version');
// Generate wallet key pair to verify copayers
var privKey = new Bitcore.PrivateKey();
var pubKey = privKey.toPublicKey();
data = {
xPrivKey: _createXPrivKey(),
m: m,
n: n,
walletPrivKey: privKey.toString(),
};
var privKey = new Bitcore.PrivateKey();
var pubKey = privKey.toPublicKey();
var args = {
name: walletName,
m: m,
@ -128,7 +131,6 @@ CliLib.prototype._joinWallet = function(data, secret, copayerName, cb) {
var secretSplit = secret.split(':');
var walletId = secretSplit[0];
var privKey = Bitcore.PrivateKey.fromString(secretSplit[1]);
var pubKey = privKey.toPublicKey();
var xPubKey = new Bitcore.HDPublicKey(data.xPrivKey);
var xPubKeySignature = SignUtils.sign(xPubKey.toString(), privKey);
@ -204,10 +206,11 @@ CliLib.prototype.status = function(cb) {
}
var wallet = body;
if (wallet.n > 1 && wallet.status === 'complete' && !data.verified) {
if (wallet.n > 0 && wallet.status === 'complete' && !data.verified) {
var pubKey = Bitcore.PrivateKey.fromString(data.walletPrivKey).toPublicKey().toString();
var fake = [];
_.each(wallet.copayers, function(copayer) {
if (!SignUtils.verify(copayer.xPubKey, copayer.xPubKeySignature, data.pubKey)) {
if (!SignUtils.verify(copayer.xPubKey, copayer.xPubKeySignature, pubKey)) {
fake.push(copayer);
}
});