class CexIODigest extends BaseParamsDigest {

  private final String clientId;
  private final String apiKey;
  private final SynchronizedValueFactory<Long> nonceFactory;

  /**
   * Constructor
   *
   * @param secretKeyBase64
   * @param clientId Account user name
   * @param apiKey @throws IllegalArgumentException if key is invalid (cannot be base-64-decoded or
   *     the decoded key is invalid).
   * @param nonceFactory
   */
  private CexIODigest(
      String secretKeyBase64,
      String clientId,
      String apiKey,
      SynchronizedValueFactory<Long> nonceFactory) {
    super(secretKeyBase64, HMAC_SHA_256);

    this.clientId = clientId;
    this.apiKey = apiKey;
    this.nonceFactory = nonceFactory;
  }

  public static CexIODigest createInstance(
      String secretKeyBase64,
      String clientId,
      String apiKey,
      SynchronizedValueFactory<Long> nonceFactory) {
    return secretKeyBase64 == null
        ? null
        : new CexIODigest(secretKeyBase64, clientId, apiKey, nonceFactory);
  }

  @Override
  public String digestParams(RestInvocation restInvocation) {<FILL_FUNCTION_BODY>}
}


    Mac mac256 = getMac();
    String nonce = nonceFactory.createValue().toString();
    mac256.update(nonce.getBytes());
    mac256.update(clientId.getBytes());
    mac256.update(apiKey.getBytes());

    String signature = String.format("%064x", new BigInteger(1, mac256.doFinal())).toUpperCase();

    List<Object> unannanotatedParams = restInvocation.getUnannanotatedParams();

    for (Object unannanotatedParam : unannanotatedParams) {
      // there *should* be only one
      if (unannanotatedParam instanceof CexIORequest) {
        CexIORequest request = (CexIORequest) unannanotatedParam;
        request.signature = signature;
        request.nonce = nonce;
        request.key = apiKey;
      }
    }

    return signature;
  
<methods>public javax.crypto.Mac getMac() <variables>public static final java.lang.String HMAC_MD5,public static final java.lang.String HMAC_SHA_1,public static final java.lang.String HMAC_SHA_256,public static final java.lang.String HMAC_SHA_384,public static final java.lang.String HMAC_SHA_512,private final non-sealed javax.crypto.Mac mac