.onion service id vs identity key in stem

In order for a program I’m building to work, I need to be able to calculate the .onion service id from the key-content parameter passed to create_ephemeral_hidden_service() in the python stem library.
I’ve observed that the key-content variable is a 64 bytes encoded in base64. However, all of the documentation for Tor specifies that the .onion service id is derived from a 32 byte ed25519 key. Furthermore, when I use the stem function HiddenServiceDescriptorV3.identity_key_from_address() on a given .onion SID, it spits out a 32 byte string, as expected. The corresponding function HiddenServiceDescriptorV3.address_from_identity_key() likewise expects a 32 byte string.

I could go on, but the tl;dr here is that I’m very confused as to what exactly the 64-byte string passed into the ephemeral service creation function (and possibly the ADD_ONION command judging by the source code) is supposed to be, and what hokey pokey I have to do to convert that to a .onion service id.

Update: I got it working!!!

The trick was to calculate the .onion SID from the public portion of the ED25519 key.
After doing that, the calculated .onion matched the .onion SID generated by the stem call.

Update: I’ve identified the 64-byte string as the expanded format of a ED25519 key.
There is example code that will expand a 32-byte key to a 64-byte key here (see expandSK()): https://github.com/torproject/tor/blob/main/src/test/ed25519_exts_ref(dot)py
However, using it on the following key:
generates the following expanded key:
feeding this into create_ephemeral_hidden_service generates the following .onion SID:
v4dkhyzjc4koj42wygojwfondfi6y3tgmkvhppqhkr7sre4dgqoqsbid . onion
however, the calculated SID for the original key is:
mfqwcylbmfqwcylbmfqwcylbmfqwcylbmfqwcylbmfqwcylbmfqwbfad . onion