A federal investigation into a child porn site in the dark corners of the Internet has led to the arrests of two Homeland Security employees in the San Antonio area.

The secretive, ongoing probe was revealed at a hearing Friday for federal agent Richard Nikolai Gratkowski, 39, who works for U.S. Immigration and Customs Enforcement’s Homeland Security Investigations and was arrested earlier this month.

RELATED: BCSO: Veteran detention deputy arrested

At the same hearing, FBI agent Larry Baker testified that the arrest of Border Patrol agent Paul Casey Whipple of Hondo in mid-December arose out of the same investigation into the child porn website on The Onion Router, or TOR network, which uses thousands of relays or servers, much like layers of an onion, to keep users anonymous.

The network originally was used for dissidents to communicate privately in oppressive regimes, but criminals have turned to it to peddle drugs, black-market guns and other contraband and to trade child pornography. Because of the prevalence of crime, law enforcement has followed and unmasked many users.

Photo: ANDREW CABALLERO-REYNOLDS/AFP/Getty Images Photo: Mysa Photo: Hays County Sheriff's Office Photo: Courtesy/Hays County Jail Records

Whipple, 34, is charged with producing child porn and distributing it. He was denied release on bond last month, but officials did not publicly disclose at the time that Whipple was connected to the child-porn investigation. The Border Patrol, an agency within Homeland Security, did not respond Friday to the San Antonio Express-News’ questions submitted by email and left on voicemail about Whipple’s work situation.

RELATED: Two men killed when rear-ended by 18-wheeler ID'd

Similarly, Homeland Security did not respond to questions about Gratkowski’s tenure with the feds, his work status and the types of investigations he was assigned.

“All Department of Homeland Security employees are held to the highest standards of behavior and ethics,” the agency said in a statement responding to questions about Gratkowski. “While ICE does not comment on personnel matters, the agency is fully cooperating with the FBI and the Department of Homeland Security’s Office of Inspector General (OIG) regarding this issue.”

FBI agent Baker testified that Gratkowski has been with Homeland Security since 2008, focused on gang investigations, and is now on paid leave as his employer is moving to fire him.

Gratkowski was arrested Jan. 4 on a charge of receiving child porn after his case was referred to the FBI by his own agency’s internal affairs branch and the Internal Revenue Service’s criminal investigators, Baker testified.

According to Baker, the website in question provides access to more than 117,000 graphic child porn videos, and Gratkowski and Whipple were identified as two users.

In Gratkowski’s case, he used his USAA bank account — and his government ID — to buy bitcoin, a cryptocurrency, and open an account on the child porn website in April 2016, Baker said. Then, Gratkowski established a second account on the child porn site that gave him access through much of 2017. Baker said Gratkowski also visited two other child porn websites on the TOR network and used a social media app called Kik to get to another child porn site.

The FBI served a search warrant at Gratkowski’s home in early January and recovered two non-working iPhones and a computer hard drive, but did not find any child porn images in them, Baker said. But the FBI did find — in one of two working iPhones recovered from Gratkowski — evidence of links that lead to child pornography, and he admitted visiting the child porn sites when he was interviewed, Baker said.

“He said that in April 2016, he turned to child porn and turned to the site and two other (child porn) sites on the TOR network,” Baker said. “He advised he’d been in a dark place as a result of problems with his wife, work stressors and financial stressors. …He went to the dark net to avoid detection.”

Baker testified that before the raid, Gratkowski used an anti-forensics program to wipe child porn images from his computers. Gratkowski also told agents that he destroyed the computer he used to download child pornography in mid-December and threw it in a Dumpster outside the apartment he shared with his girlfriend.

Gratkowski has been separated from his wife, who “advised him there might be a chance of reconciliation,” and the destruction of the computer was “symbolic” of a fresh start, Baker testified that Gratkowski said. The computer was not recovered.

Gratkowski, who served in the Army, was awarded a Bronze Star and was honorably discharged and has been diagnosed with PTSD, according to testimony from his father, who lives in Washington state. Other testimony and public records revealed Gratkowski is married and the couple has young children, but he is separated from his wife, and he’s been dating a fitness model.

Gratkowski’s lawyer, assistant federal public defender Marina Thais Douenat, tried to convince U.S. Magistrate Judge Elizabeth Chestney to release Gratkowski on bond with restrictions. Doeunat argued vehemently that the FBI has no proof that what Gratkowsi allegedly downloaded was in fact child porn because no images were recovered. Douenat further argued adult women can be made to look like young teen girls.

But Chestney was not convinced. She ordered Gratkowski to continue to be jailed without bond.

“The website described was designed for child pornography,” Chestney said. “There’s not any other reason to go to that website. …You can’t get there accidentally.”

If convicted, Gratkowski faces five to 20 years in federal prison. Whipple faces 15 to 30 years in prison.

Guillermo Contreras is a San Antonio Express-News staff writer. Read more of his stories here. | gcontreras@express-news.net | @gmaninfedland