ChainSafe / discv5

A Typescript implementation of the Discv5 protocol
Apache License 2.0
28 stars 15 forks source link

Reconcile Milagro Crypto with Libp2p Crypto #21

Closed Mikerah closed 5 years ago

Mikerah commented 5 years ago

At the moment, mainly milagro-crypto code is used since the libp2p crypto libraries don't contain everything that discv5 needs. There are some things that can be done to reconcile this:

  1. Make some PRs into various libp2p crypto libraries to add this needed functionality. The problem with this is that the libp2p crypto libraries are specific to libp2p and we would be adding bloat to their codebases.
  2. Fork the libp2p crypto repo and add the needed functionality. It would be similar to us maintaining our own incubator-milagro-crypto fork.
  3. Hack around both libraries with wrappers and such.

I'm currently leaning towards 2 and 3 since we need milagro-crypto and there's no other way to get around using libp2p specific modules for some stuff.

Mikerah commented 5 years ago

After a little bit more of searching, I may be able to remove the milagro-crypto dependency and simply fork the libp2p crypto repos and make amendments. All the libp2p crypto repos use the default crypto library provided by Node.js and uses openSSL for a lot of what we need. It also has browser version to make some crypto available in the browser. The only thing it seems to be missing is the right key derivation function, which I needed to implement anyway.

Mikerah commented 5 years ago

This is done in https://github.com/ChainSafe/js-libp2p-crypto/pull/2