Skip to content

Commit

Permalink
Remove support for legacy operator keys in CPrivateSendBroadcastTx
Browse files Browse the repository at this point in the history
  • Loading branch information
codablock committed Dec 31, 2018
1 parent 5f5fcc4 commit fb13b00
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 56 deletions.
67 changes: 12 additions & 55 deletions src/privatesend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,71 +98,28 @@ bool CPrivateSendBroadcastTx::Sign()

std::string strError = "";

if (deterministicMNManager->IsDIP3Active()) {
uint256 hash = GetSignatureHash();

CBLSSignature sig = activeMasternodeInfo.blsKeyOperator->Sign(hash);
if (!sig.IsValid()) {
return false;
}
sig.GetBuf(vchSig);
} else if (sporkManager.IsSporkActive(SPORK_6_NEW_SIGS)) {
uint256 hash = GetSignatureHash();

if (!CHashSigner::SignHash(hash, activeMasternodeInfo.legacyKeyOperator, vchSig)) {
LogPrintf("CPrivateSendBroadcastTx::Sign -- SignHash() failed\n");
return false;
}

if (!CHashSigner::VerifyHash(hash, activeMasternodeInfo.legacyKeyIDOperator, vchSig, strError)) {
LogPrintf("CPrivateSendBroadcastTx::Sign -- VerifyHash() failed, error: %s\n", strError);
return false;
}
} else {
std::string strMessage = tx->GetHash().ToString() + std::to_string(sigTime);

if (!CMessageSigner::SignMessage(strMessage, vchSig, activeMasternodeInfo.legacyKeyOperator)) {
LogPrintf("CPrivateSendBroadcastTx::Sign -- SignMessage() failed\n");
return false;
}
uint256 hash = GetSignatureHash();

if (!CMessageSigner::VerifyMessage(activeMasternodeInfo.legacyKeyIDOperator, vchSig, strMessage, strError)) {
LogPrintf("CPrivateSendBroadcastTx::Sign -- VerifyMessage() failed, error: %s\n", strError);
return false;
}
CBLSSignature sig = activeMasternodeInfo.blsKeyOperator->Sign(hash);
if (!sig.IsValid()) {
return false;
}
sig.GetBuf(vchSig);

return true;
}

bool CPrivateSendBroadcastTx::CheckSignature(const CKeyID& keyIDOperator, const CBLSPublicKey& blsPubKey) const
bool CPrivateSendBroadcastTx::CheckSignature(const CBLSPublicKey& blsPubKey) const
{
std::string strError = "";

if (deterministicMNManager->IsDIP3Active()) {
uint256 hash = GetSignatureHash();

CBLSSignature sig;
sig.SetBuf(vchSig);
if (!sig.IsValid() || !sig.VerifyInsecure(blsPubKey, hash)) {
LogPrintf("CTxLockVote::CheckSignature -- VerifyInsecure() failed\n");
return false;
}
} else if (sporkManager.IsSporkActive(SPORK_6_NEW_SIGS)) {
uint256 hash = GetSignatureHash();

if (!CHashSigner::VerifyHash(hash, keyIDOperator, vchSig, strError)) {
// we don't care about dstxes with old signature format
LogPrintf("CPrivateSendBroadcastTx::CheckSignature -- VerifyHash() failed, error: %s\n", strError);
return false;
}
} else {
std::string strMessage = tx->GetHash().ToString() + std::to_string(sigTime);
uint256 hash = GetSignatureHash();

if (!CMessageSigner::VerifyMessage(keyIDOperator, vchSig, strMessage, strError)) {
LogPrintf("CPrivateSendBroadcastTx::CheckSignature -- Got bad dstx signature, error: %s\n", strError);
return false;
}
CBLSSignature sig;
sig.SetBuf(vchSig);
if (!sig.IsValid() || !sig.VerifyInsecure(blsPubKey, hash)) {
LogPrintf("CTxLockVote::CheckSignature -- VerifyInsecure() failed\n");
return false;
}

return true;
Expand Down
2 changes: 1 addition & 1 deletion src/privatesend.h
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ class CPrivateSendBroadcastTx
uint256 GetSignatureHash() const;

bool Sign();
bool CheckSignature(const CKeyID& keyIDOperator, const CBLSPublicKey& blsPubKey) const;
bool CheckSignature(const CBLSPublicKey& blsPubKey) const;

void SetConfirmedHeight(int nConfirmedHeightIn) { nConfirmedHeight = nConfirmedHeightIn; }
bool IsExpired(int nHeight);
Expand Down

0 comments on commit fb13b00

Please sign in to comment.