private static com.google.crypto.tink.proto.JwtRsaSsaPkcs1KeyFormat getProtoKeyFormat(
      JwtRsaSsaPkcs1Parameters parameters) throws GeneralSecurityException {
    if (!parameters.getKidStrategy().equals(JwtRsaSsaPkcs1Parameters.KidStrategy.IGNORED)
        && !parameters
            .getKidStrategy()
            .equals(JwtRsaSsaPkcs1Parameters.KidStrategy.BASE64_ENCODED_KEY_ID)) {
      throw new GeneralSecurityException(
          "Unable to serialize Parameters object with KidStrategy " + parameters.getKidStrategy());
    }
    return com.google.crypto.tink.proto.JwtRsaSsaPkcs1KeyFormat.newBuilder()
        .setVersion(0)
        .setAlgorithm(ALGORITHM_CONVERTER.toProtoEnum(parameters.getAlgorithm()))
        .setModulusSizeInBits(parameters.getModulusSizeBits())
        .setPublicExponent(encodeBigInteger(parameters.getPublicExponent()))
        .build();
  }
Encodes a BigInteger using a big-endian encoding.
java_src/src/main/java/com/google/crypto/tink/jwt/JwtRsaSsaPkcs1ProtoSerialization.java