It was taken from the indigenous people, who likely took it from other indigenous peoples whom they conquered, etc.
The British could have lawfully claimed it as a prize, if it hadn’t sunk.
So, as far as I’m concerned, it belongs to whoever possesses it.
(Of course, everyone will want to get their hands on a part of it.)
If its a sunken warship, it belongs to Spain.