MCPcopy Create free account
hub / github.com/ElementsProject/elements / GenerateRangeproof

Function GenerateRangeproof

src/blind.cpp:249–268  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

247}
248
249bool GenerateRangeproof(std::vector<unsigned char>& rangeproof, const std::vector<unsigned char*>& value_blindptrs, const uint256& nonce, const CAmount amount, const CScript& scriptPubKey, const secp256k1_pedersen_commitment& value_commit, const secp256k1_generator& gen, const CAsset& asset, std::vector<const unsigned char*>& asset_blindptrs)
250{
251 // Prep range proof
252 size_t nRangeProofLen = 5134;
253 rangeproof.resize(nRangeProofLen);
254
255 // Compose sidechannel message to convey asset info (ID and asset blinds)
256 unsigned char asset_message[SIDECHANNEL_MSG_SIZE];
257 memcpy(asset_message, asset.begin(), 32);
258 memcpy(asset_message+32, asset_blindptrs[asset_blindptrs.size()-1], 32);
259
260 // Sign rangeproof
261 int ct_exponent = (int)gArgs.GetIntArg("-ct_exponent", 0);
262 int ct_bits = (int)gArgs.GetIntArg("-ct_bits", 52);
263 // If min_value is 0, scriptPubKey must be unspendable
264 uint64_t min_value = scriptPubKey.IsUnspendable() ? 0 : 1;
265 int res = secp256k1_rangeproof_sign(secp256k1_blind_context, rangeproof.data(), &nRangeProofLen, min_value, &value_commit, value_blindptrs.back(), nonce.begin(), ct_exponent, ct_bits, amount, asset_message, sizeof(asset_message), scriptPubKey.size() ? &scriptPubKey.front() : NULL, scriptPubKey.size(), &gen);
266 rangeproof.resize(nRangeProofLen);
267 return (res == 1);
268}
269
270void BlindAsset(CConfidentialAsset& conf_asset, secp256k1_generator& asset_gen, const CAsset& asset, const unsigned char* asset_blindptr)
271{

Callers 1

BlindTransactionFunction · 0.85

Calls 7

GetIntArgMethod · 0.80
IsUnspendableMethod · 0.80
resizeMethod · 0.45
beginMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected