MCPcopy Create free account
hub / github.com/ElementsProject/elements / VerifyRangeProof

Method VerifyRangeProof

src/script/sigcache.cpp:176–216  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

174}
175
176bool CachingRangeProofChecker::VerifyRangeProof(const std::vector<unsigned char>& vchRangeProof, const std::vector<unsigned char>& vchValueCommitment, const std::vector<unsigned char>& vchAssetCommitment, const CScript& scriptPubKey, const secp256k1_context* secp256k1_ctx_verify_amounts) const
177{
178 uint256 entry;
179 rangeProofCache.ComputeEntryRangeProof(entry, vchRangeProof, vchValueCommitment);
180
181 if (rangeProofCache.Get(entry, !store)) {
182 return true;
183 }
184
185 if (vchRangeProof.size() == 0) {
186 return false;
187 }
188
189 uint64_t min_value, max_value;
190 secp256k1_pedersen_commitment commit;
191 if (secp256k1_pedersen_commitment_parse(secp256k1_ctx_verify_amounts, &commit, &vchValueCommitment[0]) != 1)
192 return false;
193
194 secp256k1_generator tag;
195 if (secp256k1_generator_parse(secp256k1_ctx_verify_amounts, &tag, &vchAssetCommitment[0]) != 1)
196 return false;
197
198 if (!secp256k1_rangeproof_verify(secp256k1_ctx_verify_amounts, &min_value, &max_value, &commit, vchRangeProof.data(), vchRangeProof.size(), scriptPubKey.size() ? &scriptPubKey.front() : NULL, scriptPubKey.size(), &tag)) {
199 return false;
200 }
201
202 // An rangeproof is not valid if the output is spendable but the minimum number
203 // is 0. This is to prevent people passing 0-value tokens around, or conjuring
204 // reissuance tokens from nothing then attempting to reissue an asset.
205 // ie reissuance doesn't require revealing value of reissuance output
206 // Issuances proofs are always "unspendable" as they commit to an empty script.
207 if (min_value == 0 && !scriptPubKey.IsUnspendable()) {
208 return false;
209 }
210
211 if (store) {
212 rangeProofCache.Set(entry);
213 }
214
215 return true;
216}
217
218bool 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{

Callers 1

operator()Method · 0.80

Calls 9

IsUnspendableMethod · 0.80
GetMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected