How does public-key cryptography work?
NIST describes it as a form of cryptography that uses two related keys, a public key and a private key, chosen so that deriving the private key from the public key is computationally infeasible [1]. One key encrypts or digitally signs the data; the other decrypts it or verifies the signature [1]. The approach also lets parties establish keys securely without sharing a secret beforehand [1]. That is why it also goes by the name asymmetric cryptography [1].
What do RSA's public and private keys look like?
RFC 8017 from the IETF gives recommendations for implementing public-key cryptography based on the RSA algorithm [2]. Concretely, an RSA public key has two parts, the modulus n and the public exponent e. The private key is held either as the pair (n, d) or as a set of parameters built from the prime factors [2].
The document defines both encryption and signature schemes. New applications must support RSAES-OAEP for encryption and RSASSA-PSS for signatures; the older PKCS1-v1_5 schemes remain only for compatibility with existing applications [2].
How do the keys work in a digital signature?
For signatures, the direction flips. The owner signs with the private key they keep secret, and anyone holding the public key can verify that signature [1]. That is how you can check that a software update or a document really came from its claimed source without any secret key changing hands.