Although this would be difficult, it ought to be possible. The template for how to do this could be the pornography industry. In the United States, "mainstream" pornography is legal. However, it is not legal to use anyone who is under 18 years old in a pornographic film or pictures. There are strict requirements that force pornographers to keep records documenting the ages of those who work for them.
Decriminalizing adult prostitution could actually help to make the banning of child prostitution possible. If prostitution were legalized and regulated, it would be easier to monitor who is working as a prostitute so that child prostitutes could be weeded out and those who employed them could be punished harshly. This would be easier than the current system in which all prostitution is supposedly illegal but there is not much enforcement of laws.