| 101 | } |
| 102 | |
| 103 | bool CreateValueRangeProof(std::vector<unsigned char>& rangeproof, const uint256& value_blinder, const uint256& nonce, const CAmount amount, const CScript& scriptPubKey, const secp256k1_pedersen_commitment& value_commit, const secp256k1_generator& gen, const CAsset& asset, const uint256& asset_blinder) |
| 104 | { |
| 105 | // Prep range proof |
| 106 | size_t rangeproof_len = 5134; |
| 107 | rangeproof.resize(rangeproof_len); |
| 108 | |
| 109 | // Compose sidechannel message to convey asset info (ID and asset blinds) |
| 110 | unsigned char asset_message[SIDECHANNEL_MSG_SIZE]; |
| 111 | memcpy(asset_message, asset.begin(), 32); |
| 112 | memcpy(asset_message + 32, asset_blinder.begin(), 32); |
| 113 | |
| 114 | // Sign rangeproof |
| 115 | int ct_exponent = (int)gArgs.GetIntArg("-ct_exponent", 0); |
| 116 | int ct_bits = (int)gArgs.GetIntArg("-ct_bits", 52); |
| 117 | // If min_value is 0, scriptPubKey must be unspendable |
| 118 | uint64_t min_value = scriptPubKey.IsUnspendable() ? 0 : 1; |
| 119 | int res = secp256k1_rangeproof_sign(secp256k1_blind_context, rangeproof.data(), &rangeproof_len, min_value, &value_commit, value_blinder.begin(), nonce.begin(), ct_exponent, ct_bits, amount, asset_message, sizeof(asset_message), scriptPubKey.size() ? &scriptPubKey.front() : NULL, scriptPubKey.size(), &gen); |
| 120 | rangeproof.resize(rangeproof_len); |
| 121 | return (res == 1); |
| 122 | } |
| 123 | |
| 124 | // Create an explicit value rangeproof which proves that the commitment commits to an explicit value |
| 125 | static bool CreateBlindValueProof(std::vector<unsigned char>& rangeproof, const uint256& value_blinder, const CAmount amount, const secp256k1_pedersen_commitment& value_commit, const secp256k1_generator& gen) |
no test coverage detected