Code :

for(int i = 0; i<kin.length(); i++){
Q = doublePoint(Q, number, a);
if(kin.charAt(i) == '1')
Q = addPoint(Q, P, number, a);
}

Code :

public static ECPoint doublePoint(ECPoint r, BigInteger number, BigInteger a) {
BigInteger temp_m = new BigInteger("0");
BigInteger def_m = new BigInteger("0");
//BigInteger newPoint[] = new BigInteger[2];
BigInteger x = new BigInteger("0");
BigInteger y = new BigInteger("0");
if (r.equals(ECPoint.POINT_INFINITY))
return r;
temp_m = ((THREE.multiply(r.getAffineX().pow(2))).add(a)).multiply(ECMUtility.inverseNumber((TWO.multiply(r.getAffineY())), number));
def_m = temp_m.mod(number);
x = (def_m.pow(2)).subtract((TWO.multiply(r.getAffineX()))).mod(number);
y = (r.getAffineY().add((def_m.multiply((x.subtract(r.getAffineX())))))).negate().mod(number);
BigInteger Xout = x.mod(number);
BigInteger Yout = y.mod(number);
ECPoint out = new ECPoint(Xout, Yout);
return out;
}

I am very new to java and am having trouble understanding the mechanics of nested for loops,

the code is as follows

Code :

for (i = 1; i <= 3; i++) {
for(j = 1; j <= i; j = j + 2) {
System.out.println(j);

the result :

1

1

1

3

the question i have is, why does it print 1, three times as on the first loop round i was equal to j so i thought it would have added 2 to j,

why does it loop 3 time before its true?

I hope that makes sense and I really want to understand the nested for loop before moving on :)

thanks

matthew

--- Update ---

Solved now thanks, I stepped through it and after some confusion got there :)

thanks anyways ]]>