Prison inmates are pretty unpopular people. And transgendered men and women are only slightly less so. The two groups have found an extremely unsympathetic champion for their rights in Kosilek.

In 1990, Kosilek, transitioning to living as a woman, strangled her wife Cheryl McCaul with some wire, put her body in the trunk of a car, and left it in the parking lot at a North Attleborough mall. In 1992, Kosilek was sentenced to life without parole.

According to Wolf’s ruling, Kosilek has suffered from gender identity disorder since she was a small child: Certain she was born in the wrong body, she has wanted to be a woman for as long as she can remember. In prison, she began taking female hormones and asked for treatment for her disorder, which she was denied. She tried to kill herself twice, and attempted to castrate herself.

The murder was heinous, and Kosilek has no right to sympathy. But the Constitution says she does have a right to treatment for her illness. That’s what her attorneys began arguing 12 years ago, filing suit to require the Department of Correction to provide sexual reassignment surgery.

There are two reasons people balk at this. First, a lot of people think violent inmates don’t deserve good medical treatment. If I were McCaul’s sister, I might welcome news of Kosilek’s suffering. I’d want her to hurt as much as possible. I’d be outraged that a murderer could get care that many law-abiding people can’t.

But we don’t do justice according to the wishes of the angriest and most wounded among us. The system turns on punishment, not revenge — on the denial of liberty, not of all other rights. We are supposed to adhere to higher standards of humanity than those of the people we imprison for violent crimes. That’s what gives us the credibility to sit in judgment in the first place.

The Eighth Amendment, which prohibits cruel and unusual punishment, is central to those standards. Withholding medical treatment violates that prohibition. And the law is clear that prisons must treat not just symptoms, but the underlying illness — not just Kosilek’s depression, but the disorder that causes it.

Which brings us to the second reason Wolf’s decision has been criticized: Kosilek’s disorder isn’t yet widely seen as a legitimate illness. Though gays and lesbians have come a long way toward acceptance (witness the Democrats touting their gay-rights bona fides at this week’s convention), transgendered men and women are still widely seen as freaks.

The medical community accepts gender identity disorder as a major mental illness and has standard practices for treating it, including surgery. But ordinary people see sex-change operations as unnecessary, even frivolous. Massachusetts corrections chiefs, and the governors they serve, have rightly concluded that if they provided it, they would be destroyed by public opinion (and presidential primary opponents).

So, for years, those officials ignored their own doctors, who said Kosilek is in danger of killing herself if she does not get gender reassignment surgery. They even fired a couple of those experts, and sought others they knew had a longstanding opposition to sex-change surgery for inmates. In his decision, Wolf called that “a pattern of prevarication, denial, delay, and interference.”

“It is not permissible for prison officials to [deny treatment] just because the fact that a gender identity disorder is a major mental illness is not understood by much of the public and the required treatment for it is unpopular,” Wolf wrote.

We may not be overjoyed that a person like Kosilek benefits from the Constitution’s protections. But if we abridge her right to medical treatment, what’s to stop us denying it to other inmates? And what happens to our principles then?