"El sombrero de tres picos" by Pedro Antonio de Alarcón is a novel published in 1874. Set in early 1800s Granada, it tells the story of the miller Lucas and his beautiful wife Frasquita, whose happy marriage faces a test when a corrupt magistrate schemes to seduce her. After the magistrate's nighttime intrusion leads to a series of misunderstandings, Lucas believes himself betrayed and plots revenge by impersonating his rival. What follows is a tale of mistaken identities, suspicion, and honor that inspired Manuel de Falla's famous 1919 ballet.
Wikipedia page about this book: en.wikipedia.org/wiki/The_Three-Cornered_Hat_(novel)) Wikipedia page about this book: es.wikipedia.org/wiki/El_sombrero_de_tres_picos_(novela))