| 247 | } |
| 248 | |
| 249 | bool 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 | |
| 270 | void BlindAsset(CConfidentialAsset& conf_asset, secp256k1_generator& asset_gen, const CAsset& asset, const unsigned char* asset_blindptr) |
| 271 | { |
no test coverage detected