Bytecode VMs in Surprising Places
dubroy.com
dubroy.com
> Java Card bytecode run by the Java Card Virtual Machine is a functional subset of Java 2 bytecode run by a standard Java Virtual Machine but with a different encoding to optimize for size.
> Did you know, for example, that a SIM can run apps and communicate over the mobile network entirely independently of the host phone? Or that the SIM is arguably more in control of the phone baseband than the phone’s “main” operating system? Or that SIMs can support TCP/IP and run a web server?
https://en.wikipedia.org/wiki/Java_Card
https://mobiforge.com/news-comment/the-sim-the-tiny-computer...
During provisioning the server sends a signed Java Applet to the Secure Element which validates the chain of trust then installs the applet. The EMV protocol involves "application selection" which lets the payment terminal tell the Secure Element OS which applet it wants to communicate with.
ARQC (Authorization ReQuest Cryptogram) is where the applet on the card takes the payment terminal's payment request and identity info, signs it with the PK keypair unique to that provisioned card, and sends it back to the payment terminal which then hands it to the card issuer for validation and approval.
A bunch of Java bytecode: the chip/SE, the payment terminal, and likely also on the server side.
Early contactless payment protocols also started out as something adjacent to, but distinct from, EMV; they eventually got included under the EMV umbrella, but unlike for contact payments, the protocols (called "kernels") vary considerably between e.g. Visa and Mastercard.
There's still a wide range of non-EMV contactless payment cards in use today, mostly for stored-value transit use cases (EMV works best when there's a network connection and doesn't handle long-term two-sided offline cases very well). NXP is an important player there (with their Mifare series of cards/chips); Felica is another (mostly in Japan).
I think the fact that it's running loadable code at all is what's unexpected here, though, not really the fact that it does so using bytecode; that's mostly for compatibility across card OS vendors.
Java/the JVM was what was cool at the time these high-level programmable smartcards started becoming popular. Introduced today, they'd probably be running WASM.
https://www.design-reuse.com/news/4228/arm-securcore-support...
These days, these are sometimes ARM M0 cores which are significantly more powerful. I think Doom over SAT (SIM application toolkit) is within reach :)
(I spent a lot of time with both of these when hand-hinting my programming font.)
A couple years ago I thought about giving a presentation on a Golang VM I wrote to solve a simple problem, but it was seen as kind of a heterodox approach and I didn't want to deal with a million "umm acksully" questions about whether it was a real VM.
I'd also argue it's the most beautiful.
[0] https://ocw.mit.edu/courses/res-6-004-principles-of-computer...
Bytecode VMs are all over the place.
TFA added PostScript and TrueType, and comments here mention others. There's also Java, which is oddly not listed. And Lua. And...
https://codegolf.stackexchange.com/questions/215216/high-thr...
And a few more databases [0]: Mongo, Postgres, and SingleStore.
[0] https://notes.eatonphil.com/2023-09-21-how-do-databases-exec...
The rest can probably be found by searching around but I'm on my phone right now
https://thechipletter.substack.com/p/bytecode-and-the-busico...
And why does miri exist?
It is a lot slower. However it can check for some undefined behavior.
Apple II Integer BASIC was implemented using a 16-bit bytecode on a VM called SWEET16 to do 16-bit arithmetic, optimizing for space over speed. [1]
Running arbitrary code inside a financial transactions system isn’t the most obvious decision.
Highly recommended Fabien Sanglard series on Another World: https://fabiensanglard.net/another_world_polygons/index.html