ChainSafe / js-libp2p-noise

Noise libp2p handshake for js-libp2p
Other
37 stars 30 forks source link

fix: use node.js crypto for x25519 keys #389

Closed achingbrain closed 11 months ago

achingbrain commented 11 months ago

Using node crypto to do X25519 key operations instead of @noble/curves yields a nice little performance bump which translates to ever so slightly lower latencies when opening connections.

image

Running the ./benchmarks/benchmark.js file shows a 2x improvement:

Before:

% node ./benchmark.js
Initializing handshake benchmark
Init complete, running benchmark
handshake x 124 ops/sec ±0.47% (84 runs sampled)

After:

% node ./benchmark.js
Initializing handshake benchmark
Init complete, running benchmark
handshake x 314 ops/sec ±0.99% (87 runs sampled)

Flamegraphs (same scale)

Before:

image

After:

image