# JSBN vs SJCL ECC

## JavaScript performance comparison

Revision 7 of this test case created

## Info

Comparison of ECC performance between JSBN and SJCL

## Preparation code

``<script src="http://www-cs-students.stanford.edu/~tjw/jsbn/jsbn.js"></script><script src="http://www-cs-students.stanford.edu/~tjw/jsbn/jsbn2.js"></script><script src="http://www-cs-students.stanford.edu/~tjw/jsbn/prng4.js"></script><script src="http://www-cs-students.stanford.edu/~tjw/jsbn/rng.js"></script><script src="http://www-cs-students.stanford.edu/~tjw/jsbn/ec.js"></script><script src="http://www-cs-students.stanford.edu/~tjw/jsbn/sec.js"></script><script src="https://rawgithub.com/bitwiseshiftleft/sjcl/master/sjcl.js"></script><script src="https://rawgithub.com/bitwiseshiftleft/sjcl/master/core/bn.js"></script><script src="https://rawgithub.com/bitwiseshiftleft/sjcl/master/core/ecc.js"></script><script>  Benchmark.prototype.setup = function() {    function secp256k1() {        // p = 2^256 - 2^32 - 2^9 - 2^8 - 2^7 - 2^6 - 2^4 - 1        var p = fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F");        var a = BigInteger.ZERO;        var b = fromHex("7");        //byte[] S = null;        var n = fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141");        var h = BigInteger.ONE;        var curve = new ECCurveFp(p, a, b);        var G = curve.decodePointHex("04"                    + "79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798"                    + "483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8");        return new X9ECParameters(curve, G, n, h);    }        var ecparams = secp256k1()    var rng = new SecureRandom();    var n = ecparams.getN();    var n1 = n.subtract(BigInteger.ONE);    var G = ecparams.getG();        // Overwrite NIST-P256 with secp256k1 so we're on even footing    sjcl.ecc.curves.c256 = new sjcl.ecc.curve(        sjcl.bn.pseudoMersennePrime(256, [[0,-1],[4,-1],[6,-1],[7,-1],[8,-1],[9,-1],[32,-1]]),        "0x14551231950b75fc4402da1722fc9baee",        0,        7,        "0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",        "0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"    );  };</script>``

## Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
JSBN
``var r = new BigInteger(n.bitLength(), rng);var privateKey = r.mod(n1).add(BigInteger.ONE);// Generate public keyvar publicPoint = G.multiply(privateKey);``
pending…
SJCL
``var keys = sjcl.ecc.ecdsa.generateKeys(256,0);``
pending…

## Revisions

You can edit these tests or add even more tests to this page by appending `/edit` to the URL. Here’s a list of current revisions for this page:

• Revision 2: published by justmoon
• Revision 3: published by justmoon
• Revision 4: published by justmoon and last updated
• Revision 5: published by justmoon
• Revision 6: published
• Revision 7: published
• Revision 8: published by Fedor Indutny
• Revision 9: published
• Revision 10: published by Ivan Fraixedes
• Revision 12: published by Fedor Indutny
• Revision 13: published by Fedor Indutny
• Revision 14: published by Fedor Indutny
• Revision 15: published by Fedor Indutny
• Revision 16: published by Fedor Indutny
• Revision 17: published
• Revision 18: published
• Revision 19: published
• Revision 20: published by Fedor
• Revision 21: published by Calvin Metcalf
• Revision 22: published by Fedor
• Revision 23: published by Fedor
• Revision 24: published by Fedor Indutny
• Revision 25: published by Vyacheslav Egorov
• Revision 26: published by Edwin

# 0 comments

Comment form temporarily disabled.