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

Function VerifyTaprootCommitment

src/script/interpreter.cpp:3273–3285  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3271}
3272
3273static bool VerifyTaprootCommitment(const std::vector<unsigned char>& control, const std::vector<unsigned char>& program, const uint256& tapleaf_hash)
3274{
3275 assert(control.size() >= TAPROOT_CONTROL_BASE_SIZE);
3276 assert(program.size() >= uint256::size());
3277 //! The internal pubkey (x-only, so no Y coordinate parity).
3278 const XOnlyPubKey p{Span{control}.subspan(1, TAPROOT_CONTROL_BASE_SIZE - 1)};
3279 //! The output pubkey (taken from the scriptPubKey).
3280 const XOnlyPubKey q{program};
3281 // Compute the Merkle root from the leaf and the provided path.
3282 const uint256 merkle_root = ComputeTaprootMerkleRoot(control, tapleaf_hash);
3283 // Verify that the output pubkey matches the tweaked internal pubkey, after correcting for parity.
3284 return q.CheckTapTweak(p, merkle_root, control[0] & 1);
3285}
3286
3287static bool VerifyWitnessProgram(const CScriptWitness& witness, int witversion, const std::vector<unsigned char>& program, unsigned int flags, const BaseSignatureChecker& checker, ScriptError* serror, bool is_p2sh)
3288{

Callers 1

VerifyWitnessProgramFunction · 0.85

Calls 4

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

Tested by

no test coverage detected