DKIM works with two matching keys. One is private and stays on the sending server. The other is public and sits in your DNS. The private key signs each message, and anyone can use the public key to check that signature.1
That's why your mail service asks you to add a record. It's handing you the public half, and the receiving server needs to find it in your domain's DNS.
The two keys
Google's help page puts it this way. The public key is stored in your domain's DNS TXT record. The private key is uploaded to your email server, where it generates and adds a DKIM signature to each outgoing message.1
When mail arrives, the receiver's server gets the public key from the DKIM TXT record. It uses that key to read the signature and authenticate the email.1
The standard says the claim of responsibility is checked by a cryptographic signature and by asking the signer's domain for the key.2
What a selector is
A domain may need more than one key. Maybe the website's contact form signs one way and a newsletter tool signs another. To allow this, the standard says the key namespace is subdivided using "selectors".2
A selector is just a label. The standard's examples include office locations or the month a key was made.2 Mail services often pick a name for you, and Google's page says the default prefix selector there is "google".1
Every signed message carries the selector in its signature, in a tag called s=, next to the signing domain in a tag called d=.2
Where the receiver looks
The receiver joins the selector, the fixed word _domainkey and the domain. The standard says all DKIM keys are stored in a subdomain named "_domainkey". Its example: a domain of example.com and a selector of foo.bar means the query is for foo.bar._domainkey.example.com.2
So if your mail service tells you to create a TXT record whose name ends in ._domainkey, that's where the name comes from. Your DNS host usually adds your domain on the end, but check its help pages. The adding side is covered on the TXT records page.
Why selectors help when keys change
Selectors let you change keys without a gap. The standard suggests that when you want a new key, a better strategy is to assign new keys to new selectors rather than reuse an old one.2 The old and new keys can sit side by side while mail signed with the old one is still being delivered.
What DKIM proves, and what it doesn't
A valid signature shows the message was signed by someone holding the private key for that signing domain. It doesn't say the signing domain matches the From address people see. The DMARC standard makes this point: a message can carry a valid signature from any domain, so a signature alone isn't enough to infer who wrote it.3
Matching the signer to the From address is DMARC's job, covered on the DMARC page. The sending-server check has its own SPF page.
Where the facts come from
- Set up DKIM, Google Workspace Admin Help
- RFC 6376: DomainKeys Identified Mail (DKIM) Signatures, IETF
- RFC 7489: Domain-based Message Authentication, Reporting, and Conformance (DMARC), IETF