Package java.math

Examples of java.math.BigInteger.mod()


        ECPoint p = key.getParameters().getG().multiply(k);

        // 5.3.3
        BigInteger x = p.getX().toBigInteger();

        r = x.mod(n);
      }
      while ( r.equals(ZERO) );

      BigInteger d = ((ECPrivateKeyParameters)key).getD();
View Full Code Here


        //
    for (;;)
    {
      p = new BigInteger(pbitlength, 1, param.getRandom());
     
      if (p.mod(e).equals(ONE))
      {
        continue;
      }
     
      if (!p.isProbablePrime(param.getCertainty()))
View Full Code Here

    byte[] data = new byte[h.getDigestSize()];
    h.doFinal(data, 0);


    BigInteger m = new BigInteger(1, data);
    m = m.mod(q);

    if (BigInteger.valueOf(0).compareTo(r) >= 0 || q.compareTo(r) <= 0) {
      return false;
    }
View Full Code Here

                            BigInteger p, BigInteger q, BigInteger g,
                            byte[] data) {
   
    BigInteger hM = new BigInteger(1, data);

    hM = hM.mod(q);

    BigInteger r = g.modPow(x, p).mod(q);
    BigInteger s = x.modInverse(q).multiply(hM.add(x.multiply(r))).mod(q);

    int dataSz = data.length;
View Full Code Here

  public String run() {
    BigInteger modulus = BigInteger.TEN.pow(10);
    BigInteger sum = BigInteger.ZERO;
    for (int i = 1; i <= 1000; i++)
      sum = sum.add(BigInteger.valueOf(i).modPow(BigInteger.valueOf(i), modulus));
    return sum.mod(modulus).toString();
  }
 
}
View Full Code Here

  private static long sumSquaresMod(long n) {
    BigInteger x = BigInteger.valueOf(n);
    BigInteger y = x.multiply(x.add(BigInteger.ONE));
    y = y.multiply(x.shiftLeft(1).add(BigInteger.ONE));
    y = y.divide(SIX_BI);
    y = y.mod(MODULUS_BI);
    return y.longValue();
  }
 
}
View Full Code Here

        BigInteger upv = BigInteger.valueOf(fraction.numerator)
        .multiply(BigInteger.valueOf(denominator/d1));
        BigInteger t = isAdd ? uvp.add(upv) : uvp.subtract(upv);
        // but d2 doesn't need extra precision because
        // d2 = gcd(t,d1) = gcd(t mod d1, d1)
        int tmodd1 = t.mod(BigInteger.valueOf(d1)).intValue();
        int d2 = (tmodd1==0)?d1:ArithmeticUtils.gcd(tmodd1, d1);

        // result is (t/d2) / (u'/d1)(v'/d2)
        BigInteger w = t.divide(BigInteger.valueOf(d2));
        if (w.bitLength() > 31) {
View Full Code Here

                    hash(d, offset, output);

                    BigInteger Vj = new BigInteger(1, output);
                    if (j == n)
                    {
                        Vj = Vj.mod(ONE.shiftLeft(b));
                    }

                    W = W.add(Vj.shiftLeft(exp));
                }
View Full Code Here

                ECPoint p = key.getParameters().getG().multiply(k);

                // 5.3.3
                BigInteger x = p.getX().toBigInteger();

                r = x.mod(n);
            }
            while (r.equals(ZERO));

            BigInteger d = ((ECPrivateKeyParameters)key).getD();
View Full Code Here

                ECPoint p = key.getParameters().getG().multiply(k);

                BigInteger x = p.getX().toBigInteger();

                r = x.mod(n);
            }
            while (r.equals(ECConstants.ZERO));

            BigInteger d = ((ECPrivateKeyParameters)key).getD();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.