swift-libp2p / swift-libp2p-crypto

Core LibP2P cryptography API for commonly used Keys, Hashes and Ciphers
2 stars 2 forks source link

Linux build #2

Closed btoms20 closed 2 years ago

btoms20 commented 2 years ago

Rewrite this package using only swift-crypto (and maybe CryptoSwift) so that we can build it on linux. This involves moving away from SecKeys, CommonCrypto and a few other changes.

btoms20 commented 2 years ago

The swiftcrypto branch is currently at feature parity with the main branch using just Swift-Crytpo (for Ed25519 keys) and CryptoSwift (for RSA keys).

The only feature we don't support yet is the marshaling of a private RSA key. CryptoSwift doesn't provide us access to the primes (p, q) used to generate the private exponent and we need these in order to generate a spec compliant DER encoding of the private key.

Also RSA key gen in CryptoSwift is slow, using the release build, a 2048 bit RSA key can take ~15 seconds to generate. So it's recommended to use Ed25519 keys whenever possible while on Linux.

Most importantly though, we can un-marshal RSA pub keys of any length and verify signatures fairly performantly. 👍

btoms20 commented 2 years ago

The code from the swiftcrypto branch was used in the rewrite branch that was just merged into main (#3)!

The main branch now compiles and passes tests on both macOS and linux platforms 🥳