public static byte[] integer2Bytes(BigInteger num, int intendedLength)
      throws GeneralSecurityException {
    return BigIntegerEncoding.toBigEndianBytesOfFixedLength(num, intendedLength);
  }
Converts a nonnegative integer to a byte array of a specified length
(https://tools.ietf.org/html/rfc8017#section-4.2).

@param num nonnegative integer to be converted.
@param intendedLength intended length of the resulting integer.
@return the corresponding byte array of length {@code intendedLength}.
java_src/src/main/java/com/google/crypto/tink/subtle/SubtleUtil.java