A **pubkey** is a public portion of a keypair which can be used to verify signatures made with the private portion of the keypair.

Keys are a part of the Elliptic Curve Digital Signature Algorithm. A private key is a random number, while the public key is a 2D point coordinate on an Elliptic Curve derived from it. The private key is used to sign messages (in case of Bitcoin - the transactions), and the public key is used to check whether the signature is correct. The public key can either be used raw in a transaction, or turned into a Bitcoin address by means of hashing and other operations.

One can use any library that supports the ECDSA curve used by Bitcoin (secp256k1) to generate the appropriate keypair.

However, most commonly one leaves key pair generation to the Bitcoin program. If needed be, the private key can be retrieved from the program by using `dumpprivkey`

Bitcoin API call.

â€‹What is a private key and a public key?â€‹

[1] https://bitcoin.org/en/glossary/public-keyâ€‹

[2] https://bitcoin.stackexchange.com/questions/4675/what-is-a-private-key-and-a-public-keyâ€‹