The function ExtractPubKey() checks if a given script matches the P2PK pattern
(<PubKey> OP_CHECKSIG), extracts the PubKey and additionally checks if it is
cryptographically valid (full validation with ECC library via CPubKey::IsFullyValid()).
Currently this is done manually in the following order:
- check if first script OP is data push with valid PubKey length (first part of pattern match), extract PubKey
- create
CPubKeyobject with extracted PubKey - fully validate public key
- check if last script OP is
OP_CHECKSIG(second part of pattern match)
Using Solver, the pattern matching and PubKey extraction can be done via a single step, leading to the following simplified order with shorter code:
- check if given script matches P2PK pattern with Solver (also contains valid PubKey length check), extracts Pubkey
- create
CPubKeyobject with extracted Pubkey - fully validate public key