KEthereum icon indicating copy to clipboard operation
KEthereum copied to clipboard

Crypto API Multiplatform

Open RiccardoM opened this issue 5 years ago • 1 comments

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.

RiccardoM avatar Mar 11 '19 06:03 RiccardoM

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

ligi avatar Mar 11 '19 08:03 ligi