if decrypted, txp.message contains cleartext and txp.encryptedMessage contains cyphertext

This commit is contained in:
Ivan Socolsky 2015-02-20 15:21:19 -03:00
parent 5a3b754ea1
commit 266db38fa4
4 changed files with 20 additions and 19 deletions

View File

@ -30,7 +30,7 @@ client.getStatus(function(err, res) {
if (!_.isEmpty(res.pendingTxps)) {
console.log("* TX Proposals:")
_.each(res.pendingTxps, function(x) {
console.log("\t%s [%s by %s] %dSAT => %s", utils.shortID(x.id), x.decryptedMessage, x.creatorName, x.amount, x.toAddress);
console.log("\t%s [%s by %s] %dSAT => %s", utils.shortID(x.id), x.message, x.creatorName, x.amount, x.toAddress);
if (!_.isEmpty(x.actions)) {
console.log('\t\t * Actions');

View File

@ -33,7 +33,8 @@ function _decryptMessage(message, encryptingKey) {
function _processTxps(txps, encryptingKey) {
_.each([].concat(txps), function(txp) {
txp.decryptedMessage = _decryptMessage(txp.message, encryptingKey);
txp.encryptedMessage = txp.message;
txp.message = _decryptMessage(txp.message, encryptingKey);
_.each(txp.actions, function(action) {
action.comment = _decryptMessage(action.comment, encryptingKey);
});

View File

@ -35,8 +35,8 @@ Verifier.checkCopayers = function(copayers, walletPrivKey, myXPrivKey, n) {
}
// Not signed pub keys
if (!copayer.xPubKey || !copayer.xPubKeySignature ||
!WalletUtils.verifyMessage(copayer.xPubKey, copayer.xPubKeySignature, walletPubKey)) {
if (!copayer.xPubKey || !copayer.xPubKeySignature ||
!WalletUtils.verifyMessage(copayer.xPubKey, copayer.xPubKeySignature, walletPubKey)) {
log.error('Invalid signatures in server response');
error = true;
}
@ -62,9 +62,9 @@ Verifier.checkTxProposal = function(data, txp) {
if (!creatorXPubKey) return false;
var creatorSigningPubKey = (new Bitcore.HDPublicKey(creatorXPubKey)).derive('m/1/0').publicKey.toString();
var hash = WalletUtils.getProposalHash(txp.toAddress, txp.amount, txp.message);
var hash = WalletUtils.getProposalHash(txp.toAddress, txp.amount, txp.encryptedMessage || txp.message);
log.debug('Regenerating & verifying tx proposal hash -> Hash: ', hash, ' Signature: ', txp.proposalSignature);
if (!WalletUtils.verifyMessage(hash, txp.proposalSignature, creatorSigningPubKey))
if (!WalletUtils.verifyMessage(hash, txp.proposalSignature, creatorSigningPubKey))
return false;
return Verifier.checkAddress(data, txp.changeAddress);

View File

@ -425,7 +425,7 @@ describe('client API ', function() {
var opts = {
amount: 120000000,
toAddress: 'n2TBMPzPECGUfcT2EByiTJ12TPZkhN2mN5',
message: 'hola 1-1',
message: 'hello 1-1',
};
clients[0].sendTxProposal(opts, function(err, x) {
should.not.exist(err);
@ -462,7 +462,7 @@ describe('client API ', function() {
should.not.exist(err);
clients[2].getTxProposals({}, function(err, txs) {
should.not.exist(err);
txs[0].decryptedMessage.should.equal('some message');
txs[0].message.should.equal('some message');
txs[0].actions[0].comment.should.equal('rejection comment');
done();
});
@ -523,7 +523,7 @@ describe('client API ', function() {
var opts = {
amount: 10000,
toAddress: 'n2TBMPzPECGUfcT2EByiTJ12TPZkhN2mN5',
message: 'hola',
message: 'hello',
};
clients[0].sendTxProposal(opts, function(err, x) {
should.not.exist(err);
@ -562,7 +562,7 @@ describe('client API ', function() {
var opts = {
amount: 10000,
toAddress: 'n2TBMPzPECGUfcT2EByiTJ12TPZkhN2mN5',
message: 'hola',
message: 'hello',
};
clients[0].sendTxProposal(opts, function(err, x) {
should.not.exist(err);
@ -601,7 +601,7 @@ describe('client API ', function() {
var opts = {
amount: 10000,
toAddress: 'n2TBMPzPECGUfcT2EByiTJ12TPZkhN2mN5',
message: 'hola',
message: 'hello',
};
clients[0].sendTxProposal(opts, function(err, x) {
should.not.exist(err);
@ -643,7 +643,7 @@ describe('client API ', function() {
var opts = {
amount: 10000000,
toAddress: 'n2TBMPzPECGUfcT2EByiTJ12TPZkhN2mN5',
message: 'hola 1-1',
message: 'hello 1-1',
};
clients[0].sendTxProposal(opts, function(err, x) {
should.not.exist(err);
@ -670,7 +670,7 @@ describe('client API ', function() {
var opts = {
amount: 10000,
toAddress: 'n2TBMPzPECGUfcT2EByiTJ12TPZkhN2mN5',
message: 'hola 1-1',
message: 'hello 1-1',
};
clients[0].sendTxProposal(opts, function(err, x) {
should.not.exist(err);
@ -701,14 +701,14 @@ describe('client API ', function() {
var opts = {
amount: 10000,
toAddress: 'n2TBMPzPECGUfcT2EByiTJ12TPZkhN2mN5',
message: 'hola 1-1',
message: 'hello 1-1',
};
clients[0].sendTxProposal(opts, function(err, x) {
should.not.exist(err);
x.status.should.equal('pending');
x.requiredRejections.should.equal(2);
x.requiredSignatures.should.equal(2);
clients[0].rejectTxProposal(x, 'no me gusto', function(err, tx) {
clients[0].rejectTxProposal(x, 'wont sign', function(err, tx) {
should.not.exist(err, err);
tx.status.should.equal('pending');
clients[1].signTxProposal(x, function(err, tx) {
@ -735,7 +735,7 @@ describe('client API ', function() {
var opts = {
amount: 10000,
toAddress: 'n2TBMPzPECGUfcT2EByiTJ12TPZkhN2mN5',
message: 'hola 1-1',
message: 'hello 1-1',
};
clients[0].sendTxProposal(opts, function(err, x) {
should.not.exist(err);
@ -743,13 +743,13 @@ describe('client API ', function() {
x.requiredRejections.should.equal(2);
x.requiredSignatures.should.equal(3);
clients[0].rejectTxProposal(x, 'no me gusto', function(err, tx) {
clients[0].rejectTxProposal(x, 'wont sign', function(err, tx) {
should.not.exist(err, err);
tx.status.should.equal('pending');
clients[1].signTxProposal(x, function(err, tx) {
should.not.exist(err);
tx.status.should.equal('pending');
clients[2].rejectTxProposal(x, 'tampoco me gusto', function(err, tx) {
clients[2].rejectTxProposal(x, 'me neither', function(err, tx) {
should.not.exist(err);
tx.status.should.equal('rejected');
done();
@ -770,7 +770,7 @@ describe('client API ', function() {
var opts = {
amount: 10000,
toAddress: 'n2TBMPzPECGUfcT2EByiTJ12TPZkhN2mN5',
message: 'hola 1-1',
message: 'hello 1-1',
};
clients[0].sendTxProposal(opts, function(err, x) {
should.not.exist(err);