The last time the United States faced a big, hard-to-track threat, we ended up with the Patriot Act and a mass-surveillance program that still rankles. This time, how do we use technology to combat the novel coronavirus without creating elements of a police state?

Technology ought to be our best weapon in maintaining public health as the United States transitions back to work. High-tech testing can identify who had covid-19 (and is more likely to be “safe” now), and who’s most vulnerable to infection as the country opens up. Contact tracing can help minimize second and third bounces of the virus — while we all wait for the vaccine that, hopefully sometime next year, will bring some real relief.

This transition is doable. The tools are in our hands, literally, in the cellphones most Americans carry. The two giants of cellular telephony, Google and Apple, have already created a joint contact tracing technology that would live on our Android and iPhone devices.

Our phones could also coordinate the rapid and robust antibody testing program we need. They could connect us quickly with screeners and testers to arrange fast drive-through testing (bypassing traditional laboratory bureaucracy that is overwhelmed and slow to respond). And soon after we’re tested, we could receive a digital QR-coded certification — like an airplane boarding pass or an electronic ticket to a sports event — that could be used by employers and service providers to help ensure safe workplaces.

But nothing is easy in America these days. The anti-lockdown protesters in states such as Ohio and Michigan who are demanding to reopen the country quickly might be reluctant to provide the very data that might help them go back to work safely. Their privacy worries are widely shared. Americans have a gut belief: Live free or die.

Tech companies want to help, but they aren’t sure how. Even as they create data-monitoring tools, they seem reluctant to allow governments to use the information. As Stewart Baker, a former general counsel at the National Security Agency, noted in Lawfare last week: “Silicon Valley is in love with a ‘trust no one’ approach to security” that makes Apple and Google reluctant to share cellphone data with the public health authorities that need it most.

The challenge, in the coming back-to-work transition, will be creating an environment that restores jobs and also keeps people safe, without crossing privacy red lines. As technologist Marc Andreessen put it in a recent essay, “the problem is inertia.” Rather than continuing the blame game, the country needs to unite around the idea that “it’s time to build.”

Let’s start with the first step back, which is the public health puzzle: How do we fight what President Trump calls the “invisible enemy” without creating a “Patriot Pathogen Act” that grossly compromises civil liberties? How, in short, do we avoid the mistakes of the post-9/11 surveillance state?

What’s needed is a trusted national intermediary that can coordinate public and private efforts better than this administration seems able or willing to do. One good candidate would be the National Academy of Sciences, as proposed by Glenn Gerstell, another former NSA general counsel. The academy could help coordinate public health authorities at the federal, state and local levels. It could connect doctors and hospitals through their national associations in a coherent national testing program. It could act as a fiduciary to collect testing and contract-tracing information.

China shows how surveillance technology can help restart a country, at the cost of freedom. William A. Haseltine, a prominent health researcher, described in an email last month how China has managed the transition from lockdown using a color-coded system that’s part of a WeChat app on everyone’s phone. If your code registers green at the doorways of stores and restaurants, you’re free to enter. Otherwise, forget it.

The United States doesn’t want to be China. But we need a framework that allows us to use technology to recover from economic paralysis. Tracing and tracking using cellphones will not be silver bullets for covid-19, but they will help. Augmenting our currently slow testing regime with immediate-result antibody tests is a vital step. There will be gaps, and statisticians will have to make inferences based on limited data, stresses Sean Roche, a former top technology officer at the CIA who’s advising nonprofit groups and companies on digital technology issues. Certainly, we’ll need rules for how data is collected, how it’s anonymized, when it is used and how long it’s kept. But we need to get started, now.

It’s crazy for the United States to seem so disoriented and powerless this far into the pandemic. The tools are there, if we have the good sense to use them wisely. The real “invisible enemy” is our own breakdown of trust, self-confidence and leadership — all fixable, if we get serious about recovery.