コード例 #1
0
ファイル: governance-vote.cpp プロジェクト: bancoteam/dash
bool CGovernanceVote::CheckSignature(const CPubKey& pubKeyMasternode) const
{
    std::string strError;

    if (sporkManager.IsSporkActive(SPORK_6_NEW_SIGS)) {
        uint256 hash = GetSignatureHash();

        if (!CHashSigner::VerifyHash(hash, pubKeyMasternode, vchSig, strError)) {
            // could be a signature in old format
            std::string strMessage = masternodeOutpoint.ToStringShort() + "|" + nParentHash.ToString() + "|" +
                boost::lexical_cast<std::string>(nVoteSignal) + "|" +
                boost::lexical_cast<std::string>(nVoteOutcome) + "|" +
                boost::lexical_cast<std::string>(nTime);

            if(!CMessageSigner::VerifyMessage(pubKeyMasternode, vchSig, strMessage, strError)) {
                // nope, not in old format either
                LogPrint("gobject", "CGovernanceVote::IsValid -- VerifyMessage() failed, error: %s\n", strError);
                return false;
            }
        }
    } else {
        std::string strMessage = masternodeOutpoint.ToStringShort() + "|" + nParentHash.ToString() + "|" +
            boost::lexical_cast<std::string>(nVoteSignal) + "|" +
            boost::lexical_cast<std::string>(nVoteOutcome) + "|" +
            boost::lexical_cast<std::string>(nTime);

        if(!CMessageSigner::VerifyMessage(pubKeyMasternode, vchSig, strMessage, strError)) {
            LogPrint("gobject", "CGovernanceVote::IsValid -- VerifyMessage() failed, error: %s\n", strError);
            return false;
        }
    }

    return true;
}
コード例 #2
0
bool CMasternodePing::CheckSignature(const CPubKey& pubKeyMasternode, int& nDos) const
{
    std::string strError = "";
    nDos = 0;

    if (chainActive.Height() > 600000) {
        uint256 hash = GetSignatureHash();

        if (!CHashSigner::VerifyHash(hash, pubKeyMasternode, vchSig, strError)) {
            std::string strMessage = CTxIn(masternodeOutpoint).ToString() + blockHash.ToString() +
                                     boost::lexical_cast<std::string>(sigTime);

            if (!CMessageSigner::VerifyMessage(pubKeyMasternode, vchSig, strMessage, strError)) {
                LogPrintf("CMasternodePing::CheckSignature -- Got bad Masternode ping signature, masternode=%s, error: %s\n", masternodeOutpoint.ToStringShort(), strError);
                nDos = 33;
                return false;
            }
        }
    } else {
        std::string strMessage = CTxIn(masternodeOutpoint).ToString() + blockHash.ToString() +
                                 boost::lexical_cast<std::string>(sigTime);

        if (!CMessageSigner::VerifyMessage(pubKeyMasternode, vchSig, strMessage, strError)) {
            LogPrintf("CMasternodePing::CheckSignature -- Got bad Masternode ping signature, masternode=%s, error: %s\n", masternodeOutpoint.ToStringShort(), strError);
            nDos = 33;
            return false;
        }
    }

    return true;
}
コード例 #3
0
ファイル: governance-vote.cpp プロジェクト: bancoteam/dash
bool CGovernanceVote::Sign(const CKey& keyMasternode, const CPubKey& pubKeyMasternode)
{
    std::string strError;

    if (sporkManager.IsSporkActive(SPORK_6_NEW_SIGS)) {
        uint256 hash = GetSignatureHash();

        if(!CHashSigner::SignHash(hash, keyMasternode, vchSig)) {
            LogPrintf("CGovernanceVote::Sign -- SignHash() failed\n");
            return false;
        }

        if (!CHashSigner::VerifyHash(hash, pubKeyMasternode, vchSig, strError)) {
            LogPrintf("CGovernanceVote::Sign -- VerifyHash() failed, error: %s\n", strError);
            return false;
        }
    } else {

        std::string strMessage = masternodeOutpoint.ToStringShort() + "|" + nParentHash.ToString() + "|" +
            boost::lexical_cast<std::string>(nVoteSignal) + "|" + boost::lexical_cast<std::string>(nVoteOutcome) + "|" + boost::lexical_cast<std::string>(nTime);

        if(!CMessageSigner::SignMessage(strMessage, vchSig, keyMasternode)) {
            LogPrintf("CGovernanceVote::Sign -- SignMessage() failed\n");
            return false;
        }

        if(!CMessageSigner::VerifyMessage(pubKeyMasternode, vchSig, strMessage, strError)) {
            LogPrintf("CGovernanceVote::Sign -- VerifyMessage() failed, error: %s\n", strError);
            return false;
        }
    }

    return true;
}
コード例 #4
0
bool CMasternodePing::Sign(const CKey& keyMasternode, const CPubKey& pubKeyMasternode)
{
    std::string strError;

    sigTime = GetAdjustedTime();

    if (chainActive.Height() > 600000) {
        uint256 hash = GetSignatureHash();
        if (!CHashSigner::SignHash(hash, keyMasternode, vchSig)) {
            LogPrintf("CMasternodePing::Sign -- SignHash() failed\n");
            return false;
        }

        if (!CHashSigner::VerifyHash(hash, pubKeyMasternode, vchSig, strError)) {
            LogPrintf("CMasternodePing::Sign -- VerifyHash() failed, error: %s\n", strError);
            return false;
        }
    } else {
        std::string strMessage = CTxIn(masternodeOutpoint).ToString() + blockHash.ToString() +
                                 boost::lexical_cast<std::string>(sigTime);

        if (!CMessageSigner::SignMessage(strMessage, vchSig, keyMasternode)) {
            LogPrintf("CMasternodePing::Sign -- SignMessage() failed\n");
            return false;
        }

        if (!CMessageSigner::VerifyMessage(pubKeyMasternode, vchSig, strMessage, strError)) {
            LogPrintf("CMasternodePing::Sign -- VerifyMessage() failed, error: %s\n", strError);
            return false;
        }
    }

    return true;
}
コード例 #5
0
bool CMasternodeBroadcast::CheckSignature(int& nDos) const
{
    std::string strError = "";
    nDos = 0;

    if (chainActive.Height() > 600000) {
        uint256 hash = GetSignatureHash();
        if (!CHashSigner::VerifyHash(hash, pubKeyCollateralAddress, vchSig, strError)) {
            // maybe it's in old format
            std::string strMessage = addr.ToString() + boost::lexical_cast<std::string>(sigTime) +
                                     pubKeyCollateralAddress.GetID().ToString() + pubKeyMasternode.GetID().ToString() +
                                     boost::lexical_cast<std::string>(nProtocolVersion);

            if (!CMessageSigner::VerifyMessage(pubKeyCollateralAddress, vchSig, strMessage, strError)) {
                // nope, not in old format either
                LogPrintf("CMasternodeBroadcast::CheckSignature -- Got bad Masternode announce signature, error: %s\n", strError);
                nDos = 100;
                return false;
            }
        }
    } else {
        std::string strMessage = addr.ToString() + boost::lexical_cast<std::string>(sigTime) +
                                 pubKeyCollateralAddress.GetID().ToString() + pubKeyMasternode.GetID().ToString() +
                                 boost::lexical_cast<std::string>(nProtocolVersion);

        if (!CMessageSigner::VerifyMessage(pubKeyCollateralAddress, vchSig, strMessage, strError)) {
            LogPrintf("CMasternodeBroadcast::CheckSignature -- Got bad Masternode announce signature, error: %s\n", strError);
            nDos = 100;
            return false;
        }
    }

    return true;
}
コード例 #6
0
ファイル: governance-object.cpp プロジェクト: dashpay/dash
bool CGovernanceObject::Sign(const CBLSSecretKey& key)
{
    CBLSSignature sig = key.Sign(GetSignatureHash());
    if (!key.IsValid()) {
        return false;
    }
    sig.GetBuf(vchSig);
    return true;
}
コード例 #7
0
ファイル: governance-object.cpp プロジェクト: dashpay/dash
bool CGovernanceObject::CheckSignature(const CBLSPublicKey& pubKey) const
{
    CBLSSignature sig;
    sig.SetBuf(vchSig);
    if (!sig.VerifyInsecure(pubKey, GetSignatureHash())) {
        LogPrintf("CGovernanceObject::CheckSignature -- VerifyInsecure() failed\n");
        return false;
    }
    return true;
}
コード例 #8
0
ファイル: governance-vote.cpp プロジェクト: einalex/syscoin
bool CGovernanceVote::CheckSignature(const CPubKey& pubKeyMasternode) const
{
    std::string strError;

    if (sporkManager.IsSporkActive(SPORK_6_NEW_SIGS)) {
        uint256 hash = GetSignatureHash();
        if (!CHashSigner::VerifyHash(hash, pubKeyMasternode, vchSig, strError)) {
            LogPrint("gobject", "CGovernanceVote::IsValid -- VerifyMessage() failed, error: %s\n", strError);
            return false;  
        }
    } 
    return true;
}
コード例 #9
0
ファイル: privatesend.cpp プロジェクト: einalex/syscoin
bool CDarksendQueue::CheckSignature(const CPubKey& pubKeyMasternode) const
{
    std::string strError = "";

    if (sporkManager.IsSporkActive(SPORK_6_NEW_SIGS)) {
        uint256 hash = GetSignatureHash();

        if (!CHashSigner::VerifyHash(hash, pubKeyMasternode, vchSig, strError)) {
            // we don't care about queues with old signature format
            LogPrintf("CDarksendQueue::CheckSignature -- VerifyHash() failed, error: %s\n", strError);
            return false;
        }
    } 

    return true;
}
コード例 #10
0
bool CGovernanceVote::Sign(const CKey& keyMasternode, const CPubKey& pubKeyMasternode)
{
    std::string strError;

    uint256 hash = GetSignatureHash();

    if(!CHashSigner::SignHash(hash, keyMasternode, vchSig)) {
        LogPrintf("CGovernanceVote::Sign -- SignHash() failed\n");
        return false;
    }

    if (!CHashSigner::VerifyHash(hash, pubKeyMasternode, vchSig, strError)) {
        LogPrintf("CGovernanceVote::Sign -- VerifyHash() failed, error: %s\n", strError);
        return false;
    }

    return true;
}
コード例 #11
0
bool CMasternodeBroadcast::Sign(const CKey& keyCollateralAddress)
{
    std::string strError;

    sigTime = GetAdjustedTime();

    uint256 hash = GetSignatureHash();
    if (!CHashSigner::SignHash(hash, keyCollateralAddress, vchSig)) {
        LogPrintf("CMasternodeBroadcast::Sign -- SignHash() failed\n");
        return false;
    }
    if (!CHashSigner::VerifyHash(hash, pubKeyCollateralAddress, vchSig, strError)) {
        LogPrintf("CMasternodeBroadcast::Sign -- VerifyMessage() failed, error: %s\n", strError);
        return false;
    }

    return true;
}
コード例 #12
0
ファイル: instantx.cpp プロジェクト: einalex/syscoin
bool CTxLockVote::Sign()
{
    std::string strError;

    if (sporkManager.IsSporkActive(SPORK_6_NEW_SIGS)) {
        uint256 hash = GetSignatureHash();

        if(!CHashSigner::SignHash(hash, activeMasternode.keyMasternode, vchMasternodeSignature)) {
            LogPrintf("CTxLockVote::Sign -- SignHash() failed\n");
            return false;
        }

        if (!CHashSigner::VerifyHash(hash, activeMasternode.pubKeyMasternode, vchMasternodeSignature, strError)) {
            LogPrintf("CTxLockVote::Sign -- VerifyHash() failed, error: %s\n", strError);
            return false;
        }
    } 

    return true;
}
コード例 #13
0
ファイル: instantx.cpp プロジェクト: einalex/syscoin
bool CTxLockVote::CheckSignature() const
{
    std::string strError;

    masternode_info_t infoMn;

    if(!mnodeman.GetMasternodeInfo(outpointMasternode, infoMn)) {
        LogPrintf("CTxLockVote::CheckSignature -- Unknown Masternode: masternode=%s\n", outpointMasternode.ToString());
        return false;
    }

    if (sporkManager.IsSporkActive(SPORK_6_NEW_SIGS)) {
        uint256 hash = GetSignatureHash();

        if (!CHashSigner::VerifyHash(hash, infoMn.pubKeyMasternode, vchMasternodeSignature, strError)) {
            LogPrintf("CTxLockVote::CheckSignature -- VerifyMessage() failed, error: %s\n", strError);
            return false;
        }
    } 

    return true;
}
コード例 #14
0
ファイル: privatesend.cpp プロジェクト: einalex/syscoin
bool CDarksendBroadcastTx::Sign()
{
    if(!fMasternodeMode) return false;

    std::string strError = "";

    if (sporkManager.IsSporkActive(SPORK_6_NEW_SIGS)) {
        uint256 hash = GetSignatureHash();

        if (!CHashSigner::SignHash(hash, activeMasternode.keyMasternode, vchSig)) {
            LogPrintf("CDarksendBroadcastTx::Sign -- SignHash() failed\n");
            return false;
        }

        if (!CHashSigner::VerifyHash(hash, activeMasternode.pubKeyMasternode, vchSig, strError)) {
            LogPrintf("CDarksendBroadcastTx::Sign -- VerifyHash() failed, error: %s\n", strError);
            return false;
        }
    } 

    return true;
}