No, that doesn't work. Stick with the straightforward alternatives below.
John harbors a desire to kill Peter and would do so if he had the opportunity.
or simply
John would kill Peter if he had the opportunity to do so.

Interested in Language
Hi,
Is the following sentence correct?
John harbors a desire to kill Peter if he had the opportunity to do so.
I'd appreciate your help.
No, that doesn't work. Stick with the straightforward alternatives below.
John harbors a desire to kill Peter and would do so if he had the opportunity.
or simply
John would kill Peter if he had the opportunity to do so.
How about "John harbors a desire to kill Peter should he have the opportunity to do so"?
The should-clause is taken to modify the infinitival phrase.
No. You've just substituted "should" for "if". It still doesn't work.
I'm testing a few possibilities. What about the following?
John harbors a desire to kill Peter if he has the opportunity to do so.
John plans to kill Peter if he gets the opportunity.
I am not a teacher.
Raymond, do you see why that's an improvement? (I'd probably go further and say "chance.")
It's usually better to avoid long Latin- and Greek-rooted words when a short Anglo-Saxon word will do.
That's because it's more natural and easier to understand and therefore less annoying.
I'm not a teacher. I speak American English. I've tutored writing at the University of Southern Maine and have done a good deal of copy editing and writing, occasionally for publication.
I am just investigating the possibility of an infinitival phrase being modified by an if-clause, especially a counterfactual one.
Anyway, do you find the following correct, with the if-clause modifying the infinitival phrase?
John harbors a desire to fly to the top of the tree if he grows feathers.
John wants to fly to the top of the tree if he grows feathers.
We know his desire to fly to the top of the tree if he grows feathers.
It is evidently impossible for him to grow feathers, although the non-counterfactual if-clause is used.
I'm not a teacher. I speak American English. I've tutored writing at the University of Southern Maine and have done a good deal of copy editing and writing, occasionally for publication.