encodePkcs8

suspend fun encodePkcs8(): ByteArray

The key as PKCS #8 DER (PrivateKeyInfo, RFC 5958) whose inner ECPrivateKey (RFC 5915) carries the public key — secret material; store it as such.

The public key is written explicitly on every platform. The JDK provider's own export omits it, and the JDK cannot recompute it when reading, so without this a key written on the JVM could not be read back there. The structure is rebuilt with cryptography-kotlin's own DER codec; no key material is computed here.