At the end of this process, however unpleasant it may be, you will still have your self-identity, those friends who are true friends, and the knowledge that you did not betray yourself or your wife.

It's squarely within your control as to whether you will still have your dignity. As Gandhi said (paraphrasing here): nobody can take that away unless you let them.

On the other hand, your wife will be left with nothing but her anger, her hate, and her betrayal. Whatever she gets in the divorce, you will get the most important part of the marital estate: the right to spend the rest of your life free from the person who could do such an awful thing.

Erica