He noted, however, that campaign finance laws — which are complex — require proof that a person was willfully violating them. Mr. Cohen’s testimony does not prove that Mr. Trump knew that the payments he was making were illegal — something that prosecutors would have to prove if they wanted to charge the president.

WikiLeaks and Emails

In his testimony, Mr. Cohen described a moment when he said Roger J. Stone Jr., one of Mr. Trump’s top political operatives, called the president to tell him about a conversation with Julian Assange, the WikiLeaks founder.

“I was in Mr. Trump’s office when his secretary announced that Roger Stone was on the phone. Mr. Trump put Mr. Stone on the speakerphone,” Mr. Cohen said. “Mr. Stone told Mr. Trump that he had just gotten off the phone with Julian Assange and that Mr. Assange told Mr. Stone that, within a couple of days, there would be a massive dump of emails that would damage Hillary Clinton’s campaign.”

Mr. Cohen added: “Mr. Trump responded by stating to the effect of ‘wouldn’t that be great.’”

Legal experts cautioned that just proving that Mr. Trump knew about the WikiLeaks plans to leak damaging documents ahead of time would not necessarily prove that the president or his campaign were guilty of conspiracy. Prosecutors would have to prove that Mr. Trump and the campaign actively engaged in coordinating with Russians to distribute the documents or took other actions to affect the outcome of the election.

The question of contacts between WikiLeaks and the Trump campaign is central to the issue of whether there was any conspiracy between the campaign and Russia. It is not known what Mr. Trump might have told Mr. Mueller’s team about what, if anything, he knew about WikiLeaks’ plans or about contacts between Mr. Stone and Mr. Assange.

Peter Zeidenberg, a former federal prosecutor, said that if Mr. Cohen is telling the truth, and if Mr. Trump claimed to Mr. Mueller in his sworn, written testimony that he was not aware of any contacts between Mr. Stone and Mr. Assange, that could be a crime.