List of utility methods to do BigInteger Calculate
boolean | areEqual(BigInteger[] a, BigInteger[] b) are Equal if (a == b) { return true; if (a == null || b == null) { return false; if (a.length != b.length) { return false; ... |
ArrayList | base128(BigInteger val) Convert to base 128 (bigendian), using shifts. ArrayList<Integer> result = new ArrayList<Integer>(); int part = val.and(BN127).intValue(); val = val.shiftRight(7); result.add(0, new Integer(part)); while (!val.equals(BigInteger.ZERO)) { part = val.and(BN127).intValue(); val = val.shiftRight(7); part += 128; ... |
String | base62Encode(BigInteger number) base Encode if (number.compareTo(BigInteger.ZERO) == -1) { throw new IllegalArgumentException("number must not be negative"); StringBuilder result = new StringBuilder(); while (number.compareTo(BigInteger.ZERO) == 1) { BigInteger[] divmod = number.divideAndRemainder(B62_BASE); number = divmod[0]; int digit = divmod[1].intValue(); ... |
BigInteger | bitArrayToUnsignedBigInteger(int[] bits) bit Array To Unsigned Big Integer BigInteger result = BigInteger.ZERO; for (int i = 0; i < bits.length; i++) if (bits[i] == 1) result = result.setBit(i); return result; |
String | bitcoinValueToFriendlyString(BigInteger value) Returns the given value in nanocoins as a 0.12 type string. boolean negative = value.signum() < 0; if (negative) value = value.negate(); BigDecimal bd = new BigDecimal(value, 8); String formatted = bd.toPlainString(); int decimalPoint = formatted.indexOf("."); int toDelete = 0; for (int i = formatted.length() - 1; i > decimalPoint + 2; i--) { ... |
int | byte_size(BigInteger bi) BigInteger size in bytes. int l = (bi.bitLength() + 7) / 8; return l == 0 ? 1 : l; |
BigInteger | calculateGx(BigInteger p, BigInteger g, BigInteger x) Calculate g^x mod p as done in round 1. return g.modPow(x, p);
|
BigInteger | calculateRx_(BigInteger Rx, BigInteger n) A method to calculate the associate value of an ECPoint R, i.e. String nStr = n.toString(); int nLen = nStr.length(); nStr = "0." + nStr; double nDoubKoma = Double.parseDouble(nStr); double fDouble = ((double) nLen + Math.log10(nDoubKoma)) / Math.log10(2.0); fDouble = Math.ceil(fDouble / 2); BigInteger coef2 = BigInteger.valueOf(2).pow((int) fDouble); BigInteger Rx_ = Rx.mod(coef2).add(coef2); ... |
BigInteger | castToBigInteger(Object val) cast To Big Integer if (val == null) { return null; if (val instanceof BigInteger) { return (BigInteger) val; if (val instanceof String) { return new BigInteger((String) val); ... |
BigInteger[] | chop(BigInteger in, int bits) chop BigInteger left = in.shiftRight(bits); BigInteger right = in.subtract(left.shiftLeft(bits)); return new BigInteger[] { left, right }; |