Skip to content

Commit a93e7a4

Browse files
committed
Merge bitcoin#22748: refactor: Avoid temporary vectors/uint256s in VerifyTaprootCommitment
2f01903 Avoid temporary vectors/uint256s in VerifyTaprootCommitment (Pieter Wuille) Pull request description: 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. Reported by @ roconnor-blockstream. ACKs for top commit: Zero-1729: crACK 2f01903 theStack: re-ACK 2f01903 jonatack: ACK 2f01903 Tree-SHA512: f5e809d693cf6f6e899278cd706548eb4341e73b3f7ca8926b5fb50afb2098077d691579aea84fd7db2a7edd76be8e400aa2ed886091ee3416651b8a36efba37
2 parents e9d6eb1 + 2f01903 commit a93e7a4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/script/interpreter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1874,9 +1874,9 @@ static bool VerifyTaprootCommitment(const std::vector<unsigned char>& control, c
18741874
assert(control.size() >= TAPROOT_CONTROL_BASE_SIZE);
18751875
assert(program.size() >= uint256::size());
18761876
//! The internal pubkey (x-only, so no Y coordinate parity).
1877-
const XOnlyPubKey p{uint256(std::vector<unsigned char>(control.begin() + 1, control.begin() + TAPROOT_CONTROL_BASE_SIZE))};
1877+
const XOnlyPubKey p{Span<const unsigned char>{control.data() + 1, control.data() + TAPROOT_CONTROL_BASE_SIZE}};
18781878
//! The output pubkey (taken from the scriptPubKey).
1879-
const XOnlyPubKey q{uint256(program)};
1879+
const XOnlyPubKey q{program};
18801880
// Compute the Merkle root from the leaf and the provided path.
18811881
const uint256 merkle_root = ComputeTaprootMerkleRoot(control, tapleaf_hash);
18821882
// Verify that the output pubkey matches the tweaked internal pubkey, after correcting for parity.

0 commit comments

Comments
 (0)