Ted Griffin (upper left) appears in a cameo role in "The Wolf of Wall Street." Sources say Griffin made major contributions to the movie's script.Paramount Pictures

Martin Scorsese and Leonardo DiCaprio added a secret wolf to their pack to make “The Wolf of Wall Street.” Hollywood is buzzing that key elements of the film, opening Wednesday, were actually written by Ted Griffin, Scorsese’s close friend and scribe of “Ocean’s Eleven” and “Tower Heist.”

The film’s screenplay, based on the 2007 tell-all by disgraced money manager Jordan Belfort, is credited to “Boardwalk Empire” creator Terence Winter. But “word in Hollywood is that Ted did a lot of the writing that ended up on-screen,” said one top producer. The source added that Griffin got involved with the script from pre-production onward and contributions included adding “crackling dialogue” to the high-flying drama, to “working through the editing crunch on voice-overs with Leo and Marty to make [the film’s] release date.” Page Six previously reported that Scorsese holed up in his home to finish editing the film on time.

Griffin didn’t push for writing credit, however. “He did it as a favor to Scorsese and was rewarded with acting scenes,” said a source. Griffin is listed as a co-producer and makes an uncredited cameo. The film’s been tipped as a Best Adapted Screenplay Oscar nominee, with “12 Years a Slave,” “Philomena and “Captain Phillips.”

In an interview earlier this year, Griffin said of Scorsese, “He’s really brilliant . . . the most fantastic man I’ve ever met.” He cracked, “I like to think I’m the son he never had.” The two met working on a 2010 doc on Fran Lebowitz.

Winter, who wrote for “The Sopranos,” told us at a reception for the film, “I felt it very important to let Jordan tell the story in his own words . . . we wanted to do the most honest version of the story we could, so we were gonna take that book and go right down the middle as honest as possible. It was the most fun I’ve ever had as a writer.”

Reps for Paramount as well as Scorsese, Griffin and Winter did not return requests for comment.