package org.bouncycastle.math.ec.test;

import java.math.BigInteger;
import java.security.SecureRandom;

import junit.framework.TestCase;

import org.bouncycastle.asn1.sec.SECNamedCurves;
import org.bouncycastle.asn1.x9.X9ECParameters;
import org.bouncycastle.math.ec.ECPoint;

/**
 * Compares the performance of the the window NAF point multiplication against
 * conventional point multiplication.
 */
public class ECPointPerformanceTest extends TestCase
{
    public static final int NUM_ROUNDS = 100;

    private void randMult(final String curveName) throws Exception
    {
        final X9ECParameters spec = SECNamedCurves.getByName(curveName);

        final BigInteger n = spec.getN();
        final ECPoint g = (ECPoint) spec.getG();
        final SecureRandom random = SecureRandom.getInstance("SHA1PRNG", "SUN");
        final BigInteger k = new BigInteger(n.bitLength() - 1, random);

        ECPoint qMultiply = null;
        long startTime = System.currentTimeMillis();
        for (int i = 0; i < NUM_ROUNDS; i++)
        {
            qMultiply = g.multiply(k);
        }
        long endTime = System.currentTimeMillis();

        double avgDuration = (double) (endTime - startTime) / NUM_ROUNDS;
        System.out.println(curveName);
        System.out.print("Millis   : ");
        System.out.println(avgDuration);
        System.out.println();
    }

    public void testMultiply() throws Exception
    {
        randMult("sect163r2");
        randMult("sect233r1");
        randMult("sect283r1");
        randMult("sect409r1");
        randMult("sect571r1");
        randMult("secp224r1");
        randMult("secp256r1");
        randMult("secp521r1");
    }

    // public static void main(String argv[]) throws Exception
    // {
    // ECMultiplyPerformanceTest test = new ECMultiplyPerformanceTest();
    // test.testMultiply();
    // }
}

@@ -1448,164 +1448,381 @@
 t163
-r2%22);%0A        randMult(%22sect233r1%22);%0A        randMult(%22sect283r1%22);%0A        randMult(%22sect409r1%22);%0A        randMult(%22sect571r1%22);%0A        randMult(%22secp224r
+k1%22);%0A        randMult(%22sect163r2%22);%0A        randMult(%22sect233k1%22);%0A        randMult(%22sect233r1%22);%0A        randMult(%22sect283k1%22);%0A        randMult(%22sect283r1%22);%0A        randMult(%22sect409k1%22);%0A        randMult(%22sect409r1%22);%0A        randMult(%22sect571k1%22);%0A        randMult(%22sect571r1%22);%0A        randMult(%22secp224k1%22);%0A        randMult(%22secp224r1%22);%0A        randMult(%22secp256k
 1%22);

Add a few koblitz curves to performance test