Create an explicit value rangeproof which proves that the commitment commits to an explicit value
| 153 | |
| 154 | // Create an explicit value rangeproof which proves that the commitment commits to an explicit value |
| 155 | bool CreateBlindAssetProof(std::vector<unsigned char>& assetproof, const CAsset& asset, const CConfidentialAsset& asset_commit, const uint256& asset_blinder) |
| 156 | { |
| 157 | const unsigned char zero32[32] = {0}; |
| 158 | secp256k1_surjectionproof proof; |
| 159 | size_t input_index; |
| 160 | secp256k1_generator asset_gen; |
| 161 | secp256k1_generator blinded_asset_gen; |
| 162 | secp256k1_fixed_asset_tag fixed_tag; |
| 163 | memcpy(&fixed_tag, asset.begin(), 32); |
| 164 | |
| 165 | if (!secp256k1_generator_generate(secp256k1_blind_context, &asset_gen, asset.begin())) { |
| 166 | return false; |
| 167 | } |
| 168 | if (secp256k1_generator_parse(secp256k1_blind_context, &blinded_asset_gen, asset_commit.vchCommitment.data()) == 0) { |
| 169 | return false; |
| 170 | } |
| 171 | |
| 172 | if (!secp256k1_surjectionproof_initialize(secp256k1_blind_context, &proof, &input_index, &fixed_tag, 1, 1, &fixed_tag, 1, zero32)) { |
| 173 | return false; |
| 174 | } |
| 175 | assert(input_index == 0); |
| 176 | |
| 177 | if (!secp256k1_surjectionproof_generate(secp256k1_blind_context, &proof, &asset_gen, 1, &blinded_asset_gen, 0, zero32, asset_blinder.data())) { |
| 178 | return false; |
| 179 | } |
| 180 | if (!secp256k1_surjectionproof_verify(secp256k1_blind_context, &proof, &asset_gen, 1, &blinded_asset_gen)) { |
| 181 | return false; |
| 182 | } |
| 183 | |
| 184 | size_t output_len = secp256k1_surjectionproof_serialized_size(secp256k1_blind_context, &proof); |
| 185 | assetproof.resize(output_len); |
| 186 | secp256k1_surjectionproof_serialize(secp256k1_blind_context, &assetproof[0], &output_len, &proof); |
| 187 | assert(output_len == assetproof.size()); |
| 188 | return true; |
| 189 | } |
| 190 | |
| 191 | bool VerifyBlindValueProof(CAmount value, const CConfidentialValue& conf_value, const std::vector<unsigned char>& proof, const CConfidentialAsset& conf_asset) |
| 192 | { |
no test coverage detected