How to ethically publish the result in case we prove that P = NP?
I'll try to answer what I view to be a much easier question to answer, while still (in my view) capturing the &quot;essence&quot; of the problem.

How can one &quot;prove&quot; that they have an efficient algorithm for an NP-complete problem without publishing the algorithm?

There are many things one can do, but the simplest is to solve challenges.
There are a large number of computational challenges which have been posted over the years, for example:

RSA factoring challenges

Lattice Crypto challenges


If one solved a variety of these challenges in extremely high dimension and posted the solutions publicly, it would very quickly erode confidence in the hardness of the underlying problems.
After waiting a suitable amount of time, you could then publicly post your algorithm.
Of course, it is difficult to talk about what a &quot;suitable amount of time&quot; is for public disclosure that would break all of cryptography, which is why I avoided your initial question.