I'd preface this by saying the idea is bad and the legislators passing such laws should be voted out.
That said, looking at it from purely a technology point of view, it's going to be difficult to implement in a secure and privacy preserving fashion. At minimum, there needs to be some sort of third party trust site where an adult site operator can validate age requests. In order to preserve privacy, this will need to operate via hashes and challenges which prevent either the adult website operator or the trust provider from marrying up user and usage data.
To spitball it:
- All internet users are required to register with third party trust site (Trust Site).
1a. Because any sort of profit motive would make this site untrustworthy, this probably has to be a government run site.
1b. By law, the site would be forbidden from collecting or retaining logs or metadata of requests.
1c. By law the site would be exempt from all wiretap requests including by law enforcement and security agencies. Violations would need to be pursued and punished very harshly. Which is one reason this whole thing is a Bad Idea™. Enforcement would never happen. - When a user visits any website (not just adult websites), the site sends a random nonce to the browser.
2a. The nonce would be tied to the session via a session cookie.
2b. The nonce is purely random with no site identifying information. - The user's web browser communicates this nonce to the Trust Site along with the user's credentials.
3a. Nothing else is ever transmitted to the Trust Site. Just the nonce and credentials. - The Trust Server validates the credentials, appends a single bit to the nonce (Response).
4a. A 1 means "is adult" a 0 means "is not adult" (Adult Bit) - The Trust Server digitally signs the Response with its private key.
5a. The Trust Site's public key is publicly available and expected to be cached by all websites. - The Trust Server sends the Response back to the user's browser.
- The user's browser sends the Response back to the website.
- The website validates the digital signature on the Response.
- The website provides/denies content based on the Adult Bit in the Response.
As I said, this is just a spitball and probably has holes/problems. But, it is an attempt to look at the issue constructively.