|
|
@ -165,7 +165,7 @@ WalletService.getInstance = function(opts) { |
|
|
|
* @param {Object} opts |
|
|
|
* @param {string} opts.copayerId - The copayer id making the request. |
|
|
|
* @param {string} opts.message - The contents of the request to be signed. |
|
|
|
* @param {string} opts.signature - Signature of message to be verified using the copayer's requestPubKey |
|
|
|
* @param {string} opts.signature - Signature of message to be verified using one of the copayer's requestPubKeys |
|
|
|
* @param {string} opts.clientVersion - A string that identifies the client issuing the request |
|
|
|
*/ |
|
|
|
WalletService.getInstanceWithAuth = function(opts, cb) { |
|
|
@ -177,7 +177,7 @@ WalletService.getInstanceWithAuth = function(opts, cb) { |
|
|
|
if (err) return cb(err); |
|
|
|
if (!copayer) return cb(new ClientError(Errors.codes.NOT_AUTHORIZED, 'Copayer not found')); |
|
|
|
|
|
|
|
var isValid = server._verifySignature(opts.message, opts.signature, copayer.requestPubKey); |
|
|
|
var isValid = server._verifySignatureAgainstArray(opts.message, opts.signature, copayer.requestPubKeys); |
|
|
|
if (!isValid) |
|
|
|
return cb(new ClientError(Errors.codes.NOT_AUTHORIZED, 'Invalid signature')); |
|
|
|
|
|
|
@ -276,10 +276,24 @@ WalletService.prototype.getWallet = function(opts, cb) { |
|
|
|
* Verifies a signature |
|
|
|
* @param text |
|
|
|
* @param signature |
|
|
|
* @param pubKey |
|
|
|
* @param pubKeys |
|
|
|
*/ |
|
|
|
WalletService.prototype._verifySignature = function(text, signature, pubKey) { |
|
|
|
return WalletUtils.verifyMessage(text, signature, pubKey); |
|
|
|
WalletService.prototype._verifySignature = function(text, signature, pubkey) { |
|
|
|
return WalletUtils.verifyMessage(text, signature, pubkey); |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
* Verifies signature againt a collection of pubkeys |
|
|
|
* @param text |
|
|
|
* @param signature |
|
|
|
* @param pubKeys |
|
|
|
*/ |
|
|
|
WalletService.prototype._verifySignatureAgainstArray = function(text, signature, pubKeys) { |
|
|
|
var self = this; |
|
|
|
return _.any(pubKeys, function(item) { |
|
|
|
return self._verifySignature(text, signature, item.key); |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
/** |
|
|
@ -545,7 +559,7 @@ WalletService.prototype.verifyMessageSignature = function(opts, cb) { |
|
|
|
|
|
|
|
var copayer = wallet.getCopayer(self.copayerId); |
|
|
|
|
|
|
|
var isValid = self._verifySignature(opts.message, opts.signature, copayer.requestPubKey); |
|
|
|
var isValid = self._verifySignatureAgainstArray(opts.message, opts.signature, copayer.requestPubKeys); |
|
|
|
return cb(null, isValid); |
|
|
|
}); |
|
|
|
}; |
|
|
@ -966,7 +980,7 @@ WalletService.prototype.createTx = function(opts, cb) { |
|
|
|
hash = WalletUtils.getProposalHash(header) |
|
|
|
} |
|
|
|
|
|
|
|
if (!self._verifySignature(hash, opts.proposalSignature, copayer.requestPubKey)) |
|
|
|
if (!self._verifySignatureAgainstArray(hash, opts.proposalSignature, copayer.requestPubKeys)) |
|
|
|
return cb(new ClientError('Invalid proposal signature')); |
|
|
|
|
|
|
|
self._canCreateTx(self.copayerId, function(err, canCreate) { |
|
|
|