simplify rangeproof validation caching

This commit is contained in:
Gregory Sanders 2018-04-25 10:45:14 -04:00
parent 92871c6231
commit 9572165238

View file

@ -63,6 +63,11 @@ public:
CSHA256().Write(nonce.begin(), 32).Write(hash.begin(), 32).Write(&pubkey[0], pubkey.size()).Write(&vchSig[0], vchSig.size()).Write(&vchCommitment[0], vchCommitment.size()).Write(&scriptPubKey[0], scriptPubKey.size()).Finalize(entry.begin());
}
void ComputeEntry(uint256& entry, const std::vector<unsigned char>& proof, const std::vector<unsigned char>& commitment)
{
CSHA256().Write(nonce.begin(), nonce.size()).Write(proof.data(), proof.size()).Write(commitment.data(), commitment.size()).Finalize(entry.begin());
}
bool
Get(const uint256& entry, const bool erase)
{
@ -145,9 +150,8 @@ bool CachingTransactionSignatureChecker::VerifySignature(const std::vector<unsig
bool 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
{
CPubKey pubkey(vchValueCommitment);
uint256 entry;
rangeProofCache.ComputeEntry(entry, uint256(), vchRangeProof, pubkey, vchAssetCommitment, scriptPubKey);
rangeProofCache.ComputeEntry(entry, vchRangeProof, vchValueCommitment);
if (rangeProofCache.Get(entry, !store)) {
return true;