komputing / KEthereum

Kotlin library for Ethereum
MIT License
345 stars 72 forks source link

Crypto API Multiplatform #61

Open RiccardoM opened 5 years ago

RiccardoM commented 5 years ago

Currently inside the crypto_api package we find the following piece of code:

fun <T> loadClass(name: String): T = try {
    @Suppress("UNCHECKED_CAST")
    Class.forName("org.kethereum.crypto.impl.$name").newInstance() as T
} catch (e: ClassNotFoundException) {
    throw RuntimeException("There is not implementation found for $name - you need to either depend on crypto_impl_spongycastle or crypto_impl_bouncycastle")
}

While this works for JVM based project, I am not sure it will work on multiplatform projects too.

I think, but I might be wrong, that we could replace the loadClass method with the actual/expected mechanism allowing this library to be used inside multiplatform projects too.

ligi commented 5 years ago

That's a good point. Would totally accept a PR with this change.