What to do when I can prove a conjecture of a paper I'm peer reviewing
I was once in a very similar situation, proving a conjecture from a paper that I was refereeing. (But, unlike you, I hadn't worked on it before, and I didn't have a coauthor.) I essentially left the situation up to the editor. I sent her my proof along with my report on the paper. With my permission, she shared this information with the authors. It turned out that, in the meantime, someone else had also proved the conjecture, by a quite different method. He and I ended up publishing a joint paper that combined and extended both of our methods.
One warning, based on this experience: Don't get so excited about this that you overlook an error elsewhere in the paper you're refereeing.
Honestly, I do not see a problem here. My advice is to focus on your duties as a referee, i.e. check if the manuscript deals with the hypotheses appropriately, if the methods are suited for their purpose etc. If the authors properly build upon the currently publicly available knowledge, you have no reason to critisize this aspect of the paper. As you describe it, the authors obtained a correct result and used it in their reasoning. They may have used another method than you, but that is totally okay. So primarily judge the manuscript in itself without thinking too much about your own, unpublished work. This way, you also reduce the conflict of interest issue.
Conflicts of interest to some degree are inherent to the peer review process. You have to be an expert in the field to assess the work, so it is not unlikely that you have some own more or less related work. This in itself is nothing to worry about. If you feel unsure whether in your case the overlap is too big and you cannot guarantee that you assess the manuscript on a neutral basis, explain to the editor and let her/him decide.
About contacting the authors (via the editor!) and a possible cooperation: Ask yourself what you want. In my opinion, you are not obliged to do anything into this direction (although you could, as pointed out in the other answers). As a referee, you should remain as neutral in the process as sensible. Just imagine what would be the situation if somebody else had got the manuscript for review. You would then build upon the work in question in your own future paper, like you obviously should. That you got the manuscript for review should not necessarily make any difference.
In the best of all possible scientific worlds I think the proper outcome might be a joint paper. That would make it easier for people to find out the latest news on the topic in a single place.
Whether that's appropriate or possible in this instance requires much more information about the technical details and the people involved than you can provide here.
I agree with the consensus from other comments and answers that you begin figuring out what to do by contacting the editor.