No, converting high-energy photons into particles with mass in space would not violate the conservation of energy. The scenario you described involves the concept of pair production, where a high-energy photon interacts with a background field (such as an electromagnetic field) and spontaneously transforms into a particle-antiparticle pair, such as an electron and a positron.
In this process, the energy of the high-energy photon is conserved. The energy of the photon is converted into the rest mass energy of the created particle-antiparticle pair, as described by Einstein's famous equation E = mc², where E is energy, m is mass, and c is the speed of light.
The conservation of energy is a fundamental principle in physics, and it holds true even in the presence of gravitational fields. When the newly created massive particles gain gravitational potential energy, it is not "from nowhere." The gravitational potential energy arises due to the interaction of these particles with the gravitational field present in the region of space.
In other words, the gravitational potential energy gained by the massive particles is a result of the gravitational field acting on them, and it is consistent with the conservation of energy. The total energy, including both rest mass energy and gravitational potential energy, is conserved throughout the process.