As President Barack Obama was running for re-election in 2012, Donald Trump called him a “terrible student” and demanded that he release his academic records to the public. But when Trump launched his own presidential bid a few years later, his longtime personal attorney Michael Cohen sent letters to his alma maters, threatening to take legal action if any of Trump’s own academic records were ever made public.

That revelation was part of Cohen’s testimony to Congress on Wednesday, in which he also called Trump “a racist,” “a con man,” and “a cheat.”

“When I say con man, I’m talking about a man who declares himself brilliant but directed me to threaten his high school, his colleges, and the College Board to never release his grades or SAT scores,” Cohen said Wednesday. “The irony wasn’t lost on me at the time that Mr. Trump in 2011 had strongly criticized President Obama for not releasing his grades.”

Though it was not as frequent as his repeated questions about Obama’s birth certificate, Trump’s questions about Obama’s college transcripts were a long-running obsession of his before he formally entered politics.

In a 2011 interview with the Associated Press, Trump called Obama a “terrible student” and questioned how he had been admitted to Columbia University and Harvard Law School. “I’m certainly looking into it. Let him show his records,” Trump said.

In October 2012, Trump offered to make a $5 million charitable donation if Obama released his college applications and transcripts, deriding him as the “least transparent president in the history of this country.”

Student records are protected by the 1974 Family Educational Rights and Privacy Act, and Obama did not elect to release his college transcripts and applications. But he did graduate magna cum laude from Harvard Law School, where he was the first black president of the Harvard Law Review.

At the same time, Trump was protective of his own grades once he became a candidate.

Cohen testified Wednesday that Trump had directed him to threaten his own high school, colleges and the College Board against ever releasing his academic grades or SAT scores. Cohen submitted a copy of one of those letters to Congress.

“If in the event any of his records are released or otherwise disclosed without his prior written consent, we will hold your institution liable to the fullest extent of the law including damages and criminality,” Cohen wrote in the letter, addressed to Fordham University on behalf of Trump in May 2015, requesting confirmation that the “records have been permanently sealed.”

In a statement, a spokesperson for Fordham confirmed that the university had received a phone call from a Trump campaign staffer and then a letter from one of Trump’s attorneys.

“We told the caller that Fordham is bound by federal law, and that we could not/would not reveal/share any records (as we would not reveal any student records) with anyone except Mr. Trump himself, or any recipient he designated, in writing,” Fordham spokesperson Bob Howe said in a statement. “Our stance remains the same: we obey federal law and don’t release student records to anyone but the student/graduate or anyone that the student designates, in writing.”

Trump attended Fordham for two years and then transferred to the Wharton School at the University of Pennsylvania, graduating in 1968 with a bachelor’s degree and no apparent honors, according to the 1968 commencement program.

Trump’s desire to conceal his academic records runs counter to his habit of boasting about his intelligence and success as a student.

“I went to the Wharton School of Business. I’m, like, a really smart person,” he said in a July 2015 speech.

“I went to an Ivy League school. I’m very highly educated. I know words, I have the best words,” he said in December that year.

“You know, people don’t understand. I went to an Ivy League college. I was a nice student,” Trump said in 2017. “I did very well. I’m a very intelligent person.”

Write to Katie Reilly at Katie.Reilly@time.com.