The final firmware boot stage before the OS is responsible for verifying it. For the stock OS, it uses a hard-wired public key. Installing GrapheneOS flashes the GrapheneOS verified boot public key to the secure element. Each boot, this key is loaded and used to verify the OS.
This is strange, since I've actually deleted the key (using steps here: https://grapheneos.org/install/web#replacing-grapheneos-with-the-stock-os) and the OS definitely still booted.
Is this a bug?