I'm in mathematics, just in case that matters.
I submitted a manuscript to a journal, and got an extensive referee report from referee X. After sending the revision, the paper got rejected, so I sent it to a second journal where it got accepted.
Later, I got a note from the editor of the first journal saying that referee X found a way to improve my results, and the editor gave me a pdf file from referee X outlining his/her ideas. Unfortunately, since my manuscript had already been accepted for publication I could not change it at this point.
Nevertheless, the improvement that referee X suggested is significant enough to merit another paper. I asked the editor to pass on an invitation to referee X to work on a joint paper with me, but the editor refused, saying that he didn't want to violate referee anonymity.
I think the paper needs to be written, but I feel it would be strange for me to write a single-author paper when the most significant idea does not originate with me. (Referee X only gave me a vague sketch of the idea, there are things that still have to be worked out. I still have to do a lot of work, but the most important insight would be referee X's). I suppose I'm just going to write a few paragraphs in the introduction explaining the situation. I was wondering if there would be another way to handle the issue.