diff options
author | Pieter Wuille <pieter@wuille.net> | 2021-08-19 13:49:19 -0400 |
---|---|---|
committer | Pieter Wuille <pieter@wuille.net> | 2021-08-20 14:30:59 -0400 |
commit | 2f0190320ddf45ff35f07950e8f01e8f15538043 (patch) | |
tree | 05382a819ef64d00fa2570912721cfdc0b829a82 /src | |
parent | 4fc15d15667d9d9c4fb5515ce73c05b4596298ec (diff) |
Avoid temporary vectors/uint256s in VerifyTaprootCommitment
As XOnlyPubKey has a Span-based constructor, that can be used directly
without needing to first convert the byte sequence into a vector, only
to convert that to a uint256, which only then can then be passed as a
span to the constructor.
Diffstat (limited to 'src')
-rw-r--r-- | src/script/interpreter.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp index dd7c0a4a05..eafa9840d7 100644 --- a/src/script/interpreter.cpp +++ b/src/script/interpreter.cpp @@ -1874,9 +1874,9 @@ static bool VerifyTaprootCommitment(const std::vector<unsigned char>& control, c assert(control.size() >= TAPROOT_CONTROL_BASE_SIZE); assert(program.size() >= uint256::size()); //! The internal pubkey (x-only, so no Y coordinate parity). - const XOnlyPubKey p{uint256(std::vector<unsigned char>(control.begin() + 1, control.begin() + TAPROOT_CONTROL_BASE_SIZE))}; + const XOnlyPubKey p{Span<const unsigned char>{control.data() + 1, control.data() + TAPROOT_CONTROL_BASE_SIZE}}; //! The output pubkey (taken from the scriptPubKey). - const XOnlyPubKey q{uint256(program)}; + const XOnlyPubKey q{program}; // Compute the Merkle root from the leaf and the provided path. const uint256 merkle_root = ComputeTaprootMerkleRoot(control, tapleaf_hash); // Verify that the output pubkey matches the tweaked internal pubkey, after correcting for parity. |