| 216 | } |
| 217 | |
| 218 | bool CachingSurjectionProofChecker::VerifySurjectionProof(secp256k1_surjectionproof& proof, std::vector<secp256k1_generator>& vTags, secp256k1_generator& gen, const secp256k1_context* secp256k1_ctx_verify_amounts, const uint256& wtxid) const |
| 219 | { |
| 220 | |
| 221 | // Serialize proof |
| 222 | std::vector<unsigned char> vchproof; |
| 223 | size_t proof_len = secp256k1_surjectionproof_serialized_size(secp256k1_ctx_verify_amounts, &proof); |
| 224 | vchproof.resize(proof_len); |
| 225 | assert(secp256k1_surjectionproof_serialize(secp256k1_ctx_verify_amounts, vchproof.data(), &proof_len, &proof) == 1); |
| 226 | |
| 227 | // wtxid commits to all data including surj targets |
| 228 | // we need to specify the proof and output asset point to be unique |
| 229 | uint256 entry; |
| 230 | surjectionProofCache.ComputeEntrySurjectionProof(entry, wtxid, vchproof, std::vector<unsigned char>(std::begin(gen.data), std::end(gen.data))); |
| 231 | |
| 232 | if (surjectionProofCache.Get(entry, !store)) { |
| 233 | return true; |
| 234 | } |
| 235 | |
| 236 | if (secp256k1_surjectionproof_verify(secp256k1_ctx_verify_amounts, &proof, vTags.data(), vTags.size(), &gen) != 1) { |
| 237 | return false; |
| 238 | } |
| 239 | |
| 240 | if (store) { |
| 241 | surjectionProofCache.Set(entry); |
| 242 | } |
| 243 | |
| 244 | return true; |
| 245 | } |
| 246 | |
| 247 | // END ELEMENTS |
| 248 | // |
no test coverage detected