How to acknowledge contributions of anonymous referee in new paper? 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.
From my understanding of the details of the situation, the editor is not acting well in refusing to pass along your invitation to the referee.  Doing so does not violate anonymity in any way (I am confident that the review process was not "double blind" -- i.e., the referee knows the author's identity -- in my experience, no mathematics papers are reviewed in this way.)  Maybe what the editor is thinking is that in order to accept your offer the referee would have to violate anonymity.

However, is this an ethical issue?  I have always held it to be the case that a referee can disclose her identity to an author at any time, and I have done this more than once as a referee.  I can vaguely see some ethical problems which might arise if this process of referee-self-disclosure were very widespread, but it seems like a bit of a stretch.  I would be very interested if someone can explain to me why this is a real concern.

Against the highly nebulous previous paragraph one must balance the ethical issue that academic ideas are not gifts that one person can freely bestow upon another.  I wrote the previous sentence in full awareness of the fact that mathematics in practice does have some degree of noblesse oblige: one often encounters very eminent and senior mathematicians giving ideas away to younger / less experienced / less eminent mathematicians without wanting anything in return: in mathematics we are inculcated to have a view that certain contributions are "below our level" and thus not worth taking credit for.  That is fine if "not taking credit" means not becoming an author on a paper.  But if it means not disclosing your contribution at all -- with the consequence that the begifted junior mathematician gets "too much credit" for work that had a significant component that was not his own -- well, that is hardly a victimless crime in our current highly competitive job-market.  In fact it seems to be a form of plagiarism.

[The situation brings to mind Karl Iagnemma's short story "Zilkowski's Theorem".  This was anthologized in the Best American Short Stories of 2002.  Remarkably, this was only one of two short stories in that anthology in which the main character was a practitioner of the mathematical sciences.  The other is Leonard Michaels's "Nachmann from Los Angeles".  Both were excellent!]

Perhaps you should write back to the editor to express these ethical concerns.  Getting the editor-in-chief of the journal involved (if this is not already the editor you are dealing with) is also a good idea at this point.

If you really don't know the identity of the author, then you need to indicate clearly the circumstances in whatever paper you write.  You may also want to make it known in your circles that you would very much like to know the identity of the mathematician who helped you write your next paper.  Depending upon how small / tightly knit your particular subcommunity is, you may have more or less luck with that, but it's certainly worth a try.