komputing / KEthereum

Kotlin library for Ethereum
MIT License
350 stars 73 forks source link

[fix] NoSuchAlgorithmException for old Android version #39

Closed klblk closed 6 years ago

klblk commented 6 years ago

Algorithm "PBKDF2withHmacSHA512" work only Android 8+ (api 26+): https://developer.android.com/reference/javax/crypto/SecretKeyFactory

Change "toSeed()" method for MnemonicWords use functions from org.spongycastle.crypto.

Old tests performed.

ligi commented 6 years ago

Interestingly it also seems to work on some older devices - e.g. a nexus 7 that runs my UI test runs on 5.1.1 passes the UI tests that calculate an address from mnemonics - but could just verify this problem on another device and this fix is great anyway - thanks!

mirceanis commented 6 years ago

This might have something to do with initialization of the spongy castle provider.

Some tests may pass on older droids if the provider is already added by another test

ligi commented 6 years ago

@mirceanis ah thanks - that makes sense! Btw.: sorry for changing the API a bit more recently - will try to stabilize the API and before KotlinKonf (will do a talk there)

mirceanis commented 6 years ago

No problem, thanks for all the great work!

On Mon, Aug 20, 2018, 18:57 ligi notifications@github.com wrote:

@mirceanis https://github.com/mirceanis ah thanks - that makes sense! Btw.: sorry for changing the API a bit more recently - will try to stabilize the API and before KotlinKonf (will do a talk there)

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/walleth/kethereum/pull/39#issuecomment-414368907, or mute the thread https://github.com/notifications/unsubscribe-auth/AA68gjGPbvvQ4ZWNXvoofVblkEneYTqrks5uStyBgaJpZM4WDyIQ .