NIP-04: encrypts the message content but leaks metadata: anyone can see who is messaging whom, when, and how often, since sender/receiver pubkeys and timestamps are visible on relays.
NIP-17: fixes this by wrapping the encrypted message inside a gift-wrap (NIP-59): the outer event uses a random throwaway key, a randomized timestamp, and is sealed so relays and observers cannot see the real sender, receiver, or timing. The actual message is only visible to the intended recipient after unwrapping two layers of encryption.
In short: NIP-04 = encrypted content, public metadata. NIP-17 = encrypted content + protected metadata.
