Friday, July 3, 2020

Prank Defeated - Formerly: Introducing Inference: A Neural Network Powered Programming Language

OK, a few months ago, I wrote this post, as a bad joke, and scheduled it to be published on April 1st, 2021. Since then, I've had a chance to play around with OpenAI's AGI playground, and while I've only produced some fairly funny interactions and other basic uses, other people are doing some crazily impressive stuff with it, like this:



So I'm posting this thing early, because why not, but instead of it being a prank, it's more a prediction of the future.


Inference has been created to define a new paradigm of programming languages.

Where all previous languages required programming using a rigid syntax, where semantics were precise, and no leeway existed, Inference uses the power of neural networks to infer meaning from the programmer.

The basic model works like this:

Programmer writes code however they want

For example:
  1. var x = position + 8
  2. add a margin of 8 to the position - keep track of that for me (call it x)
  3. let a new variable (let's say x) hold that variable I just used, plus the fixed margin

Training

The neural network ingests the code that's been written, and based on its assessment of certainty of each statement (taken individually, and in a sampling of broadening contexts), quizzes the programmer for meaning, generating educated guesses about the meaning, as well as allowing the programmer to correct it.

For example:
Regarding let a new variable (let's say x) hold that variable I just used, plus the fixed margin, did you mean:
a) int x = position + fixedMargin  [92% certainty]
b) int x = position + [?? supply reference to "fixed margin"] [98% certainty if reference supplied]
c) int x = position + top [86% certainty as fixedMargin used after top]
d) [Let me know more precisely what you meant]
As this is a trained system, the more consistently the style is written, the easier it will be to train. That might make it seem pointless, except it is able to store multiple profiles, for each developer, meaning multiple programmers can each use their own style, and train the model to understand what they each mean.

Performance

So far, this is in alpha, but with just 3 days of training on pseudocode written by 3 developers, it has been able to understand, compile and execute a simple Pong-style game, written in plain language by those same developers.

More info

Code and infrastructure config will be released soon.
Tweet at me for more info.

Monday, December 16, 2019

Atheism vs Agnosticism: A Brief Explainer

I had a brief Twitter exchange with a well-known poker player, and realised that he seems to be religious. My default position in any exchange is an assumption that people are atheists. I guess that's because I am one myself, but it also seems to me to be the overall default, given that everyone starts their lives as atheists, with no beliefs about god, or television, or sports, or anything, and it's only through exposure to religious ideas that people become religious. It's why "Christian" countries tend to have more Christians, and "Muslim" countries tend to have more Muslims.

So, I knocked up the following image to explain how Gnosticism (knowledge) differs from Theism (belief) in god(s). I've seen similar things in the past, and the examples are extremely approximate, but it's probably good enough to be able to send people to this link when they ask about my thoughts on it.

Two dimensional spectrum of Theism vs Gnosticism

The only other thing to really talk about here is that, unlike, say, the common 2-d political compass (which I find to be too naive), belief and knowledge actually could be drawn on one dimension, because all knowledge is really a subset of belief, and it comes down to what presuppositions a person has. But my presuppositions include solipsism being pointless, and that the scientific method is an appropriate way to understand whatever can be understood, so I'm ok with treating knowledge as categorically different to beliefs, even when some purported knowledge turns out to be false, because it's more reliable than a world in which everyone has their own facts.

Friday, June 22, 2018

A Gotcha in Variable Initialisation in Golang

I'm new to Golang development, and there are lots of things I consider weird with the language. I've just discovered this gotcha, luckily before any code went live, so I figured I'd post about it.

Variables of the same name can be declared at multiple scopes within the same function, and as functions can return tuples, it's possible that, when declaring and initialising variables at the same time, you intend to actually reuse a previously declared variable.

For example:

  x := 1
  y := true
  if y {
    z, x := DoSomethingThatChangesX(x)
    fmt.Printf("Output: %d, %d", x, z)
  }

  fmt.Printf("If x is 1, oops: %d", x) // x == 1


The output of this will show that the x that is set as an output of DoSomethingThatChangesX will not be the same x as in the outer scope.

This next version shows how the code can be changed, in quite an ugly way, to avoid the gotcha:

  x := 1
  y := true
  if y {
    var z int
    z, x = DoSomethingThatChangesX(x)
    fmt.Printf("Output: %d, %d", x, z)
  }

  fmt.Printf("If x is 1, oops: %d", x) // x != 1


By separately declaring z before initialisation, z and x can both be assigned a value separately to declaration.

I know this will come across as pretty simplistic, and is obvious when you think about it, but I still think it would be really easy to increase some subtle bugs, which even careful eyes might not spot, because of it.

Monday, October 16, 2017

A Challenge for Homeopaths

Homeopathy is a body of "knowledge" wherein it is believed that ingredients that cause a symptom when consumed in full strength can be used to treat health issues that have those same symptoms.

At least some homeopaths cause patients to delay real treatment for diseases like cancer, and thereby to die.

The discipline (in the sense of its adherents being disciples) was created, entirely out of whole cloth, at a time when placebos could conceivably be better than the real medical treatments of the day. That's one proposed reason for its rise in popularity.

Not coincidentally, homeopathic remedies require extreme dilution, to the point where the mathematical modelling demonstrates that the remedy contains none of the original active ingredient.

Homeopaths claim that a higher amount of dilution, even well past the point where there is nothing left but water, boosts a remedy's strength and effectiveness.

I'm sure this is an overly simplistic summary of homeopathy. Just as there are entire universities where people study for many years in theology, the more fictional a structured field of study, the more esoteric the knowledge must become. Much of the body of knowledge and study must be focused on learning and developing "outs", i.e. the ability to shift goalposts in order to keep the main hypothesis unfalsifiable.

So, based on this take of homeopathy, here is my challenge:

You need not use a remedy to successfully treat a disorder, because that would allow for the aforementioned goalpost shifting ("it doesn't work if you don't believe").

I will merely supply several samples of homeopathic remedies. They will all be samples from real purveyors of homeopathy. For each sample, you need only tell me what the active ingredients are, and at what concentrations.

You can use whatever equipment you would like in order to do the analysis. You can use the samples on people - even true believers - to measure the effect; anything you like as long as the challenge is conducted with your ignorance of the source samples.

In the spirit of James Randi's million dollar challenge, and in light of my inferior financial position (given the need for escrow), I'd suggest a $1000 prize, or perhaps I can crowdfund the prize money, so you can win from lots of non-believers.

Either way, it will be worth your while to merely prove to me that your career isn't a giant fraud, and that you didn't waste all those weeks at the Unaccredited University for Fictional Studies.

Are you up to the challenge?

Saturday, January 21, 2017

Trump's Inauguration Speech

So, if you haven't, watch Trump's inauguration speech. Don't watch excerpts, which can introduce bias; go to the source and watch the whole thing.

I can see how people could see it as inspiring or uplifting, or other positive things.

I thought it was pretty worrying if seen through the lens of examples of fervent, populist movements concentrating power at the top. His references to hearing the people's voices and that people wouldn't be unheard anymore was particularly scary, as he didn't show how he'd actually be listening to individual real people, and deliberating rationally based on those inputs.

Instead, it sounds like he'll be doing what is needed to maintain that fervour and to increase his power, i.e. he'll be the figurehead of a mob. That's a power structure that is easy to exceed the limits of American constitutionalism. And without that, there's the risk of some very dark times.

But like I said, watch it for yourself. I could be wrong. I hope I'm wrong.

Tuesday, December 6, 2016

AdWords used in eBay Stores Bait-and-Switch Scam

I was looking at a device that I recently saw online - probably through Facebook marketing, called a Fidget Cube. It cost something like US$20 each or 3 for about $50, including shipping.

I almost bought it on an impulse, then decided to see how much it cost if I googled it.


Monday, March 28, 2016

Australian Senate Electoral Reform: Close, but no Cigar

In Australia, we have a great, albeit complicated-in-the-back-end, system for electing senators. Not only is it proportional so that smaller parties can get represented, but it's preferential, so people aren't pushed towards 2-3 parties due to a fear of wasting their vote.

In practice, almost every person just votes for a single party, and the party's own preferences for how that vote should be distributed are followed. This is called a Group Voting Ticket, or GVT. The effort of a person specifying all their own preferences, or even learning about more than a couple of different parties' policies, is enough to deter about 96% of the population from numbering every box for every candidate, which often reaches about 200 in total, which until recently, was the only alternative to following a party's GVT.

One area where there has been a lot of argument is that the way GVTs were being created wasn't fair, because they allowed parties to agree how to game the system by preference sharing in a way that was technically visible to voters, but invisible in practice, creating strange bedfellows. This allowed election of senators with sub-1% of the first preference votes to win seats after preference distribution.

Lack of transparency is an issue, but I have no problem with preferential voting systems allowing the election of people who would not have been foreseen in a non-preferential system. That's what preferences are for, after all: electing consensus candidates, rather than extremists who win a non-preferential plurality.

So, a reform that's just been made, specifically designed to exclude many minor parties from doing what was done in the last election - winning seats against the odds - has been enacted. (The government says the problem is that those who were elected in this way are not representative of Australia, but looking at the individual senators makes it clear they are far more representative of Australia than the major parties' senators.) The reform sounds reasonable, being that a person can preferentially number party boxes - as many as they'd like to express their preferences - instead of one party box or all candidate boxes.

The problem with this reform, however, is that it throws the baby out with the bathwater: some parties, specifically Pirate Party Australia in my experience, use preference deals with other parties in an open, transparent and honest way, and those parties will now be penalised by the unaddressed problem with this reform: most people still don't know enough about all the political parties, or care enough about how the system works, to vote for more than a few pairs at the top of their mind. Preferences will now be left unspecified, even where they would have clearly aligned with a voter's honest preferences.

I appreciate that the Australian Greens have said that they have had this reform as their policy for 12 years, so there should be no surprise to anybody, but the public debate was non-existent, and most people would have no clue about some old Greens policy that has had very little airtime over the intervening years. There was no Australian Law Reform Commission request for opinions, followed by a report, which would be standard practice for such an important reform.

Pirate Party Australia was calling for a, now possibly useless, non-partisan royal commission to consider different approaches that would be fair (to the voters, not the status quo). I would like to think that one solution that could have come out of that would have been this: Allow people to specify their own party preferences, just like in the current reform, but for any unspecified preferences, follow the preferences of the party in the voter's first preference.

For example, if party A had a GVT of A, B, C, D, E, F, and a voter voted A, F, D, then that would be translated into A, F, D, B, C, E.

This slight tweak to the system would have been the best of all worlds: Voters would be free to specify their own preferences, without too much effort and without relying on backroom party deals, parties could have worked with like-minded parties to ensure that votes aren't exhausted, and thereby wasted, and most of the power to exploit GVTs would have been removed.

Maybe this idea can be revisited after the upcoming election, but with all those independent voices set to be wiped out and a resulting, further entrenchment of power upon us, I'm not holding my breath.

Monday, December 28, 2015

Facebook and Hate Speech

I'm a very firm believer in freedom of speech. There are lots of reasons to oppose censorship, but that's not what this post is going to be about. This post is about what Facebook, and similar sites can do to help reduce the effect of hate speech without censoring anyone.

Tuesday, July 14, 2015

[Solved] Frequent Wifi Disconnection on Samsung Galaxy Tab S

My Samsung Galaxy Tab S, running KitKat, has been having problems over the last few weeks, where the WiFi connection constantly drops out and reconnects, causing connection issues on loads of sites and apps. It's been happening at home on a new router, and at work on some fancy new access points that mesh together to bathe our whole office, so I'd put it down to the phone (I use the 8.4 inch tablet as a phone anyway (which looks pretty comical)) itself.

I finally decided to dig into why, and found this forum post, where people throw around various ideas like Samsung SideSync being the cause, though in my case it was much simpler.

I'd turned on Smart Network Switch, under the WiFi settings, which claims to maintain a stable connection by switching between 4g and WiFi when needed. There's something wrong with it though, because it was saying that a WiFi connection is unstable even when it's got full bars in an unpolluted area, so it was just causing lots of unnecessary switching to 4g. Since I turned it off, the WiFi connection has been reliable and stable, rather than switching several times per minute.

Problem solved, and I hope it helps someone else out there.

Monday, June 29, 2015

I Fear For My Citizenship And You Should Too

The government's proposed changes to citizenship for dual nationals would allow a minister to cancel a dual citizen's citizenship at their own discretion, and it would not allow appeals to the court. If someone is not a citizen, only having a visa enables them to stay in Australia. Even if they have a visa (and why would they?), it can be cancelled by the same minister, so they could potentially be deported or at least moved to detention, held incommunicado, before anyone knows what's happening. This is remarkably dangerous.

The Liberal Party have clearly included in their talking points a lot of emphasis on protections, but let's have a quick look at them. As an aside, Labor has also been working through how to word support for this. The bill would allow for judicial review. I don't believe that this is because of the government's concern for the rule of law; I believe it's because whenever, in the past, Australian governments have tried to exclude it as an option, the High Court has found a way to re-include it, either by saying the government didn't word the legislation effectively enough to exclude it, or that the government couldn't exclude it because the Constitution directly allows for some petitions to the High Court that the government can't legislate away.

But, put simply, judicial review only allows a person to challenge whether a decision was made properly; it does not allow a person to challenge whether a decision was made reasonably given the facts, i.e. it does not allow for a merits based appeal where the affected party can question the fairness or accuracy of the decision, except in very limited circumstances. Typically, the minister's decision would stand unless it meets a really high standard called Wednesbury unreasonableness, which is defined as:

"A reasoning or decision is Wednesbury unreasonable (or irrational) if it is so unreasonable that no reasonable person acting reasonably could have made it."[1]

That's not very illuminating, so in practise, you need to prove that the decision was unreasonable beyond belief. Luckily, reasons for (most kind of) administrative decisions need to be made available, so that gives some fuel. In SZMDS[2], a homosexual man was deported back to Pakistan because the minister didn't believe he was really afraid (and the federal court judge didn't believe he was really gay (despite strong evidence)). That's the kind of stuff that doesn't meet the level of unreasonableness that would allow a successful challenge.

Even if a decision was challenged successfully, the typical result is that the minister just needs to remake the decision. Much of the time, they make it differently with a different result, because they know they're being watched, but we've seen how belligerent this government is with political decisions; they'd just make the same decision, maybe for better rationalised reasons, which is what Scott Morrison tried to do in S297.

In addition, the minister's reasons, which would normally be accessible to the formerly dual citizen, would likely be exempt from being made available, as the documents would probably have been prepared for cabinet, or be related to national security (as we've been told is the purpose of this legislation) and are therefore exempt from the Freedom of Information Act. All the safeguards that the Abbott government have given are a smokescreen.

So, I, a person who was born an Australian citizen, who has spent most of my life here, but commonly speak out against the policies of both the major Australian parties, should rationally fear that at some point, my citizenship could be revoked on a whim. That's a pretty bad chilling effect against my continued involvement in the political process. If that seems like an unreasonable position because the government has said that the bill is only meant to affect people who leave the country to fight against "our interests", consider that they don't feel so strongly that they'd actually put that as a requirement into the legislation. As usual, with civil-liberty-encroaching legislation, we are told that there are protections, but they're merely spoken platitudes, unwritten and unbinding.

My job involves finding edge cases that allow for a well meaning rule to be exploited, but I don't pride myself on finding this one, because it's not subtle. To any of these lawyers in power, assuming they wrote their own essays and sat their own exams, it's obvious. Obvious to the point of being clearly intended. All these laws to protect us from the way-of-life-changing effects of terrorism, and it's always the major party politicians destroying the rule of law and freedoms we hold dear.

[1] Associated Provincial Picture Houses Ltd v Wednesbury Corporation (1948) 1 KB 223
[2] Minister for Immigration and Citizenship v SZMDS & ANOR [2010] 226 ALR 367

Saturday, June 20, 2015

Apple Craftini

I just made some tasty cocktails with some of what I had available, so I'm writing it down before I forget, and hopefully it will make someone else happy if they make it and drink it.

I'm calling it, egotistically, the Apple Craftini.

Recipe:
Put about a dozen cubes of ice info a 600ml+ measuring jug.
Blend a medium granny smith Apple with 40ml of extra dry vermouth.
Push the apple mixture through a sieve into the measuring jug, making sure to scrape off the solids from the underside of the sieve into the jug.
Add 80 more ml of vermouth, along with 120ml of vodka. Make sure the vodka is non-Russian, because of their anti-gay laws and totalitarian power structure.
Add 120ml of a good apple cider - I used Cascade - and then stir it all thoroughly together.

Serve out into two highball or large whisky glasses, including the ice. Feel free to garnish with some apple peel. I peeled off a bit, but forgot to put it on the glass.

Enjoy!

Friday, June 12, 2015

More Website Blocking for Australia

Now that Netflix is available in Australia, you might think you don't need a VPN. Think again.

The government, with opposition support, is planning to pass more site-blocking legislation, ostensibly to address piracy this time. They're even considering whether VPNs should be legal or not. There's no way they will criminalize them until a few more rounds of fascist scope creep have occurred, but whether or not they're ultimately successful, they will try.

When they finally do attempt to criminalize VPNs, there'll be a mental test, with the law worded something like "using a VPN with intent to access illegal services". Then it will be modified to "using a VPN in a way that could reasonably be considered to be for bad things m'kay". And there'll be a carve-out to protect business use, so that businesses don't complain and the government can screw individuals without endangering their campaign finances.

Anyway, get a VPN and tell your MPs to mind their own business.

Sunday, December 21, 2014

Pharmaceutical Price-fixing

I use a nasal spray, for which I was given a prescription and told to use it every single day. When I was given my prescription with 20 repeats, it cost almost $50 for a bottle that would last one month. It was an unexpected lifetime mobile phone contract worth of preventative health care.

I saw it advertised on TV the other day, and wondered if it was actually the same thing, because it was an over-the-counter drug they were advertising.

I asked a pharmacist, and the drug has been deregulated, so no more need to organise trips to the doctor just to get more of the same.

Now for the point of the story: in being deregulated, the price has changed from $50 per bottle to $20. I don't know exactly the cause of this, but I can only imagine it comes down to less access to government money through people with health care cards, or something like that.

That's a bloody outrage, that is. We're not meant to have that American kind of system where insurance drives up prices.

There should be an inquiry into the effects of regulation on medication prices. I don't know if it would find that there are any practical solutions, but regulation should not add 150% onto the price of the medication.

Wednesday, November 5, 2014

Hey Bill, No Thanks, Love Tony

So, Bill Shorten is concerned that the new National Security laws might restrict freedom of speech and result in journalists going to jail for reporting on stories with a public interest...

Better late than never, I guess, but only marginally so. I can't imagine Tony Abbott will be all that concerned.


Tuesday, October 28, 2014

Australia: The Torture State

The following is a translation of an article about Australia's refugee policy from the original German version featured in Handelsblatt. It's a very interesting international perspective, which is enlightening for those of us who only see Australia from within the prism of our local, mainstream media's agenda.

Friday, October 17, 2014

Indelible email

Here's another idea for a form of secure messaging. This time, it's middleware for a secure email ecosystem.

The idea is to have businesses set up bitcoin wallets, manage the private keys, and to use bitcoin for email.

This would just be middleware to abstract bitcoin from users. On top of this would be a normal email server layer, where users can request their inboxes from the corporate server, with or without encryption and other features.

Using bitcoin for email would allow records to be created that could not be destroyed or altered, and would make compliance easier for businesses, and discovery (with subpoenas) easier for the courts.

With message sizes growing massively if this system were used, the blockchain messages could instead contain hashes of payloads located in parallel systems. Each business with a node, for example, could expose the payloads through web services, which would be encrypted so that only the recipient's public key could decrypt it.

I once wrote an idea for a client-encrypted email system, and the biggest criticism I could find of similar systems is that a user wouldn't, in practice, know it wasn't secretly compromised, no matter what protections were in place in the client. Using this corporate middleware that relies on the blockchain would solve those problems, at least for businesses.

Now, I've specifically said to use bitcoin, rather than a non-currency blockchain, because one benefit of this system could be requiring messages to have some payment made for processing of the messages. The amount would be set so that spamming would be costly, but normal email would cost little.

Emails could still be read and relied on pretty well without even being verified, subject to being revokable on discovery of a fraud within an hour. And any messages that are sent without payment could be ignored by the middleware as spam.

One challenge of this system would be how to communicate addresses. They could be actual bitcoin addresses communicated by text or QR code, but it seems like a more user-friendly approach would be to have a directory on each node, or to use TXT DNS records or something, so that normal email addresses could be looked up and converted into bitcoin addresses.

Anyway, thoughts on this system? Ideas for refinement of the idea, or criticisms of why it wouldn't work or is stupid?

Friday, September 26, 2014

I'm still here

Now that we live in a police state, we need a way to inform our loved ones when the secret police have taken us away subject to a preventative detention order to be held incommunicado.

Well, there's an app for that. Or there might be... I don't really know. But there could be, and here's how it would go:

Firstly, there needs to be a trustworthy authority for holding, though not issuing, public keys. A web of trust is suitable for the purpose, though using the blockchain would be more resilient.

Then, there needs to be an actual app.

The app would use your private key to sign a message. The message could contain your whereabouts, but that would be a risk of its own. Instead, the message could contain your whereabouts encrypted with the public key of 1...n trusted people. Actual content of the message, such as state of mind, e.g. "I feel safe" or "I think I'm being followed" could be selected from a list or preprogrammed into buttons.

Then, all that's left is to hit the button, which would encrypt the whole message with your private key, doing whatever digest stuff is necessary to be secure, and post the encrypted message to Facebook, Google+, and, if the message can be split up, to Twitter.

Now, you can't expect to oust the plain text message asking with the encrypted message and expect anyone to verify that the encrypted message is valid and matches the plain text message. That's why only the encrypted message would be posted.

To make the system functional, the app would allow the use to follow other people. Their encrypted messages would be downloaded and decrypted using relevant public keys, and the messages would be logged in the app.

From there, it's a simple matter to alert the user when friends of the user haven't checked in for more than a day or so.

So, if you're reading this and give a crap about civil liberties, and know about infosec-related programming, and want to help me out, or just give me opinions, advice, or let me know that this has already been done, then leave a comment or tweet at me @dcrafti.

/ramble

Monday, August 11, 2014

Open Letter to Bruce Billson MP re: Data Retention

Here is the letter that I submitted to my MP via the EFA/GetUp petition on Data Retention. Please consider also signing the petition and writing a letter to your MP, which the form makes extremely trivial to do.

Thursday, August 7, 2014

LexisNexis Rage

We said it's a free society, not a free society

I graduated from my Master of Laws degree earlier this year, and since then, I've been somewhat disconnected from being able to continue my studies. I mean disconnected in the literal sense.

Monash University, where I did my study (though I assume all other institutions are the same), give access to lots of online research tools for the duration of studies. Many of those tools are made by the likes of LexisNexis or ThomsonReuters. However, since graduation, I can no longer access any of these services.

In particular, LexisNexis makes a terrible database front-end for looking up reported cases and journal articles, called CaseBase. While the rest of the world has moved on to web 3.11, or some other such buzzword, CaseBase has remained true to its origins, firmly rooted in web 0.98beta.

They have no reason to spend money on improving their horrible front-end or adding features to their search "technology", because, as I'm sure you could guess, all their content is licensed either from journal companies, or some government department or government-approved monopoly. That means, for example, that you have to go through CaseBase, or some system just like it, in order to find out what was said in the decisions of the courts, for most court decisions. In Australia, which is a common law country, that means that without paying for a subscription, you cannot feasibly find out enough of the law to know what your responsibilities are, as a citizen.

You shouldn't need to pay for this stuff, but let's forget all that idealistic crap about citizens being able to read the laws of the land. I'm not cheap, so I'll just pay for a subscription. It can't be too much can it?

Try to find out on the website. I couldn't. I tried to LiveChat with them, but it took them somewhere north of an hour to respond, from my estimate, and I'd left my computer. I left a message on the phone and finally got a call back the next day. So this is an efficient company, huh?

So, now, back to how much it costs. I guess on an annual subscription, for this important information, $700 isn't too much is it? Oh, you think it is? Well, on an annual subscription, that's the monthly cost.

CaseBase costs $8,400 per year

Stripping out various journals and paring it back to just access to cases still cost about $5,000 per year, and when I still balked at that, the sales rep offered it to me for $3,400 per year, because I wouldn't be using it commercially.

Yeah, no.

This is what happens when information that should be public domain is locked up behind paywalls; we're left with sub-standard systems that cost a fortune.

It's a rort, and it needs to be fixed.

Tuesday, July 8, 2014

[Solved] Amazon EC2 HTTP/HTTPS Redirection Loop using IIS

I'm writing this up because, like with a couple of problem solving posts in the past, I think this could be helpful for other people who have spent hours googling without any results.

I have been setting up a site on a single Amazon EC2 instance. The site can be accessed with SSL or without.

I generated the certificate request, going through GeoTrust, installed it with only a little difficulty.
Everything was going well until I tried to visit any of the HTTPS pages. If they didn't require HTTPS, then the request was redirected back to the HTTP version with a 301 permanent redirection. If HTTPS was required, then a redirection loop was encountered, as my code kept redirecting back to HTTPS, with something redirecting back to HTTP.

Lots of articles exist where people can't reach the site over SSL, but that wasn't my problem. Lots of articles exist where the problem is that Amazon's Enterprise Load Balancer (ELB) was in use, which obviously intercepts HTTPS requests, then passes on the result as HTTP, which would cause a redirection if requesting a page that requires HTTPS, but should not cause a loop where HTTPS is optional.

Instead, the problem was much simpler. The binding I had set up in IIS for HTTPS was using the EC2 instance's public, elastic IP address, rather than the server's private IP address. This was resulting in a redirection to the non-secure version on requests for the secure version, because as far as the server knows, the elastic IP address is a different machine.

Anyway, so changing the binding to use the private IP address worked perfectly.

I can't be bothered trying to word this as a question and answer using the right keywords and then deciding on whether it is more appropriate to go on Stackoverflow.com or Serverfault.com, hence me brain-dumping this here.

Hopefully, this SEO-keyword-laden blog post will allow others who get bitten by this esoteric issue to find an answer much faster.