| 189 | } |
| 190 | |
| 191 | bool VerifyBlindValueProof(CAmount value, const CConfidentialValue& conf_value, const std::vector<unsigned char>& proof, const CConfidentialAsset& conf_asset) |
| 192 | { |
| 193 | if (conf_value.IsNull() || conf_asset.IsNull()) { |
| 194 | return false; |
| 195 | } |
| 196 | |
| 197 | secp256k1_pedersen_commitment value_commit; |
| 198 | if (secp256k1_pedersen_commitment_parse(secp256k1_blind_context, &value_commit, conf_value.vchCommitment.data()) == 0) { |
| 199 | return false; |
| 200 | } |
| 201 | |
| 202 | secp256k1_generator gen; |
| 203 | if (secp256k1_generator_parse(secp256k1_blind_context, &gen, conf_asset.vchCommitment.data()) == 0) { |
| 204 | return false; |
| 205 | } |
| 206 | |
| 207 | uint64_t min_value; |
| 208 | uint64_t max_value; |
| 209 | if (secp256k1_rangeproof_verify(secp256k1_blind_context, &min_value, &max_value, &value_commit, proof.data(), proof.size(), /* extra_commit */ nullptr, /* extra_commit_len */ 0, &gen) == 0) { |
| 210 | return false; |
| 211 | } |
| 212 | return min_value == (uint64_t)value; |
| 213 | } |
| 214 | |
| 215 | BlindProofResult VerifyBlindProofs(const PSBTOutput& o) { |
| 216 | // No blinding, no problem |
no test coverage detected