• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ GetPubKey函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中GetPubKey函数的典型用法代码示例。如果您正苦于以下问题:C++ GetPubKey函数的具体用法?C++ GetPubKey怎么用?C++ GetPubKey使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: qWarning

	QObject* FileTransferManager::SendFile (const QString& id,
			const QString&, const QString& name, const QString&)
	{
		const auto toxThread = ToxThread_.lock ();
		if (!toxThread)
		{
			qWarning () << Q_FUNC_INFO
					<< "Tox thread is not available";
			return nullptr;
		}

		const auto contact = Acc_->GetByAzothId (id);
		if (!contact)
		{
			qWarning () << Q_FUNC_INFO
					<< "unable to find contact by the ID"
					<< id;
			return nullptr;
		}

		const auto transfer = new FileTransferOut { id, contact->GetPubKey (), name, toxThread };
		connect (this,
				SIGNAL (gotFileControl (qint32, qint8, qint8, QByteArray)),
				transfer,
				SLOT (handleFileControl (qint32, qint8, qint8, QByteArray)));
		return transfer;
	}
开发者ID:MellonQ,项目名称:leechcraft,代码行数:27,代码来源:filetransfermanager.cpp


示例2: ECDSA_do_sign

bool CECKey::SignCompact(const uint256 &hash, unsigned char *p64, int &rec) {
    bool fOk = false;
    ECDSA_SIG *sig = ECDSA_do_sign((unsigned char*)&hash, sizeof(hash), pkey);
    if (sig==NULL)
        return false;
    memset(p64, 0, 64);
    int nBitsR = BN_num_bits(sig->r);
    int nBitsS = BN_num_bits(sig->s);
    if (nBitsR <= 256 && nBitsS <= 256) {
        std::vector<unsigned char> pubkey;
        GetPubKey(pubkey, true);
        for (int i=0; i<4; i++) {
            CECKey keyRec;
            if (ECDSA_SIG_recover_key_GFp(keyRec.pkey, sig, (unsigned char*)&hash, sizeof(hash), i, 1) == 1) {
                std::vector<unsigned char> pubkeyRec;
                keyRec.GetPubKey(pubkeyRec, true);
                if (pubkeyRec == pubkey) {
                    rec = i;
                    fOk = true;
                    break;
                }
            }
        }
        assert(fOk);
        BN_bn2bin(sig->r,&p64[32-(nBitsR+7)/8]);
        BN_bn2bin(sig->s,&p64[64-(nBitsS+7)/8]);
    }
    ECDSA_SIG_free(sig);
    return fOk;
}
开发者ID:flirtcoin,项目名称:flirtcoin,代码行数:30,代码来源:ecwrapper.cpp


示例3: VerifyCompact

bool CKey::VerifyCompact(uint256 hash, const std::vector<unsigned char>& vchSig)
{
    CKey key;
    if (!key.SetCompactSignature(hash, vchSig))
        return false;
    if (GetPubKey() != key.GetPubKey())
        return false;

    return true;
}
开发者ID:uscoin,项目名称:uscoin,代码行数:10,代码来源:key.cpp


示例4: CRITICAL_BLOCK

bool CBasicKeyStore::HaveCScript(const uint160& hash) const
{
    bool result;
    CBitcoinAddress address;
    std::vector<unsigned char> vchPubKey;
    address.SetScriptHash160(hash);
    CRITICAL_BLOCK(cs_KeyStore)
        result = (mapScripts.count(hash) > 0) || GetPubKey(address, vchPubKey);
    return result;
}
开发者ID:FuzzyBearBTC,项目名称:CoiledCoin,代码行数:10,代码来源:keystore.cpp


示例5: GetSecret

bool CKey::IsValid()
{
    if (!fSet)
        return false;

    bool fCompr;
    CSecret secret = GetSecret(fCompr);
    CKey key2;
    key2.SetSecret(secret, fCompr);
    return GetPubKey() == key2.GetPubKey();
}
开发者ID:uscoin,项目名称:uscoin,代码行数:11,代码来源:key.cpp


示例6: GetKeys

bool CAccount::EncryptKeys(const CKeyingMaterial& vMasterKeyIn)
{
    if (!externalKeyStore.EncryptKeys(vMasterKeyIn))
        return false;
    if (!internalKeyStore.EncryptKeys(vMasterKeyIn))
        return false;

    if (pactiveWallet)
    {
        {
            std::set<CKeyID> setAddress;
            GetKeys(setAddress);

            LOCK(pactiveWallet->cs_wallet);
            for (const auto& keyID : setAddress)
            {
                CPubKey pubKey;
                if (!GetPubKey(keyID, pubKey))
                {
                    LogPrintf("CAccount::EncryptKeys(): Failed to get pubkey\n");
                    return false;
                }
                if (pactiveWallet->pwalletdbEncryption)
                    pactiveWallet->pwalletdbEncryption->EraseKey(pubKey);
                else
                    CWalletDB(*pactiveWallet->dbw).EraseKey(pubKey);

                std::vector<unsigned char> secret;
                if (!GetKey(keyID, secret))
                { 
                    LogPrintf("CAccount::EncryptKeys(): Failed to get crypted key\n");
                    return false;
                }
                if (pactiveWallet->pwalletdbEncryption)
                {
                    if (!pactiveWallet->pwalletdbEncryption->WriteCryptedKey(pubKey, secret, pactiveWallet->mapKeyMetadata[keyID], getUUIDAsString(getUUID()), KEYCHAIN_EXTERNAL))
                    {
                        LogPrintf("CAccount::EncryptKeys(): Failed to write key\n");
                        return false;
                    }
                }
                else
                {
                    if (!CWalletDB(*pactiveWallet->dbw).WriteCryptedKey(pubKey, secret, pactiveWallet->mapKeyMetadata[keyID], getUUIDAsString(getUUID()), KEYCHAIN_EXTERNAL))
                    {
                        LogPrintf("CAccount::EncryptKeys(): Failed to write key\n");
                        return false;
                    }
                }
            }
        }
    }
    return true;
}
开发者ID:ALEX196969,项目名称:gulden-official,代码行数:54,代码来源:account.cpp


示例7: GetPubKey

CPubKey CAccountHD::GenerateNewKey(CWallet& wallet, int keyChain)
{
    CExtPubKey childKey;
    do {
        GetPubKey(childKey, keyChain);
    } while (wallet.HaveKey(childKey.pubkey.GetID())); ///

    LogPrintf("CAccount::GenerateNewKey(): NewHDKey [%s]\n", CBitcoinAddress(childKey.pubkey.GetID()).ToString());

    if (!wallet.AddKeyPubKey(childKey.nChild, childKey.pubkey, *this, keyChain))
        throw std::runtime_error("CAccount::GenerateNewKey(): AddKeyPubKey failed");

    return childKey.pubkey;
}
开发者ID:Gulden,项目名称:gulden-official,代码行数:14,代码来源:account.cpp


示例8: fopen

//rsa密钥对产生
bool CRsaDesManager::GenRsaKeypairs(void)
{
	RSA *rsa = NULL;
	FILE *fKeyFile = NULL;
	fKeyFile = fopen("raskeys.key", "wb");
	if(fKeyFile == NULL)
	{
		return false;
	}

	int i = 0;
	//把密钥对写入文件,以后从文件里读取
	unsigned char ucPubKey[RSA_KEY_LEN] = {0}, ucPriKey[RSA_KEY_LEN] = {0};
	for(i = 0; i < RSA_KEY_PAIR_NUM; ++i)
	{
		//生成RSA密钥对:
		rsa = RSA_new();
		rsa = RSA_generate_key(RSA_KEY_LEN, RSA_F4, NULL, NULL);

		unsigned char* pt = ucPubKey;
		ui32 len = i2d_RSAPublicKey(rsa, &pt);
		if(!GetPubKey(ucPubKey, len, &m_pPubRSA[i]))
			break;
		fwrite((unsigned char*)&len, 1, sizeof(ui32), fKeyFile);
		fwrite(ucPubKey, 1, len, fKeyFile);
		m_strPubKeys[i].clear();
		m_strPubKeys[i].append((char*)ucPubKey, len);

		unsigned char* pt2 = ucPriKey;
		len = i2d_RSAPrivateKey(rsa,&pt2);
		if(!GetPriKey(ucPriKey, len, &m_pPriRSA[i]))
			break;
		fwrite((unsigned char*)&len, 1, sizeof(ui32), fKeyFile);
		fwrite(ucPriKey, 1, len, fKeyFile);

		if(rsa != NULL)
		{
			RSA_free(rsa);
			rsa = NULL;
		}
	}
	fclose(fKeyFile);
	if(i < RSA_KEY_PAIR_NUM)
		return false;
	return true;
}
开发者ID:furen2013,项目名称:testwork,代码行数:47,代码来源:RsaDesManager.cpp


示例9: GetPubKey

CPubKey CAccountHD::GenerateNewKey(CWallet& wallet, CKeyMetadata& metadata, int keyChain)
{
    CExtPubKey childKey;
    do
    {
        GetPubKey(childKey, keyChain);
    }
    while( wallet.HaveKey(childKey.pubkey.GetID()) );//fixme: (Post-2.1) (BIP44) No longer need wallet here.

    //LogPrintf("CAccount::GenerateNewKey(): NewHDKey [%s]\n", CGuldenAddress(childKey.pubkey.GetID()).ToString());

    metadata.hdKeypath = std::string("m/44'/87'/") +  std::to_string(m_nIndex)  + "/" + std::to_string(keyChain) + "/" + std::to_string(childKey.nChild) + "'";
    metadata.hdAccountUUID = getUUIDAsString(getUUID());

    if (!wallet.AddHDKeyPubKey(childKey.nChild, childKey.pubkey, *this, keyChain))
        throw std::runtime_error("CAccount::GenerateNewKey(): AddKeyPubKey failed");

    return childKey.pubkey;
}
开发者ID:ALEX196969,项目名称:gulden-official,代码行数:19,代码来源:account.cpp


示例10: RSAPubEncode

 bool CRsaDesManager::RSAPubEncode(const string& strRsaPubKey, const string& strInData, string& strOutData)
 {
	 RSA * pRsa;
	 if(!GetPubKey((unsigned char*)strRsaPubKey.c_str(), strRsaPubKey.size(), &pRsa))
		 return false;

	 unsigned char pcOutData[1024];
	 unsigned char *pcInData = (unsigned char *)strInData.c_str();
	 unsigned long ulOutLen = 0, ulInLen = strInData.size();
	 unsigned long ulInTmpLen = std::min<int>(ulInLen, RSA_ENCODE_LEN_UNIT);
	 unsigned long ulOutTmpLen = 0;
	 while(ulInLen)
	 {
		 ulOutTmpLen = RSA_public_encrypt(ulInTmpLen, pcInData, pcOutData+ulOutLen, pRsa, 1);
		 if(ulOutTmpLen <= 0)
			 break;

		 ulOutLen = ulOutLen + ulOutTmpLen;
		 pcInData = pcInData+ulInTmpLen;
		 ulInLen -= ulInTmpLen;
		 ulInTmpLen = std::min<int>(ulInLen, RSA_ENCODE_LEN_UNIT);
	 }

	 RSA_free(pRsa);

	 strOutData.clear();
	 if(ulInLen <= 0)
	 {
		 strOutData.append((char*)pcOutData, ulOutTmpLen);
		 return true;
	 }
	 else
	 {
		 return false;
	 }
 }
开发者ID:furen2013,项目名称:testwork,代码行数:36,代码来源:RsaDesManager.cpp


示例11: SignStep

/**
 * Sign scriptPubKey using signature made with creator.
 * Signatures are returned in scriptSigRet (or returns false if scriptPubKey can't be signed),
 * unless whichTypeRet is TX_SCRIPTHASH, in which case scriptSigRet is the redemption script.
 * Returns false if scriptPubKey could not be completely satisfied.
 */
static bool SignStep(const SigningProvider& provider, const BaseSignatureCreator& creator, const CScript& scriptPubKey,
                     std::vector<valtype>& ret, txnouttype& whichTypeRet, SigVersion sigversion, SignatureData& sigdata)
{
    CScript scriptRet;
    uint160 h160;
    ret.clear();
    std::vector<unsigned char> sig;

    std::vector<valtype> vSolutions;
    if (!Solver(scriptPubKey, whichTypeRet, vSolutions))
        return false;

    switch (whichTypeRet)
    {
    case TX_NONSTANDARD:
    case TX_NULL_DATA:
    case TX_WITNESS_UNKNOWN:
        return false;
    case TX_PUBKEY:
        if (!CreateSig(creator, sigdata, provider, sig, CPubKey(vSolutions[0]), scriptPubKey, sigversion)) return false;
        ret.push_back(std::move(sig));
        return true;
    case TX_PUBKEYHASH: {
        CKeyID keyID = CKeyID(uint160(vSolutions[0]));
        CPubKey pubkey;
        GetPubKey(provider, sigdata, keyID, pubkey);
        if (!CreateSig(creator, sigdata, provider, sig, pubkey, scriptPubKey, sigversion)) return false;
        ret.push_back(std::move(sig));
        ret.push_back(ToByteVector(pubkey));
        return true;
    }
    case TX_SCRIPTHASH:
        if (GetCScript(provider, sigdata, uint160(vSolutions[0]), scriptRet)) {
            ret.push_back(std::vector<unsigned char>(scriptRet.begin(), scriptRet.end()));
            return true;
        }
        return false;

    case TX_MULTISIG: {
        size_t required = vSolutions.front()[0];
        ret.push_back(valtype()); // workaround CHECKMULTISIG bug
        for (size_t i = 1; i < vSolutions.size() - 1; ++i) {
            CPubKey pubkey = CPubKey(vSolutions[i]);
            if (ret.size() < required + 1 && CreateSig(creator, sigdata, provider, sig, pubkey, scriptPubKey, sigversion)) {
                ret.push_back(std::move(sig));
            }
        }
        bool ok = ret.size() == required + 1;
        for (size_t i = 0; i + ret.size() < required + 1; ++i) {
            ret.push_back(valtype());
        }
        return ok;
    }
    case TX_WITNESS_V0_KEYHASH:
        ret.push_back(vSolutions[0]);
        return true;

    case TX_WITNESS_V0_SCRIPTHASH:
        CRIPEMD160().Write(&vSolutions[0][0], vSolutions[0].size()).Finalize(h160.begin());
        if (GetCScript(provider, sigdata, h160, scriptRet)) {
            ret.push_back(std::vector<unsigned char>(scriptRet.begin(), scriptRet.end()));
            return true;
        }
        return false;

    default:
        return false;
    }
}
开发者ID:fujicoin,项目名称:fujicoin,代码行数:75,代码来源:sign.cpp


示例12: zmq_msg_t

void SampleEscrowServerZmq::UpdateServer()
{
    //while (!Modules::shutDown)
    {
        zmq_msg_t request; // = new zmq_msg_t();
        zmq_msg_init(&request);

        // Wait for next request from client
        zmq_pollitem_t item;
        item.socket = this->serverSocket;
        item.fd = 0;
        item.events = ZMQ_POLLIN;
        item.revents = 0;
        /*zmq_pollitem_t items[] = { item }; //{ this->serverSocket, 0, ZMQ_POLLIN, 0 } };
        zmq_poll(&items[0], 1, 1000);

        // Return if no request
        if (!(items[0].revents & ZMQ_POLLIN))
        {
            zmq_msg_close(&request);
            return;
        }*/

#ifdef OT_USE_ZMQ4
        if(zmq_msg_recv(&request, this->serverSocket, ZMQ_DONTWAIT) == -1)
#else
        #ifndef Q_OS_MAC
        if(zmq_recv(this->serverSocket, &request, ZMQ_NOBLOCK) == -1)
#endif
#endif
        {
            zmq_msg_close(&request);
            return;
        }

        if(zmq_msg_size(&request) < NetMessageSizes[Unknown])
        {
            zmq_msg_close(&request);
            return;
        }

        NetMessageType messageType = static_cast<NetMessageType>(static_cast<BtcNetMsg*>(zmq_msg_data(&request))->MessageType);
        if(zmq_msg_size(&request) != NetMessageSizes[messageType])
        {
            zmq_msg_close(&request);
            return;
        }

        BtcNetMsg* replyPtr = new BtcNetMsg();

        switch(messageType)
        {
        case Unknown:
        {
            break;
        }
        case Connect:
        {
            BtcNetMsgConnectPtr message = BtcNetMsgConnectPtr(new BtcNetMsgConnect());
            memcpy(message->data, zmq_msg_data(&request), NetMessageSizes[messageType]);
            ClientConnected(message);
            std::printf("client connected\n");
            std::cout.flush();
            break;
        }
        case ReqDeposit:
        {
            BtcNetMsgReqDepositPtr message = BtcNetMsgReqDepositPtr(new BtcNetMsgReqDeposit());
            memcpy(message->data, zmq_msg_data(&request), NetMessageSizes[messageType]);
            bool accepted = RequestEscrowDeposit(message);

            BtcNetMsgDepositReply* replyMsg = new BtcNetMsgDepositReply();
            replyMsg->accepted = static_cast<int8_t>(accepted);
            replyPtr = (BtcNetMsg*)replyMsg;
            break;
        }
        case GetMultiSigAddr:
        {
            BtcNetMsgGetDepositAddrPtr message = BtcNetMsgGetDepositAddrPtr(new BtcNetMsgGetDepositAddr());
            memcpy(message->data, zmq_msg_data(&request), NetMessageSizes[messageType]);
            std::string multiSigAddr = RequestDepositAddress(message);

            if(multiSigAddr.empty())
                break;

            BtcNetMsgDepositAddr* replyMsg = new BtcNetMsgDepositAddr();
            memcpy(replyMsg->address, multiSigAddr.c_str(), std::min(multiSigAddr.size(), sizeof(replyMsg->address)));
            std::printf("server %s sending multisig addr %s\n", this->serverName.c_str(), replyMsg->address);
            std::cout.flush();
            replyPtr = (BtcNetMsg*)replyMsg;
            break;
        }
        case GetMultiSigKey:
        {
            BtcNetMsgGetKeyPtr message = BtcNetMsgGetKeyPtr(new BtcNetMsgGetKey());
            memcpy(message->data, zmq_msg_data(&request), NetMessageSizes[messageType]);
            std::string pubKey = GetPubKey(message);

            if(pubKey.empty())
                break;
//.........这里部分代码省略.........
开发者ID:plato-cambrian,项目名称:Cambrian-src,代码行数:101,代码来源:sampleescrowserverzmq.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ GetQuantumPixels函数代码示例发布时间:2022-05-30
下一篇:
C++ GetPtr函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap