MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / VerifyTaprootCommitment

Function VerifyTaprootCommitment

src/script/interpreter.cpp:1913–1925  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1911}
1912
1913static bool VerifyTaprootCommitment(const std::vector<unsigned char>& control, const std::vector<unsigned char>& program, const uint256& tapleaf_hash)
1914{
1915 assert(control.size() >= TAPROOT_CONTROL_BASE_SIZE);
1916 assert(program.size() >= uint256::size());
1917 //! The internal pubkey (x-only, so no Y coordinate parity).
1918 const XOnlyPubKey p{std::span{control}.subspan(1, TAPROOT_CONTROL_BASE_SIZE - 1)};
1919 //! The output pubkey (taken from the scriptPubKey).
1920 const XOnlyPubKey q{program};
1921 // Compute the Merkle root from the leaf and the provided path.
1922 const uint256 merkle_root = ComputeTaprootMerkleRoot(control, tapleaf_hash);
1923 // Verify that the output pubkey matches the tweaked internal pubkey, after correcting for parity.
1924 return q.CheckTapTweak(p, merkle_root, control[0] & 1);
1925}
1926
1927static bool VerifyWitnessProgram(const CScriptWitness& witness, int witversion, const std::vector<unsigned char>& program, script_verify_flags flags, const BaseSignatureChecker& checker, ScriptError* serror, bool is_p2sh)
1928{

Callers 1

VerifyWitnessProgramFunction · 0.85

Calls 4

sizeFunction · 0.85
ComputeTaprootMerkleRootFunction · 0.85
CheckTapTweakMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected