If your employer produced digital evidence which showed that you have been embezzling substantial sums of money from them, how would you prove you didn’t do it? In principle, the burden of proof lies on the prosecutor. In principle, you don’t have to prove your innocence. But confronted with an apparently unassailable printout detailing all the money the computer says is missing, what exactly is your defence lawyer going to say?

A simple denial isn’t going to cut it. You might try to show you haven’t been living high on the hog, haven’t been living a life of luxury holidays and private jets. Short of tearing the source code apart, you look guilty as hell.

This was the predicament which confronted over 730 Post Office sub-postmasters and mistresses across the UK between 2000 and 2013. Designed by Fujitsu, the Horizon system was intended to fully digitise Post Office transactions, recording all the money coming in going out of a branch. Intended as a modernising and anti-fraud measure, Horizon would instead generate a fraud on the criminal justice system of unprecedented scale.

Horizon didn’t work. After the new accounting system was rolled out in 2000, sub-postmasters across the country began to report problems and glitches in its operation. The money in-store and the money recorded in-system didn’t balance. We aren’t talking about pennies and pounds here: Horizon reported that tens of thousands were going astray.

Until 2014, the Post Office maintained that “there is absolutely no evidence of any systemic issues with the computer system which is used by over 78,000 people across our 11,500 branches and which successfully processes over six million transactions every day.”

As subsequent litigation has now established, this was a lie. There was rampant evidence of “bugs, errors and defects” in the Horizon software. This might have been just another story of incompetent public procurement – if the Post Office hadn’t treated the Horizon evidence as gospel and used it to pursue hundreds of its own postmasters through the courts for these phantom shortfalls.

First, demands would be made for the money. Sub-postmasters were contractually obliged to make good any shortfall out of their own pockets. If they refused to pay, their branch would be shuttered the next day. But even if postmasters made good the Horizon shortfalls, further audits often followed, identifying further and larger sums of missing money. Some were dismissed. Others were prosecuted for theft, fraud and false accounting. Faced with apparently incontrovertible financial evidence, many postmasters pled guilty. Some served substantial jail time.

How widespread were Horizon prosecutions in Scotland? Until this week, it has been impossible to say for sure. When Sir Wyn Williams visited Glasgow in the spring of this year to hold hearings on the human impact of the Post Office scandal on Scottish sub-postmasters and mistresses, it was striking that nobody who testified had faced prosecution.

Their lives and fortunes had been wrecked. Because of the Post Office’s false allegations of financial impropriety, many had built up substantial personal debt to cover shortfalls. Others spoke of losing pensions they had worked towards for decades. Every one lost their reputations in the communities they once served. But curiously, not a single postmaster who gave evidence had been pursued through the courts by the Scottish authorities.

This is a critical difference in the anatomy of the Post Office scandal north and south of the border. In England and Wales, the Post Office acted as alleged victim, investigator, plea bargainer and prosecutor in its Horizon cases. It was the Post Office which sent threatening correspondence to its suspected postmasters. It was the Post Office which gingered up the indictments, accusing sub postmasters of theft while holding out the promise that if they were prepared to plead guilty to the lesser charge of false accounting, then deals could be cut. It was the Post Office who muscled its former employees into coughing up their life savings to cover the shortfalls, and it was Post Office which insisted that postmasters pleading guilty shouldn’t mention any faults with Horizon in pleas in mitigation made on their behalf. It was a devil’s deal, but you can understand why so many postmasters took the terms. What else were they supposed to do?

In Scotland, by contrast, the Crown Office and Procurator Fiscal Service has a functional monopoly over public prosecutions. The Post Office is just a specialist reporting agency. Like HMRC, they can refer suspected criminality directly to the procurator fiscal without police involvement, but the ultimate decision on whether or not to prosecute the suspect, and what to prosecute them for, lies with independent public prosecutors.

Which poses an obvious question: how many people in Scotland did the Crown prosecute using Horizon evidence? 75 convictions have been quashed in England and Wales so far, but the scale of the Scottish problem remained fundamentally unclear.

This week, matters became a little clearer. On Tuesday, the Scottish Criminal Cases Review Commission referred six cases back to the Appeal Court. They have concluded that the convictions of Aleid Kloosterhuis, William Quarm, Susan Sinclair, Colin Smith, Judith Smith and Rab Thomson may have constituted miscarriages of justice.

In each case, the SCCRC has concluded that “Horizon evidence was essential to the proof of the accounting shortfall that led to the charges being brought against them and that their prosecutions were oppressive because the process was an affront to justice.” They also confirmed that five more cases are still under review.

The SCCRC can’t publish its detailed reasons for referring convictions back to the Court, but the information they have shared this week gives some insight into where these prosecutions were raised and the kind of penalties these men and women faced having been accused of cooking the books. Of the six Scottish postmasters and mistresses, only Susan Sinclair pled “not guilty” at trial. The rest took a plea, in the hopes of avoiding prison. Of the six, four received community sentences, while Judith Smith was admonished. Aleid Kloosterhuis was jailed for 12 months.

Campbeltown, Lochmaddy, Peterhead, Dunfermline, Selkirk, Alloa – reading the list of Sheriff courts where these accusations were prosecuted, it is striking that these allegations surfaced in rural and small-town Scotland. One of the saddest dimensions of the scandal is how it robbed innocent people of their reputations, convincing former friends and neighbours that people were on the take. Having grown up in one, it is easy to understand how much tougher this must have been in small communities, where everybody knows your name and anonymity is in short supply.

Digging through the fossil record – it is striking that only one of these prosecutions was reported in the wider media at the time – and it concerned the only postmistress on the SCCRC list to receive a prison sentence. In December 2012, the Daily Mail reported on the prosecution of Aleid Kloosterhuis. She was 54 when she pled guilty to stealing £20,000 from her Post Office branch on Gigha. Originally from the Netherlands, Kloosterhuis moved to the island off the west coast of Kintyre with her husband and children. “She was welcomed into the community – but islanders were horrified to discover that she had been gradually embezzling the profits,” the paper recorded.

The discovery was attributed to “a surprise visit from Post Office auditors,” but it almost certainly wasn’t a careful reading of the books which drew Kloosterhuis into the net of suspicion – but the Post Office’s Horizon system. They expected to find £27,868 in cash and stock “but there was hardly any money in the safe.”

In sentencing Kloosterhuis, Sheriff Ruth Anderson highlighted the apparent abuse of trust as an aggravating factor. “When you carried out the embezzlement, you were in a position of trust as a sub-postmistress of an island community.” In grim echo of the destabilising effect these convictions had on people and community caught up in them, one local described Kloosterhuis’s conduct as “detrimental to the life and soul of the island.”

Robert Thomson – known as Rab – has since spoken to the Scottish media about his case. He took over the Cambus Post Office in Alloa in the early 2000s. Thomson told BBC Scotland that he had reported Horizon shortfalls to Fujitsu, but that didn’t save him when a subsequent audit claimed he was £5,700 short. Rab has described the allegations as “the most embarrassing situation of my life.” It also embarrassed his elderly mother Margaret, from whom he’d inherited the Post Office branch. Word got around. Ashamed, Margaret confined herself to the house. “I went one day to see mum and I found her dead,” he said. He blames himself. “She didn’t want anything to go wrong with the family.”

The book on the Post Office scandal is a book of tragic stories like this one – just ordinary people who found themselves caught up in a nightmare, the trajectories of hundreds of lives forever altered. The canker sore of this injustice can never truly heal: the damage is done. But there can and must be justice and accountability for those who have dealt – and those who have felt – this terrible wrong.