Libertarian senator and presidential candidate Rand Paul on Thursday praised Edward Snowden for exposing far-reaching government surveillance programs and floated the idea of a short prison sentence if the man he called “a whistleblower” agreed to return home.

“People are always saying, ‘Hero or villain?'” Paul said in an onstage interview at Yahoo‘s Digital Democracy event in Des Moines, Iowa. “He is a whistleblower, and he did inform us of something the government’s doing that was illegal.”

Paul, the Kentucky Republican who has built a Senate career around his civil-liberties protests and filibusters, acknowledged that “there are secrets that a government does have to have,” but he maintained that Snowden “did do a service” by giving journalists documents revealing the scope of the National Security Agency’s domestic and overseas operations.

“He is a whistleblower, and he did inform us of something the government’s doing that was illegal.”

Paul, who is struggling in the polls, turned his fierce criticism of NSA surveillance into one of his best campaign moments when he argued with New Jersey Gov. Chris Christie at the first Republican debate. Christie, a former federal prosecutor in the Bush administration, defended the NSA and suggested that Paul was “just blowing hot air.” Paul responded by telling Christie, “You fundamentally misunderstand the Bill of Rights.” The exchange was the most-tweeted part of the debate.

“People think it’s an either/or,” Paul said at the Yahoo event. “You have to let us look at all your records or you won’t be safe. I think it’s actually the opposite. … Is looking at all our records making us safer?”

Paul pointed to the April 2013 Boston Marathon bombing as an example of U.S. surveillance failures. The Russian government had previously warned the Obama administration about the two Kyrgyzstan-born brothers who carried out the attack, and Paul said that U.S. authorities should have immediately sought warrants to monitor them. What happened instead, he said, was mass surveillance of the Boston area after the fact—a situation that he compared to “[trying] to just scoop up everything, and [making] the haystack so big that you can’t find the needle.”

Asked if Snowden deserved to go to prison for breaking the law, Paul suggested that, if he became president, he would seek a compromise with the fugitive leaker. He noted that James Clapper, the director of national intelligence, had lied to Congress when asked if the NSA spied on Americans, and he suggested “some equivalency between a perjury charge [for Clapper], which is sort of like a five-year sentence, and [charges for] revealing secrets.”

Paul has joked in the past that Snowden and Clapper should share a cell so that each can teach the other about their values and priorities. (Clapper never apologized to Congress for lying, saying that he “responded in what I thought was the most truthful, or least untruthful, manner.”)

Snowden’s case, Paul told the Digital Democracy audience, is very different from the cases of malicious hackers whose goal is to undermine U.S. national security. “He wanted to do it to show that we were lying and we were in breach of the Fourth Amendment,” Paul said. “It’s different than someone selling secrets to the enemy.”

“We are lucky that we learned what they were doing,” he added.

At the Yahoo event, Paul also discussed technology topics like data breaches and the on-demand economy. He praised the private sector for offering bounties to hackers who identified vulnerabilities in commercial code, suggesting that this strategy proved that industry was better than government at securing systems.

“Hackers have these incredible minds,” he said. “Some of them are devious, some of them are just tricksters, and some of them … end up being people who are very successful, who businesses will want to pay to show vulnerabilities. We should try to channel some of this energy and intelligence into something that’s … productive.”

Paul, who has tried to play up his political views in libertarian Silicon Valley, dismissed criticisms of startups like Uber and Airbnb. He compared the cabbies and rental agencies that have savaged these companies to the 19th-century luddites who, angry at the automation of the Industrial Revolution, sabotaged mechanical looms rather than accept their own obsolescence.

“We should never be in the camp of opposing technology or development,” said Paul, citing the benefits that changes like the division of labor brought to a newly industrializing nation.

But Paul wouldn’t say whether or not he supported government action to help retrain workers whose jobs will disappear as technology marches forward. “The way to make transitions easier,” he said, is to “encourage an economy that is robust and innovative.”

Photo via Gage Skidmore/Flickr (CC BY SA 2.0) | Remix by Jason Reed