More bytes vs str handling.
Ensure private key is in bytes.
Ensure dict components are str before creating JSON string.