”There was this culture in London, and it really came from New York,” he said. “These guys were either from New York or trained in London at New York banks, and they looked at Europe as their playground. People at the highest levels were collaborating to rip off countries.”

Seemingly risk-free profits poured in, and over the years a mini-industry thrived, one that a former participant labeled “the devil’s machine.”

Exactly how that machine operated is a central question in the first cum-ex prosecution, which began in September in Bonn, Germany. In a trial expected to last until February, German prosecutors intend to make an example of Mr. Shields, 41, and a former colleague. (Mr. Mora, 52, was indicted in December and will be tried separately in the coming months.) The men in the Bonn case have been charged with “aggravated tax evasion” that cost the German treasury close to $500 million.

Last month, the presiding judge issued a preliminary ruling that, for the first time, declared cum-ex a felony, calling it a “collective grab in the treasury.” Punishment has yet to be determined, but the give-it-back and the go-to-prison phases of this calamity are about to begin.

German prosecutors say they will now pursue 400 other suspects, unearthed in 56 investigations. Banks large and small will be ordered to hand over cum-ex profits, which could have serious consequences for some. Two have already gone bust.

Dozens of law firms and lawyers may face penalties, too, having drafted highly priced opinions contending there was no law explicitly prohibiting cum-ex and thus it was perfectly legal. That is an argument that many involved might offer in the coming years of litigation. They may insist that if Germany didn’t make the trade impossible, they did not break a law. A desk-thumping variation of that defense is already being offered by Hanno Berger, once the most formidable tax auditor in Germany, who later switched sides and became a cum-ex mastermind as well as an ally of Mr. Shields and Mr. Mora.

But officials in Germany say the trade was a form of theft, one so obviously illicit that forbidding it — which was tried twice, with ineffectively worded laws — was hardly necessary. In September, the justice minister of the state of North-Rhine Westphalia, Peter Biesenbach, went so far as to liken cum-ex players to mobsters.