private static ProtoKeySerialization serializePrivateKey(
      Ed25519PrivateKey key, @Nullable SecretKeyAccess access) throws GeneralSecurityException {
    return ProtoKeySerialization.create(
        PRIVATE_TYPE_URL,
        com.google.crypto.tink.proto.Ed25519PrivateKey.newBuilder()
            .setPublicKey(getProtoPublicKey(key.getPublicKey()))
            .setKeyValue(
                ByteString.copyFrom(
                    key.getPrivateKeyBytes().toByteArray(SecretKeyAccess.requireAccess(access))))
            .build()
            .toByteString(),
        KeyMaterialType.ASYMMETRIC_PRIVATE,
        VARIANT_CONVERTER.toProtoEnum(key.getParameters().getVariant()),
        key.getIdRequirementOrNull());
  }
Returns the proto serialization of a {@link Ed25519PublicKey}.

@param access may be null for public key material
@throws GeneralSecurityException if the key cannot be serialized (e.g. unknown variant)
java_src/src/main/java/com/google/crypto/tink/signature/internal/Ed25519ProtoSerialization.java