Java BigInteger Calculate serializeQuery(BigInteger modulus, BigInteger base, BigInteger exponent, boolean brief, String... modexps)

Here you can find the source of serializeQuery(BigInteger modulus, BigInteger base, BigInteger exponent, boolean brief, String... modexps)

Description

Helper method creating the JSON string for a modexp-queryResponse with optional default base, exponent and modulus.

License

MIT License

Parameter

Parameter Description
modulus the default modulus to use or null to omit
base the default base to use or null to omit
exponent the default exponent to use or null to omit
brief should the server return a brief or full response?
modexps JSON strings of modexps to queryResponse for

Return

A JSON representation of a modexp-queryResponse

Declaration

static String serializeQuery(BigInteger modulus, BigInteger base, BigInteger exponent, boolean brief,
        String... modexps) 

Method Source Code


//package com.java2s;
/*/*from w  ww.j  av  a 2 s  .  c o  m*/
 * Copyright 2016 Pascal Mainini
 * Licensed under MIT license, see included file LICENSE or
 * http://opensource.org/licenses/MIT
 */

import java.math.BigInteger;

public class Main {
    /**
     * Helper method creating the JSON string for a modexp-queryResponse with optional default base, exponent and modulus.
     * @param modulus the default modulus to use or null to omit
     * @param base the default base to use or null to omit
     * @param exponent the default exponent to use or null to omit
     * @param brief should the server return a brief or full response?
     * @param modexps JSON strings of modexps to queryResponse for
     * @return A JSON representation of a modexp-queryResponse
     */
    static String serializeQuery(BigInteger modulus, BigInteger base, BigInteger exponent, boolean brief,
            String... modexps) {
        String query = "{";
        query = modulus != null ? query + "\"m\":\"" + modulus.toString(16) + "\"," : query;
        query = base != null ? query + "\"b\":\"" + base.toString(16) + "\"," : query;
        query = exponent != null ? query + "\"e\":\"" + exponent.toString(16) + "\"," : query;
        query = brief ? query : query + "\"brief\":false,";

        query = modexps.length > 0 ? query + "\"modexps\":[" : query;
        for (int i = 0; i < modexps.length; i++) {
            query += modexps[i];
            query += i < modexps.length - 1 ? "," : "";
        }
        query = modexps.length > 0 ? query + "]" : query;

        return query + "}";
    }
}

Related

  1. rightshift(byte b1, BigInteger b2)
  2. saveKey(File destDir, String fileName, BigInteger modulus, BigInteger publicExponent)
  3. saveToFile(String fileName, BigInteger mod, BigInteger exp)
  4. serializeModexpNoBase(BigInteger[] modexp, boolean withResult)
  5. serializeModexpResponse(BigInteger response)
  6. shift(BigInteger integer, int distance)
  7. shiftLeft(final BigInteger register, final BigInteger input, final int n)
  8. split(BigInteger maxValue, int numberOfSplits)
  9. splitBigInt(BigInteger value, int n)