elliptic.js vs emscripten-libsecp256k1.js (v25)

Revision 25 of this benchmark created by Vyacheslav Egorov on


Description

Comparison of ECC performance between Elliptic.JS and Emscripten-libsecp256k1

Preparation HTML

<script src="https://cdn.rawgit.com/indutny/elliptic/v3.0.2/dist/elliptic.min.js"></script>
<script src="https://cdn.rawgit.com/indutny/063d124faa2b38fe5e5d/raw/ba94a287f79a68418c4aa2a44a0bdd66eaa4372c/secp256k1.js"></script>

Setup

var ellipticEcdsa = new ellipticjs.ec('secp256k1');
    var em = Module;
    
    em._secp256k1_start(3);
    
    // Honestly saying this could happen in benchmark function itself,
    // but let's assume that user app could cache it somehow
    var out = em._malloc(128);
    var out_s = em._malloc(4);
    var secexp = em._malloc(32);

Teardown


    em._free(out);
    em._free(out_s);
    em._free(secexp);
  

Test runner

Ready to run.

Testing in
TestOps/sec
Elliptic.js
var pub = ellipticEcdsa.genKeyPair().getPublic();
ready
libsecp256k1
// "Generate" pseudo-random number
var sec = [
  0xde, 0xad, 0xbe, 0xef, 0xab, 0xba, 0xde, 0xad,
  0xde, 0xad, 0xbe, 0xef, 0xab, 0xba, 0xde, 0xad,
  0xde, 0xad, 0xbe, 0xef, 0xab, 0xba, 0xde, 0xad,
  0xde, 0xad, 0xbe, 0xef, 0xab, 0xba, 0xde, 0xad,
];
em.writeArrayToMemory(sec, secexp);

var pub = em._secp256k1_ec_pubkey_create(out, out_s, secexp, 1);
 
ready
libsecp256k1 (no caching)
var out_1 = em._malloc(128);
var out_s_1 = em._malloc(4);
var secexp_1 = em._malloc(32);

// "Generate" pseudo-random number
var sec = [
  0xde, 0xad, 0xbe, 0xef, 0xab, 0xba, 0xde, 0xad,
  0xde, 0xad, 0xbe, 0xef, 0xab, 0xba, 0xde, 0xad,
  0xde, 0xad, 0xbe, 0xef, 0xab, 0xba, 0xde, 0xad,
  0xde, 0xad, 0xbe, 0xef, 0xab, 0xba, 0xde, 0xad,
];
em.writeArrayToMemory(sec, secexp_1);

var pub = em._secp256k1_ec_pubkey_create(out_1, out_s_1, secexp_1, 1);

em._free(out_1);
em._free(out_s_1);
em._free(secexp_1);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.