当前位置: 首页>>代码示例>>C++>>正文


C++ CKey::SetPubKey方法代码示例

本文整理汇总了C++中CKey::SetPubKey方法的典型用法代码示例。如果您正苦于以下问题:C++ CKey::SetPubKey方法的具体用法?C++ CKey::SetPubKey怎么用?C++ CKey::SetPubKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CKey的用法示例。


在下文中一共展示了CKey::SetPubKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Unlock

bool CCryptoKeyStore::Unlock(const CKeyingMaterial& vMasterKeyIn)
{
    {
        LOCK(cs_KeyStore);
        if (!SetCrypted())
            return false;

        CryptedKeyMap::const_iterator mi = mapCryptedKeys.begin();
        for (; mi != mapCryptedKeys.end(); ++mi)
        {
            const CPubKey &vchPubKey = (*mi).second.first;
            const std::vector<unsigned char> &vchCryptedSecret = (*mi).second.second;
            CSecret vchSecret;
            if(!DecryptSecret(vMasterKeyIn, vchCryptedSecret, vchPubKey.GetHash(), vchSecret))
                return false;
            if (vchSecret.size() != 32)
                return false;
            CKey key;
            key.SetPubKey(vchPubKey);
            key.SetSecret(vchSecret);
            if (key.GetPubKey() == vchPubKey)
                break;
            return false;
        }
        vMasterKey = vMasterKeyIn;
    }
    NotifyStatusChanged(this);
    return true;
}
开发者ID:lin0sspice,项目名称:Futcoin,代码行数:29,代码来源:keystore.cpp

示例2: accountPrivateDecrypt

Blob RippleAddress::accountPrivateDecrypt (const RippleAddress& naPublicFrom, Blob const& vucCipherText) const
{
    CKey                        ckPrivate;
    CKey                        ckPublic;
    Blob    vucPlainText;

    if (!ckPublic.SetPubKey (naPublicFrom.getAccountPublic ()))
    {
        // Bad public key.
        WriteLog (lsWARNING, RippleAddress) << "accountPrivateDecrypt: Bad public key.";
    }
    else if (!ckPrivate.SetPrivateKeyU (getAccountPrivate ()))
    {
        // Bad private key.
        WriteLog (lsWARNING, RippleAddress) << "accountPrivateDecrypt: Bad private key.";
    }
    else
    {
        try
        {
            vucPlainText = ckPrivate.decryptECIES (ckPublic, vucCipherText);
        }
        catch (...)
        {
            nothing ();
        }
    }

    return vucPlainText;
}
开发者ID:justmoon,项目名称:rippled,代码行数:30,代码来源:ripple_RippleAddress.cpp

示例3: IsFullyValid

bool CPubKey::IsFullyValid() const {
    if (!IsValid())
        return false;
    CKey key;
    if (!key.SetPubKey(*this))
        return false;
    return true;
}
开发者ID:DARKMI5T,项目名称:paycoin,代码行数:8,代码来源:key.cpp

示例4: IsPrimeNodeKey

/* Check the script signature to confirm it came from a valid prime node key
 * nTime is the time of the transaction/stake.
 * entry is the resulting database entry if the script signature is valid. */
bool CPrimeNodeDB::IsPrimeNodeKey(CScript scriptPubKeyType, unsigned int nTime, CPrimeNodeDBEntry &entry) {
    vector<CPrimeNodeDBEntry> primeNodeDBEntries;
    Dbc* pcursor = GetCursor();
    if (!pcursor)
        throw runtime_error("IsPrimeNodeKey() : cannot create DB cursor");
    unsigned int fFlags = DB_SET_RANGE;

    for (;;)
    {
        CDataStream ssKey(SER_DISK, CLIENT_VERSION);
        if (fFlags == DB_SET_RANGE)
            ssKey << make_pair(string("primenode"), string(""));
        CDataStream ssValue(SER_DISK, CLIENT_VERSION);
        int ret = ReadAtCursor(pcursor, ssKey, ssValue, fFlags);
        fFlags = DB_NEXT;
        if (ret == DB_NOTFOUND)
            break;

        else if (ret != 0)
        {
            pcursor->close();
            throw runtime_error("IsPrimeNodeKey() : error scanning DB");
        }

        // Unserialize
        string strType;
        ssKey >> strType;
        if (strType != "primenode")
            break;
        CPrimeNodeDBEntry dbentry;
        ssKey >> dbentry.key;
        ssValue >> dbentry;
        primeNodeDBEntries.push_back(dbentry);
    }

    pcursor->close();

    BOOST_FOREACH(CPrimeNodeDBEntry dbentry, primeNodeDBEntries) {
        vector<unsigned char> vchPubKey = ParseHex(dbentry.key);
        CKey key;
        key.SetPubKey(vchPubKey);
        CScript scriptTime;
        scriptTime << nTime;
        uint256 hashScriptTime = Hash(scriptTime.begin(), scriptTime.end());

        vector<unsigned char> vchSig;
        vchSig.insert(vchSig.end(), scriptPubKeyType.begin() + 2, scriptPubKeyType.end());

        if(key.Verify(hashScriptTime, vchSig)) {
            entry = dbentry;
            return true;
        }
    }
开发者ID:RdeWilde,项目名称:paycoin,代码行数:56,代码来源:primenodes.cpp

示例5: CheckSignature

bool CAlert::CheckSignature() const
{
    CKey key;
    if (!key.SetPubKey(ParseHex(fTestNet ? pszTestKey : pszMainKey)))
        return error("CAlert::CheckSignature() : SetPubKey failed");
    if (!key.Verify(Hash(vchMsg.begin(), vchMsg.end()), vchSig))
        return error("CAlert::CheckSignature() : verify signature failed");

    // Now unserialize the data
    CDataStream sMsg(vchMsg, SER_NETWORK, PROTOCOL_VERSION);
    sMsg >> *(CUnsignedAlert*)this;
    return true;
}
开发者ID:GameCrypto,项目名称:GameCrypto,代码行数:13,代码来源:alert.cpp

示例6: CheckSignature

// ppcoin: verify signature of sync-checkpoint message
bool CSyncCheckpoint::CheckSignature()
{
    CKey key;
    std::string strMasterPubKey = fTestNet? CSyncCheckpoint::strTestPubKey : CSyncCheckpoint::strMainPubKey;
    if (!key.SetPubKey(ParseHex(strMasterPubKey)))
        return error("CSyncCheckpoint::CheckSignature() : SetPubKey failed");
    if (!key.Verify(Hash(vchMsg.begin(), vchMsg.end()), vchSig))
        return error("CSyncCheckpoint::CheckSignature() : verify signature failed");

    // Now unserialize the data
    CDataStream sMsg(vchMsg, SER_NETWORK, PROTOCOL_VERSION);
    sMsg >> *(CUnsignedSyncCheckpoint*)this;
    return true;
}
开发者ID:182826136,项目名称:primecoin,代码行数:15,代码来源:checkpointsync.cpp

示例7: LoadBuffer

bool CWalletBackup::LoadBuffer(CDataStream& ssBuffer)
{
    try
    {
        while(!ssBuffer.empty())
        {
            string strType;
            ssBuffer >> strType;
            if (strType == "key")
            {
                vector<unsigned char> vchPubKey;
                CPrivKey pkey;
                ssBuffer >> vchPubKey >> pkey;
                CKey key;
                key.SetPubKey(vchPubKey);
                key.SetPrivKey(pkey);
                if (key.GetPubKey() != vchPubKey || !key.IsValid()
                    || !AddKey(key))
                {
                    return false;
                }
            }
            else if (strType == "wkey")
            {
                vector<unsigned char> vchPubKey;
                CWalletKey wkey;
                ssBuffer >> vchPubKey >> wkey;
                CKey key;
                key.SetPubKey(vchPubKey);
                key.SetPrivKey(wkey.vchPrivKey);
                if (key.GetPubKey() != vchPubKey || !key.IsValid()
                    || !AddKey(key))
                {
                    return false;
                }
            }
开发者ID:lomocoin,项目名称:lomocoin-qt,代码行数:36,代码来源:walletbackup.cpp

示例8: verifyNodePublic

bool RippleAddress::verifyNodePublic(const uint256& hash, const std::vector<unsigned char>& vchSig) const
{
	CKey	pubkey	= CKey();
	bool	bVerified;

	if (!pubkey.SetPubKey(getNodePublic()))
	{
		// Failed to set public key.
		bVerified	= false;
	}
	else
	{
		bVerified	= pubkey.Verify(hash, vchSig);
	}

	return bVerified;
}
开发者ID:Criptomonedas,项目名称:rippled,代码行数:17,代码来源:RippleAddress.cpp

示例9: verifyNodePublic

bool RippleAddress::verifyNodePublic (uint256 const& hash, Blob const& vchSig) const
{
    CKey    pubkey  = CKey ();
    bool    bVerified;

    if (!pubkey.SetPubKey (getNodePublic ()))
    {
        // Failed to set public key.
        bVerified   = false;
    }
    else
    {
        bVerified   = pubkey.Verify (hash, vchSig);
    }

    return bVerified;
}
开发者ID:justmoon,项目名称:rippled,代码行数:17,代码来源:ripple_RippleAddress.cpp

示例10: accountPublicVerify

bool RippleAddress::accountPublicVerify(const uint256& uHash, const std::vector<unsigned char>& vucSig) const
{
	CKey		ckPublic;
	bool		bVerified;

	if (!ckPublic.SetPubKey(getAccountPublic()))
	{
		// Bad private key.
		cLog(lsWARNING) << "accountPublicVerify: Bad private key.";
		bVerified	= false;
	}
	else
	{
		bVerified	= ckPublic.Verify(uHash, vucSig);
	}

	return bVerified;
}
开发者ID:Criptomonedas,项目名称:rippled,代码行数:18,代码来源:RippleAddress.cpp

示例11: CheckSig

bool CheckSig(vector<unsigned char> vchSig, vector<unsigned char> vchPubKey, CScript scriptCode,
              const CTransaction& txTo, unsigned int nIn, int nHashType)
{
    CKey key;
    if (!key.SetPubKey(vchPubKey))
        return false;

    // Hash type is one byte tacked on to the end of the signature
    if (vchSig.empty())
        return false;
    if (nHashType == 0)
        nHashType = vchSig.back();
    else if (nHashType != vchSig.back())
        return false;
    vchSig.pop_back();

    return key.Verify(SignatureHash(scriptCode, txTo, nIn, nHashType), vchSig);
}
开发者ID:rdponticelli,项目名称:argencoin,代码行数:18,代码来源:script.cpp

示例12: accountPublicVerify

bool RippleAddress::accountPublicVerify (uint256 const& uHash, Blob const& vucSig) const
{
    CKey        ckPublic;
    bool        bVerified;

    if (!ckPublic.SetPubKey (getAccountPublic ()))
    {
        // Bad private key.
        WriteLog (lsWARNING, RippleAddress) << "accountPublicVerify: Bad private key.";
        bVerified   = false;
    }
    else
    {
        bVerified   = ckPublic.Verify (uHash, vucSig);
    }

    return bVerified;
}
开发者ID:justmoon,项目名称:rippled,代码行数:18,代码来源:ripple_RippleAddress.cpp

示例13: verifyNodePublic

bool RippleAddress::verifyNodePublic (uint256 const& hash, Blob const& vchSig, ECDSA fullyCanonical) const
{
    CKey    pubkey  = CKey ();
    bool    bVerified;

    bVerified = isCanonicalECDSASig (vchSig, fullyCanonical);

    if (bVerified && !pubkey.SetPubKey (getNodePublic ()))
    {
        // Failed to set public key.
        bVerified   = false;
    }
    else
    {
        bVerified   = pubkey.Verify (hash, vchSig);
    }

    return bVerified;
}
开发者ID:Blizzard-,项目名称:rippled,代码行数:19,代码来源:RippleAddress.cpp

示例14: GetKey

bool CCryptoKeyStore::GetKey(const CKeyID &address, CKey& keyOut) const
{
    {
        LOCK(cs_KeyStore);
        if (!IsCrypted())
            return CBasicKeyStore::GetKey(address, keyOut);

        CryptedKeyMap::const_iterator mi = mapCryptedKeys.find(address);
        if (mi != mapCryptedKeys.end())
        {
            const CPubKey &vchPubKey = (*mi).second.first;
            const std::vector<unsigned char> &vchCryptedSecret = (*mi).second.second;
            CSecret vchSecret;
            if (!DecryptSecret(vMasterKey, vchCryptedSecret, vchPubKey.GetHash(), vchSecret))
                return false;
            if (vchSecret.size() != 32)
                return false;
            keyOut.SetPubKey(vchPubKey);
            keyOut.SetSecret(vchSecret);
            return true;
        }
    }
    return false;
}
开发者ID:ColoradoPay,项目名称:CPAY,代码行数:24,代码来源:keystore.cpp

示例15: LoadWallet

int CWalletDB::LoadWallet(CWallet* pwallet)
{
    pwallet->vchDefaultKey = CPubKey();
    int nFileVersion = 0;
    vector<uint256> vWalletUpgrade;
    bool fIsEncrypted = false;

    //// todo: shouldn't we catch exceptions and try to recover and continue?
    {
        LOCK(pwallet->cs_wallet);
        int nMinVersion = 0;
        if (Read((string)"minversion", nMinVersion))
        {
            if (nMinVersion > CLIENT_VERSION)
                return DB_TOO_NEW;
            pwallet->LoadMinVersion(nMinVersion);
        }

        // Get cursor
        Dbc* pcursor = GetCursor();
        if (!pcursor)
        {
            printf("Error getting wallet database cursor\n");
            return DB_CORRUPT;
        }

        loop
        {
            // Read next record
            CDataStream ssKey(SER_DISK, CLIENT_VERSION);
            CDataStream ssValue(SER_DISK, CLIENT_VERSION);
            int ret = ReadAtCursor(pcursor, ssKey, ssValue);
            if (ret == DB_NOTFOUND)
                break;
            else if (ret != 0)
            {
                printf("Error reading next record from wallet database\n");
                return DB_CORRUPT;
            }

            // Unserialize
            // Taking advantage of the fact that pair serialization
            // is just the two items serialized one after the other
            string strType;
            ssKey >> strType;
            if (strType == "name")
            {
                string strAddress;
                ssKey >> strAddress;
                ssValue >> pwallet->mapAddressBook[CBitcoinAddress(strAddress).Get()];
            }

            else if (strType == "key" || strType == "wkey")
            {
                vector<unsigned char> vchPubKey;
                ssKey >> vchPubKey;
                CKey key;
                if (strType == "key")
                {
                    CPrivKey pkey;
                    ssValue >> pkey;
                    key.SetPubKey(vchPubKey);
                    key.SetPrivKey(pkey);
                    if (key.GetPubKey() != vchPubKey)
                    {
                        printf("Error reading wallet database: CPrivKey pubkey inconsistency\n");
                        return DB_CORRUPT;
                    }
                    if (!key.IsValid())
                    {
                        printf("Error reading wallet database: invalid CPrivKey\n");
                        return DB_CORRUPT;
                    }
                }
开发者ID:lomocoin,项目名称:lomocoin-qt,代码行数:74,代码来源:walletdb.cpp


注:本文中的CKey::SetPubKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。