There is a federal law that exists that prevents government from infringing on the people's rights to keep and bear arms. It is the 2nd Amendment to the United States Constitution. Based on the (few) details provided, the OP was bearing arms and had his right infringed upon.
OP is not an idiot, ignorant, or stupid. The legislators, judges, and law enforcement officers that have upheld these unconstitutional tyrannical gun laws are. Why should anyone have to read any further into gun laws after starting at the top and reading "SHALL NOT BE INFRINGED." A reasonable person can read that and come to the conclusion that they have the right to keep and bear arms, and not only do they have that right, but the government shall not infringe upon it IAW the SUPREME law of the land.
The Bill Of Rights isn't written in hieroglyphics. It says what it says.
inb4 WELCOME TO THE REAL WORLD
It is what it is. The OP just experienced TYRANNY in the LAND OF THE FREE. He did nothing wrong, illegal, or stupid. The only mistake he made was thinking he lived in a society where elected officials and law enforcement upheld the law.