本文整理汇总了C++中CBigNum::setuint256方法的典型用法代码示例。如果您正苦于以下问题:C++ CBigNum::setuint256方法的具体用法?C++ CBigNum::setuint256怎么用?C++ CBigNum::setuint256使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBigNum
的用法示例。
在下文中一共展示了CBigNum::setuint256方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SeedToZPIV
void CzPIVWallet::SeedToZPIV(const uint512& seedZerocoin, CBigNum& bnValue, CBigNum& bnSerial, CBigNum& bnRandomness, CKey& key)
{
ZerocoinParams* params = Params().Zerocoin_Params(false);
//convert state seed into a seed for the private key
uint256 nSeedPrivKey = seedZerocoin.trim256();
bool isValidKey = false;
key = CKey();
while (!isValidKey) {
nSeedPrivKey = Hash(nSeedPrivKey.begin(), nSeedPrivKey.end());
isValidKey = libzerocoin::GenerateKeyPair(params->coinCommitmentGroup.groupOrder, nSeedPrivKey, key, bnSerial);
}
//hash randomness seed with Bottom 256 bits of seedZerocoin & attempts256 which is initially 0
uint256 randomnessSeed = uint512(seedZerocoin >> 256).trim256();
uint256 hashRandomness = Hash(randomnessSeed.begin(), randomnessSeed.end());
bnRandomness.setuint256(hashRandomness);
bnRandomness = bnRandomness % params->coinCommitmentGroup.groupOrder;
//See if serial and randomness make a valid commitment
// Generate a Pedersen commitment to the serial number
CBigNum commitmentValue = params->coinCommitmentGroup.g.pow_mod(bnSerial, params->coinCommitmentGroup.modulus).mul_mod(
params->coinCommitmentGroup.h.pow_mod(bnRandomness, params->coinCommitmentGroup.modulus),
params->coinCommitmentGroup.modulus);
CBigNum random;
uint256 attempts256 = 0;
// Iterate on Randomness until a valid commitmentValue is found
while (true) {
// Now verify that the commitment is a prime number
// in the appropriate range. If not, we'll throw this coin
// away and generate a new one.
if (IsValidCoinValue(commitmentValue)) {
bnValue = commitmentValue;
return;
}
//Did not create a valid commitment value.
//Change randomness to something new and random and try again
attempts256++;
hashRandomness = Hash(randomnessSeed.begin(), randomnessSeed.end(),
attempts256.begin(), attempts256.end());
random.setuint256(hashRandomness);
bnRandomness = (bnRandomness + random) % params->coinCommitmentGroup.groupOrder;
commitmentValue = commitmentValue.mul_mod(params->coinCommitmentGroup.h.pow_mod(random, params->coinCommitmentGroup.modulus), params->coinCommitmentGroup.modulus);
}
}