A marriage contract? I have been told the wife can claim that her husband has raped her.
A signed document stating that she is having sex willingly? I have been told she can claim later that she asked the man to stop.
Law Stack Exchange is a question and answer site for legal professionals, students, and others with experience or interest in law. It only takes a minute to sign up.
Sign up to join this communityA marriage contract? I have been told the wife can claim that her husband has raped her.
A signed document stating that she is having sex willingly? I have been told she can claim later that she asked the man to stop.
A woman can always accuse you of rape. In the U.S., at least theoretically, you are presumed innocent until proven guilty, so unless there is actual evidence you raped her, odds are you won't be convicted. If you are wrongly and maliciously accused, you can probably win a defamation suit as well.
There is nothing you can legally do to prevent being accused - only principles which protect the innocent against conviction (e.g., presumption of innocence) and means for being made whole (e.g., civil suits).
You've built quite a few caveats into the hypothetical.
I'm left with two suggestions, which I will offer here aware that this might constitute legal advice. So I make the disclaimer that these are general suggestions and do not apply to a specific situation.
Film the entire sex act. You should keep each video until the statute of limitations has expired. The videos should be time and date stamped and stored in a away that metadata is preserved. The video should be uncut and begin with a clear scene showing both (or all, see below) participants providing verbal consent, both to the act of filming and to the sex act itself.
Have a third party present during the sex act. This person can act as a witness in the event of allegations. If you are concerned about the witness' credibility or willingness to testify, you might consider having a few extra participants. I might ask a notary to fill this role, but I'm not sure they offer that professional service.
Of course, a victim still could allege that he or she was under duress or incapacitated (drugs, alcohol, star-struck, whatever) so you really take on an amount of risk no matter the precautions. If this is a concern you should have the agreement made well in advance of the sex act as this will dispel the likelihood of temporary incapacitation or duress.
You could use one of the sexual consent apps on the market. For instance, We Consent is an app that records both partners of the potential encounter saying "Yes, I consent" (there doesn't seem to be provisions for three- or more-somes); the video is stored "privately" and "securely" in case there is a later dispute.
Note that all approaches to documenting consent have the same flaws: even after clearly documented consent, that consent can be withdrawn at any time. The above app has a provision that lets you document that you withdraw consent, but it would be easy to argue in court that you couldn't get to the app after you changed your mind. So, unless you film the entire encounter (with permission) there is going to have to be some trust involved. And that may not be a bad thing; one could argue that you should never have sex with someone you can't trust.