Skip to content
Permalink
Browse files

Allow only one signature per public key when validation multisignatur…

…e transactions
  • Loading branch information...
4miners committed Nov 9, 2018
1 parent 9c958b4 commit 7d10367d67915914c1fad22e3608d4ac36dc02f1
Showing with 28 additions and 22 deletions.
  1. +28 −22 logic/transaction.js
@@ -586,32 +586,38 @@ class Transaction {
}
}

// Verify multisignatures
// Verify signatures of multisignatures transactions
if (transaction.signatures) {
for (let d = 0; d < transaction.signatures.length; d++) {
valid = false;

for (let s = 0; s < multisignatures.length; s++) {
if (
transaction.requesterPublicKey &&
multisignatures[s] === transaction.requesterPublicKey
) {
continue; // eslint-disable-line no-continue
}

if (
this.verifySignature(
transaction,
multisignatures[s],
transaction.signatures[d]
)
) {
valid = true;
let isValidSignature;
const keygroup = multisignatures;

// Iterate over signatures
for (let s = 0; s < transaction.signatures.length; s++) {
// Mark currently checked signature as invalid
isValidSignature = false;

// Iterate over public keys in keygroup, check if signature is valid for
for (let k = 0; k < keygroup.length; k++) {
try {
if (this.verifySignature(transaction, keygroup[k], transaction.signatures[s])) {
// If signature is valid for particular public key - remove this public key from the array
keygroup.splice(k, 1);
isValidSignature = true;
}
} catch (e) {
return setImmediate(cb, `Failed to verify multisignature: ${e.toString()}`);
}
}

if (!valid) {
return setImmediate(cb, 'Failed to verify multisignature');
if (!isValidSignature) {
const err = `Failed to verify multisignature: ${transaction.signatures[s]}`;

// Check against exceptions
if (exceptions.duplicatedSignatures[transaction.id] && exceptions.duplicatedSignatures[transaction.id].includes(transaction.signatures[s])) {
this.scope.logger.warn('Transaction accepted due to exceptions', { err, transaction: JSON.stringify(transaction) });
} else {
return setImmediate(cb, err);
}
}
}
}

0 comments on commit 7d10367

Please sign in to comment.
You can’t perform that action at this time.