public static byte[] serialize(Parameters parameters) throws GeneralSecurityException {
    if (parameters instanceof LegacyProtoParameters) {
      return ((LegacyProtoParameters) parameters).getSerialization().getKeyTemplate().toByteArray();
    }
    ProtoParametersSerialization s =
        MutableSerializationRegistry.globalInstance()
            .serializeParameters(parameters, ProtoParametersSerialization.class);
    return s.getKeyTemplate().toByteArray();
  }
Serializes a Parameters object into a byte[] according to Tink's binary format.
java_src/src/main/java/com/google/crypto/tink/TinkProtoParametersFormat.java