When (if ever) disclose your identity as a reviewer? The peer review system is in general single blinded: The reviewers will not be known by the authors of a paper by default. One reason for this is to guarantee that the reviewer can write his opinions on the paper without expecting any drawbacks whatsoever. However, I can imagine situations in which the reviewer may think about disclosing his identity:


*

*The reviewer is not d'accord with the editor's decision. This happened to me once - as author: the reviewer wrote some kind of open letter to the the editor and put me and my coauthor in the cc. Basically, the reviewer complained that the editor weighted some other (unqualified) review high enough to not accept the paper.

*The reviewer has ideas for further research based on the paper and thinks that a collaboration would be a very good idea. He could think about contacting the author directly but this would disclose his identity (in the case that the paper is not available as a preprint - which still happens sometimes). However, waiting until the paper would be published would be a waste of time.
Since I experienced 1. myself and I am thinking about 2., I would like to hear anwers to this question:

Under what circumstances (if any) should a reviewer disclose his identity to the authors of a paper?

Edit: A small clarification for point 2.: First, the submitted paper is not publicly available and hence, writing to the author would disclose the reviewers identity.  Moreover, it is not about improving the actual paper (and wishing to become a coauthor) but about further work inspired by the paper.
In view of the current answer, I would also like to expand the current question a little bit (which is not worth a whole new question, I think):

... and what are arguments against disclosing the reviewers identity?

 A: This is more of a response to @Chris. The FLT case is actually useful, in that for many papers of sufficient magnitude, the author will know who the referee is, and even for papers of insufficient magnitude, getting emails saying: hey, I was looking at your preprint, and the proof of lemma x.y.z eludes me is usually a hint. Sending such email through the editor slows down the process by orders of magnitude. The suggestion to be co-author (in my experience) tends to come from the editor, not the referee, and is sufficiently often a bad idea that I think it should never be done (having it come from the authors, as Chris suggests, is a good idea, but has not happened in my experience as author, referee, or editor).
As for the OP's question: 
point 2 seems moot: why should the author care that you are the referee. Just write about your great idea, and suggest a joint paper. The author may object that the paper is already submitted, but then saying that you are the referee sounds like blackmail.
point 1: This sort of action seems totally pointless. Both the referee and the author should just take note, and never submit anything to the journal as long as the bad editor is on the board.
A: For question 2.
According to the instructions given to referees by certain journals ... the submitted material is to be treated as privileged information.  And (one consequence) you cannot use it as a basis for your own further research.  Of course, once the paper is published, or the author otherwise releases it as a preprint, then of course you can use the information.  And in particular you could then contact the author about a collaboration.  (You need not mention that you were a referee.)  
So I reiterate one of the other responses: do not do it without the approval of the editor who sent you the paper for review.
A: Anonymity is the referee's right (or privilege), not an obligation.  I think the referee should be free to disclose his/her identity to the author. 
A: On a somewhat practical -- and frighteningly co-incident -- note, just this morning a reviewer revealed his identity to me on the grounds that his own as-yet unpublished work overlaps my paper that he is currently reviewing. 
As a reviewer, encountering a draft which overlaps your current project would be a bit of a nightmare scenario for a variety of straightforward reasons; I think a frank discussion with the author is mandated in such a situation so that the simultaneous development of common ideas can be properly expressed and clearly cited.
This is one situation where it seems as though the "do it blind" idea is extremely dangerous and counter-productive. You really wouldn't want to end up in a situation where you are accused of stealing ideas from unpublished work (that you were reviewing!) and then rushing your own eerily similar draft to a journal with quicker turnaround time so it gets published first. It is much better to explain the situation to both the author of that work and the editor of the journal so that everything gets sorted out transparently and amicably.
A: This is actually a long comment. Concerning point 2: Here is an amusing example when the referee wanted to collaborate with the author on the paper that he/she was refereeing, and so contributed a two-page appendix to the paper without disclosing their identity:
Real reductive Cayley groups of rank 1 and 2. 
With appendices by Dolgachev and an anonymous referee. 
J. Algebra 436 (2015), 35–60.
(Excuse me for promoting my own work...)
A: I think PaPiro's answer is entirely correct, based on my own experiences as author, referee and editor.
One principle is that the referee is carrying out a task at the request of, and for, the editor. I would say that the the referee's task is to supply information to the editor, who will use this to decide what should be done with the paper. The standard is that the 
referees are anonymous, and if you agree to referee a paper you are accepting this constraint by default.
All correspondence between the referee and author should go through the editor. This provides the referee with protection from the author - I recall one case where an author was very vexed by a positive report, because it was felt that the report was not positive enough. It also provides the author with protection from the referee's requests, which are not always guided by the pure light of reason.
If the referee provides a substantive improvement to the paper, the authors are free to propose via the editor that the referee be added as an author. They are also free to decline.
My own view in this case is that the editor does not have a right to insist that the improvements be added, and that the final
decision should be based on the submitted paper, not on what it might have been. (Dealing with this sort of issue is why editors are so well paid, of course.)
If as referee you are unhappy with the way an editor has handled a paper, you are free to contact other members of the board. 
As for Will Jagy's anecdote about Wiles, I appeal to the adage "extreme cases make bad law".
A: I think there are ethical issues here that other people have not brought up, even after the refereeing job is done.  
By letting the author know about your (very positive?) referee report, they may feel more likely to "repay the favor" in the future.  This seems potentially problematic to me (although in many cases it won't be).  Obviously, if you recommended rejection :-( or gave an isufficiently glowing report, this seems less problematic from an ethical perspective...
That said, I have revealed that I'm the referee of various papers in the past.  Although usually because something came up in conversation and it seemed natural to mention this (ie, "I know what you are talking about, I refereed this paper of yours a while back and had a conversation with you about this topic through the editor").  To me this could still be problematic although perhaps still can be good/ok.  
For example, in one case I revealed I had been the referee of a paper to the author after it had been accepted but before it had been published because I wanted to exhort the author to put the corrected version of the paper on the arXiv (to replace the existing version with some misleading mistakes).  
Finally, in another case I revealed my identity to the author after getting permission from the editor during the referee process.  This was a case where the editors were not looking so much for my opinion of the paper in terms of quality (it was a birthday conference proceedings), but wanted a detailed report on correctness.  I asked the editors if it was ok to contact the author directly to speed up the process.
A: If you are sent a paper to referee that is not publicly available, I believe it is your duty to provide your report and then pretend you have never seen the paper, at least until it appears somewhere public. You shouldn't be thinking about proving any conjectures made in the paper or generalizing its results. You shouldn't be contemplating collaborations to extend the work. The author has chosen not to make his or her results public yet, and has the right to have this privacy maintained throughout the editorial process. So I think contacting the author in situation (2) of the original post is highly inappropriate.
