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


C++ uint256::begin方法代码示例

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


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

示例1: hkdfExpand

HmacSha256Key
PeerAuth::getSendingMacKey(Curve25519Public const& remotePublic,
                           uint256 const& localNonce,
                           uint256 const& remoteNonce, Peer::PeerRole role)
{
    std::vector<uint8_t> buf;
    if (role == Peer::WE_CALLED_REMOTE)
    {
        // If WE_CALLED_REMOTE then sending key is K_AB,
        // and A is local and B is remote.
        buf.push_back(0);
        buf.insert(buf.end(), localNonce.begin(), localNonce.end());
        buf.insert(buf.end(), remoteNonce.begin(), remoteNonce.end());
    }
    else
    {
        // If REMOTE_CALLED_US then sending key is K_BA,
        // and B is local and A is remote.
        buf.push_back(1);
        buf.insert(buf.end(), localNonce.begin(), localNonce.end());
        buf.insert(buf.end(), remoteNonce.begin(), remoteNonce.end());
    }
    auto k = getSharedKey(remotePublic, role);
    return hkdfExpand(k, buf);
}
开发者ID:hanxueming126,项目名称:stellar-core,代码行数:25,代码来源:PeerAuth.cpp

示例2: logic_error

uint256 JoinSplit<NumInputs, NumOutputs>::h_sig(
    const uint256& randomSeed,
    const boost::array<uint256, NumInputs>& nullifiers,
    const uint256& pubKeyHash
) {
    const unsigned char personalization[crypto_generichash_blake2b_PERSONALBYTES]
        = {'Z','c','a','s','h','C','o','m','p','u','t','e','h','S','i','g'};

    std::vector<unsigned char> block(randomSeed.begin(), randomSeed.end());

    for (size_t i = 0; i < NumInputs; i++) {
        block.insert(block.end(), nullifiers[i].begin(), nullifiers[i].end());
    }

    block.insert(block.end(), pubKeyHash.begin(), pubKeyHash.end());

    uint256 output;

    if (crypto_generichash_blake2b_salt_personal(output.begin(), 32,
                                                 &block[0], block.size(),
                                                 NULL, 0, // No key.
                                                 NULL,    // No salt.
                                                 personalization
                                                ) != 0)
    {
        throw std::logic_error("hash function failure");
    }

    return output;
}
开发者ID:ageis,项目名称:zcash,代码行数:30,代码来源:JoinSplit.cpp

示例3: operator

 uint32_t operator()(const uint256& key) const
 {
     static_assert(hash_select <8, "SignatureCacheHasher only has 8 hashes available.");
     uint32_t u;
     std::memcpy(&u, key.begin() + 4 * hash_select, 4);
     return u;
 }
开发者ID:marcusfox0,项目名称:polis,代码行数:7,代码来源:cuckoocache_tests.cpp

示例4: runtime_error

std::array<unsigned char, 11> default_diversifier(const uint256& sk)
{
    std::array<unsigned char, 11> res;   
    unsigned char blob[34];

    memcpy(&blob[0], sk.begin(), 32);
    blob[32] = 3;
    
    blob[33] = 0;
    while (true) {
        crypto_generichash_blake2b_state state;
        crypto_generichash_blake2b_init_salt_personal(&state, nullptr, 0, 64, nullptr, ZCASH_EXPANDSEED_PERSONALIZATION);
        crypto_generichash_blake2b_update(&state, blob, 34);
        crypto_generichash_blake2b_final(&state, res.data(), 11);
        
        if (librustzcash_check_diversifier(res.data())) {
            break;
        } else if (blob[33] == 255) {
            throw std::runtime_error("librustzcash_check_diversifier did not return valid diversifier");
        }
        blob[33] += 1;
    }
        
    return res;
}
开发者ID:Whiteblock,项目名称:zcash,代码行数:25,代码来源:prf.cpp

示例5: selectBranch

// Which branch would contain the specified hash
int SHAMapNodeID::selectBranch (uint256 const& hash) const
{
#if RIPPLE_VERIFY_NODEOBJECT_KEYS

    if (mDepth >= 64)
    {
        assert (false);
        return -1;
    }

    if ((hash & Masks(mDepth)) != mNodeID)
    {
        std::cerr << "selectBranch(" << getString () << std::endl;
        std::cerr << "  " << hash << " off branch" << std::endl;
        assert (false);
        return -1;  // does not go under this node
    }

#endif

    int branch = * (hash.begin () + (mDepth / 2));

    if (mDepth & 1)
        branch &= 0xf;
    else
        branch >>= 4;

    assert ((branch >= 0) && (branch < 16));

    return branch;
}
开发者ID:bachase,项目名称:rippled,代码行数:32,代码来源:SHAMapNodeID.cpp

示例6: runtime_error

std::uint64_t ProofOfWork::getDifficulty (uint256 const& target, int iterations)
{
    // calculate the approximate number of hashes required to solve this proof of work
    if ((iterations > kMaxIterations) || (target < sMinTarget))
    {
        WriteLog (lsINFO, ProofOfWork) << "Iterations:" << iterations;
        WriteLog (lsINFO, ProofOfWork) << "MaxIterat: " << kMaxIterations;
        WriteLog (lsINFO, ProofOfWork) << "Target:    " << target;
        WriteLog (lsINFO, ProofOfWork) << "MinTarget: " << sMinTarget;
        throw std::runtime_error ("invalid proof of work target/iteration");
    }

    // more iterations means more hashes per iteration but also a larger final hash
    std::uint64_t difficulty = iterations + (iterations / 8);

    // Multiply the number of hashes needed by 256 for each leading zero byte in the difficulty
    const unsigned char* ptr = target.begin ();

    while (*ptr == 0)
    {
        difficulty *= 256;
        ++ptr;
    }

    difficulty = (difficulty * 256) / (*ptr + 1);

    return difficulty;
}
开发者ID:619213152,项目名称:vpal20,代码行数:28,代码来源:ProofOfWork.cpp

示例7: ForEachMN

std::vector<std::pair<arith_uint256, CDeterministicMNCPtr>> CDeterministicMNList::CalculateScores(const uint256& modifier) const
{
    std::vector<std::pair<arith_uint256, CDeterministicMNCPtr>> scores;
    scores.reserve(GetAllMNsCount());
    ForEachMN(true, [&](const CDeterministicMNCPtr& dmn) {
        if (dmn->pdmnState->confirmedHash.IsNull()) {
            // we only take confirmed MNs into account to avoid hash grinding on the ProRegTxHash to sneak MNs into a
            // future quorums
            return;
        }
        // calculate sha256(sha256(proTxHash, confirmedHash), modifier) per MN
        // Please note that this is not a double-sha256 but a single-sha256
        // The first part is already precalculated (confirmedHashWithProRegTxHash)
        // TODO When https://github.com/bitcoin/bitcoin/pull/13191 gets backported, implement something that is similar but for single-sha256
        uint256 h;
        CSHA256 sha256;
        sha256.Write(dmn->pdmnState->confirmedHashWithProRegTxHash.begin(), dmn->pdmnState->confirmedHashWithProRegTxHash.size());
        sha256.Write(modifier.begin(), modifier.size());
        sha256.Finalize(h.begin());

        scores.emplace_back(UintToArith256(h), dmn);
    });

    return scores;
}
开发者ID:dashpay,项目名称:dash,代码行数:25,代码来源:deterministicmns.cpp

示例8: NotifyBlock

bool CZMQPublishHashBlockNotifier::NotifyBlock(const uint256 &hash)
{
    LogPrint("zmq", "Publish hash block %s\n", hash.GetHex());
    char data[32];
    for (unsigned int i = 0; i < 32; i++)
        data[31 - i] = hash.begin()[i];
    int rc = zmq_send_multipart(psocket, "hashblock", 9, data, 32, 0);
    return rc == 0;
}
开发者ID:CryptoDJ,项目名称:DarkSilk-Release-Candidate,代码行数:9,代码来源:zmqpublishnotifier.cpp

示例9: sign

void RippleAddress::sign(uint256 const& message, Blob& retSignature) const
{
	assert(vchData.size() == 64);

	const unsigned char *key = vchData.data();
	retSignature.resize(crypto_sign_BYTES);
	crypto_sign_detached(&retSignature[0], NULL,
		(unsigned char*)message.begin(), message.size(),
		key);
}
开发者ID:Payshares,项目名称:paysharesd,代码行数:10,代码来源:RippleAddress.cpp

示例10: CheckReqNonce

int PrimeWorker::CheckReqNonce(const uint256& nonce) {
	
	const uint32_t* limbs = (uint32_t*)nonce.begin();
	
	uint32_t tmp = limbs[0];
	for(int i = 1; i < 7; ++i)
		tmp *= limbs[i];
	tmp += limbs[7];
	
	return !tmp;
	
}
开发者ID:LongAndShort,项目名称:xpmpool,代码行数:12,代码来源:pool.cpp

示例11: sign

	void PaysharesPrivateKey::sign(uint256 const& message, Blob& retSignature) const
	{
		unsigned char out[crypto_sign_BYTES + message.bytes];
		unsigned long long len;
		const unsigned char *key = mPair.mPrivateKey.data();

		// contrary to the docs it puts the signature in front
		crypto_sign(out, &len,
			(unsigned char*)message.begin(), message.size(),
			key);

		retSignature.resize(crypto_sign_BYTES);
		memcpy(&retSignature[0], out, crypto_sign_BYTES);
	}
开发者ID:Payshares,项目名称:paysharesd,代码行数:14,代码来源:PaysharesPrivateKey.cpp

示例12: memcpy

// Sapling 
std::array<unsigned char, 64> PRF_expand(const uint256& sk, unsigned char t)
{
    std::array<unsigned char, 64> res;   
    unsigned char blob[33];

    memcpy(&blob[0], sk.begin(), 32);
    blob[32] = t;
        
    crypto_generichash_blake2b_state state;
    crypto_generichash_blake2b_init_salt_personal(&state, nullptr, 0, 64, nullptr, ZCASH_EXPANDSEED_PERSONALIZATION);
    crypto_generichash_blake2b_update(&state, blob, 33);
    crypto_generichash_blake2b_final(&state, res.data(), 64);
    
    return res;
}
开发者ID:Whiteblock,项目名称:zcash,代码行数:16,代码来源:prf.cpp

示例13: dumpKeyInfo

void dumpKeyInfo(uint256 secret)
{
    CKey key;
    CAnoncoinSecret b58secret;
    printf("  * secret (hex): %s\n", secret.GetHex().c_str());
    for (int nCompressed=0; nCompressed<2; nCompressed++)
    {
        bool fCompressed = nCompressed == 1;
        printf("  * %s:\n", fCompressed ? "compressed" : "uncompressed");
        key.Set( secret.begin(), secret.end(), fCompressed );
        b58secret.SetKey( key );
        printf("    * secret (base58): %s\n", b58secret.ToString().c_str());
        CPubKey pubkey = key.GetPubKey();
        printf("    * address (base58): %s\n", CAnoncoinAddress(CTxDestination(pubkey.GetID())).ToString().c_str() );
    }
}
开发者ID:Anoncoin,项目名称:anoncoin,代码行数:16,代码来源:key_tests.cpp

示例14: PRF

// Sprout
uint256 PRF(bool a, bool b, bool c, bool d,
            const uint252& x,
            const uint256& y)
{
    uint256 res;
    unsigned char blob[64];

    memcpy(&blob[0], x.begin(), 32);
    memcpy(&blob[32], y.begin(), 32);

    blob[0] &= 0x0F;
    blob[0] |= (a ? 1 << 7 : 0) | (b ? 1 << 6 : 0) | (c ? 1 << 5 : 0) | (d ? 1 << 4 : 0);

    CSHA256 hasher;
    hasher.Write(blob, 64);
    hasher.FinalizeNoPadding(res.begin());

    return res;
}
开发者ID:Whiteblock,项目名称:zcash,代码行数:20,代码来源:prf.cpp

示例15: ECDSAPrivateKey

ec_key ECDSAPrivateKey (uint256 const& serialized)
{
    BIGNUM* bn = BN_bin2bn (serialized.begin(), serialized.size(), nullptr);

    if (bn == nullptr)
    {
        throw std::runtime_error ("ec_key::ec_key: BN_bin2bn failed");
    }

    EC_KEY* key = new_initialized_EC_KEY();

    const bool ok = EC_KEY_set_private_key (key, bn);

    BN_clear_free (bn);

    if (! ok)
    {
        EC_KEY_free (key);
    }

    return ec_key::acquire ((ec_key::pointer_t) key);
}
开发者ID:Joke-Dk,项目名称:rippled,代码行数:22,代码来源:ECDSAKey.cpp


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