It can be achieved with a zero-knowledge proof - there are many schemes, but in essence, they all allow you to prove something (e.g. your birthdate, validated by a government agency), without revealing who you are. You can prove to a third party "the government authenticated that I was born on 1970-01-01" without exposing who "I" is.
Some worthwhile reading on the topic if you're interested:
ZKP is better, but still not foolproof. Depending on the implementation, the government may now know that you have an account, or at least attempted to open an account on that service. You will have a hard time denying it in the future if the government asks to see your posts (as the US is currently doing at their borders).
I disagree. I can't think of an implementation mistake that would allow just the government to see what services you sign up for.
You could of course screw it up so everybody could see. If the government put a keylogger on your device then they could see. However broadly speaking this is not something that can be screwed up in such a way that just the government would be able to see.
The protocol wouldn't even involve any communication with the government.
"This is experimental software. While it has undergone external review, it has not yet received a formal security audit. Please use with caution and at your own risk in production environments."
The anonymity is that the government doesn't know who is asking for the verification, not that the the government doesn't know whose majority it should attest.
If the API asks for a users minimum age at a certain time, how can the government not know which data set it has to check?