valid_pk pk checks if the contents of pk is a valid public key. This is the case if:
pk is 64 bytes long (it is in the "raw" form)
the first 32 bytes encode x and the last 32 bytes encode y such that (x, y) is on the curve and both x and y are greater than 0 and less than the order of the curve
ECDSA
ECDSA signing and signature verification functions
For the sign and verify functions included in this module, msg is the 32-byte digest of the message to be signed, requiring users to use a cryptographic hash function of their choosing before calling them.
Versions of the ECDSA functions which work on low-S normalized signatures. These functions can be used when compatibility with libsecp256k1 is required.