Does PostGIS store its data types using the WKT binary encoding? Or does it use its own custom binary format? Where can I find more information on how the storage layer works in the PostGIS library?
If helpful: https://github.com/postgis/postgis/blob/f6def67654c25d812446239036cee44812613748/postgis/geobuf.c.
It stores data in its own internal format, which is neither EWKT nor EWKB. To learn details, you have to read the source.