Keira Knightley, Matthew Beard, Matthew Goode, Benedict Cumberbatch, and Allen Leech star in “The Imitation Game.”(Photo by Jack English/The Weinstein Company)

Gay rights movies frequently work as both art and politics by presenting viewers with sympathetic gay and lesbian characters, and then, once we feel attached to these fictional people, tallying up the ways that prejudice injures them personally. But “The Imitation Game,” a handsome new movie about Alan Turing, inventor of modern computing, and the work he did for the British at Bletchley Park to break the German Engima code during World War II, dares to suggest something grander: that the equal participation of gay people and women in public life is a matter of national self-interest.

“The Imitation Game” takes as its center the close friendship between Turing (Benedict Cumberbatch, in a typically sensitive performance) and Joan Clarke (Keira Knightley), Turing’s colleague, confidante and for a brief time, his fianceé. Screenwriter Graham Moore says he was animated by “The way Alan Turing and Joan Clarke were these two people who were each kind of cast out of traditional authority roles in traditional society in certain ways: her, because she was a woman, he because he was a gay man at a time when that was literally illegal, not simply frowned upon. And how these two outsiders were able to find each other and see the world in a way that no one else had, and to accomplish these things that no one thought were possible.”

(Disclosure: Moore and I met at a group dinner in 2013 and have seen each other socially in similar setting two other times since.)

At Bletchley Park, people like Turing and Clark were given opportunities to make full use of their talents on behalf of their country in a way that would not have been possible for them in peacetime. There were slights, of course. Clark had to be commissioned onto the Enigma process as a linguist, rather than as a full code-breaker because of her gender. “That was the only way they could get her the security clearance and get her into the rooms,” Moore explains. Other women were hired as clerks, director Morten Tyldum notes.

And some secrets were more dangerous than others. Part of “The Imitation Game” is taken up in a tense minuet between Turing and John Cairncross, the Bletchley codebreaker turned Soviet spy played by “Downton Abbey” star Allen Leech. As each man’s discovers the other’s secret–Turing’s homosexuality and Cairncross’ treachery–the balance of power shifts dangerously between them. The unnecessary suspicion of Turing’s homosexuality meant that he was not free to report a real security risk without having his own secret exposed, something that surely would have resulted in his removal from the project.

Leech says he was fascinated by “the power that you can have when you have all the information, but also the moral element of what you do with that information. And you have that information when they break the code, how they’re actually going to filter that through into the war effort.”

Some of those same dynamics played out in the post-war years. While in the post-War United States, women who had worked in factories were encouraged to embrace a return to domestic life to free up their jobs for men who were returning from Europe and the Pacific, women and gay men who worked at Bletchley faced a different dilemma. The code of secrecy that had guided their intelligence work bound them long after they ended their war-time service. Leech says he heard a story of a couple who only learned they had both worked at Bletchley decades into their marriage, while Moore recalls a meeting with a woman who wasn’t even aware until recently that she had helped break Enigma.

The consequences of this code of silence were more than personal. In order for women and gay men who served at Bletchley to use their service there as an argument that they ought to have equal opportunities and equal rights, they would have to have to breach the secrecy that governed their conduct there. The very act of speaking up on their own behalf would render them untrustworthy, a contradiction also captured by the excellent television drama “The Bletchley Circle.

During the war, this delicate balance might have been sustainable. In a sense, Moore suggests, Britain’s own climate of sexual repression created a man who was perfectly suited to the Enigma project, which required the Allies not only to break Germany’s highest-level codes, but then not to act on that information in a way that might indicate to the Germans that their communications were no longer secure. Just as Turing could not act on his self-knowledge, the Allies had to continue to let the Axis kill huge numbers of soldiers and civilians so they could continue to make any use of the Enigma-encrypted messages at all.

“You’ve got this man who’s not qualified to sort of be this high-level spy in any way, but that he’s been keeping secrets every single day of his life,” Moore reflects. “He’s been imitating someone else every day and now he has to help the whole military apparatus imitate, in some way, something it’s not.”

But Enigma need not have been the end of Turing’s contributions to Britain and to the world. Moore says he was moved by “The idea of institutionally, what we lost due to the systemic persecution of gay men in the middle part of the century, to think of what Alan Turing could have accomplished if he hadn’t died so young.”

The idea that Alan Turing’s sexuality was so dangerous that he had to be chemically castrated didn’t just result in his eventual suicide. It was a tragedy for England. Gay rights, “The Imitation Game” suggests, aren’t just a matter of sympathy for others. Sixty years after Alan Turing’s suicide, it’s finally time to recognize full equality as a matter of our collective self-interest.