Let us leave aside the problem with selective application of "international law" for one moment, just to entertain your thoughts further.
Here is a summary (mine, not AI) what International Maritime Law actually permits in this situation:
Within 12 nautical miles perpendicular to a national coastline, nations can apply the limitation of "innocent passage" upon transiting vessels (NOT "freedom of navigation", which exists beyond that distance).
"Innocent passage" allows a nation to impart reasonable security measures upon transiting vessels, including boarding, blocking, and being recompensed for said security. Iran is actually within its maritime rights to exert conditions of transit withing 12 nautical miles perpendicular to its coastline.
Indeed, it is USA that has clearly and unequivocally engaged in piracy here.