derive signingPubKey from correct xPub
This commit is contained in:
parent
cdbbbec640
commit
8ca3b65fad
|
@ -54,8 +54,13 @@ Verifier.checkCopayers = function(copayers, walletPrivKey, myXPrivKey, n) {
|
||||||
|
|
||||||
Verifier.checkTxProposal = function(data, txp) {
|
Verifier.checkTxProposal = function(data, txp) {
|
||||||
var hash = WalletUtils.getProposalHash(txp.toAddress, txp.amount, txp.message);
|
var hash = WalletUtils.getProposalHash(txp.toAddress, txp.amount, txp.message);
|
||||||
var signingPubKey = Bitcore.PrivateKey.fromString(data.signingPrivKey).toPublicKey().toString();
|
var creatorXPubKey = _.find(data.publicKeyRing, function(xPubKey) {
|
||||||
if (!WalletUtils.verifyMessage(hash, txp.proposalSignature, signingPubKey)) return false;
|
if (WalletUtils.xPubToCopayerId(xPubKey) === txp.creatorId) return true;
|
||||||
|
});
|
||||||
|
if (!creatorXPubKey) return false;
|
||||||
|
|
||||||
|
var creatorSigningPubKey = (new Bitcore.HDPublicKey(creatorXPubKey)).derive('m/1/0').publicKey.toString();
|
||||||
|
if (!WalletUtils.verifyMessage(hash, txp.proposalSignature, creatorSigningPubKey)) return false;
|
||||||
|
|
||||||
return Verifier.checkAddress(data, txp.changeAddress);
|
return Verifier.checkAddress(data, txp.changeAddress);
|
||||||
};
|
};
|
||||||
|
|
|
@ -222,7 +222,9 @@ describe('client API ', function() {
|
||||||
it.skip('should sign tx proposal', function(done) {});
|
it.skip('should sign tx proposal', function(done) {});
|
||||||
|
|
||||||
it('should detect fake tx proposal signature', function(done) {
|
it('should detect fake tx proposal signature', function(done) {
|
||||||
|
client.storage.fs.readFile = sinon.stub().yields(null, JSON.stringify(TestData.storage.complete11));
|
||||||
var txp = {
|
var txp = {
|
||||||
|
creatorId: '56cb00afd85f4f37fa900ac4e367676f2eb6189a773633eb9f119eb21a22ba44',
|
||||||
toAddress: '2N3fA6wDtnebzywPkGuNK9KkFaEzgbPRRTq',
|
toAddress: '2N3fA6wDtnebzywPkGuNK9KkFaEzgbPRRTq',
|
||||||
amount: 100000,
|
amount: 100000,
|
||||||
message: 'some message',
|
message: 'some message',
|
||||||
|
|
|
@ -32,7 +32,7 @@ var storage = {
|
||||||
"network": "livenet"
|
"network": "livenet"
|
||||||
},
|
},
|
||||||
complete11: {
|
complete11: {
|
||||||
"copayerId": "036ed70f51adf14e3e55aba727d28adec1851aff6865552aa9ec9b9dbafecd4a87",
|
"copayerId": "56cb00afd85f4f37fa900ac4e367676f2eb6189a773633eb9f119eb21a22ba44",
|
||||||
"xPrivKey": "tprv8ZgxMBicQKsPdjYWSKKh8SuMZAQ6K3J6v5H3A8ZVyyvXk4h1xft3qeRTmCZbxQB77n3ndfF6G4AevqgpiAVuCmZqYURH3wzSQviTvP1nkYN",
|
"xPrivKey": "tprv8ZgxMBicQKsPdjYWSKKh8SuMZAQ6K3J6v5H3A8ZVyyvXk4h1xft3qeRTmCZbxQB77n3ndfF6G4AevqgpiAVuCmZqYURH3wzSQviTvP1nkYN",
|
||||||
"publicKeyRing": ["tpubD6NzVbkrYhZ4XCaJKxzHXrZU8Bv2UNV1VNspSeboQFivaYwnb4he293KwLPxnNNSBEj3RAE5EEaHqPWatzexGd613hGMLLQz5BEgjtpgWnZ"],
|
"publicKeyRing": ["tpubD6NzVbkrYhZ4XCaJKxzHXrZU8Bv2UNV1VNspSeboQFivaYwnb4he293KwLPxnNNSBEj3RAE5EEaHqPWatzexGd613hGMLLQz5BEgjtpgWnZ"],
|
||||||
"network": "testnet",
|
"network": "testnet",
|
||||||
|
|
Loading…
Reference in New Issue