komputing / KEthereum

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

NoSuchMethodError for ECKeyPair.getPrivateKey #94

Closed Vergil333 closed 4 years ago

Vergil333 commented 4 years ago

Hello everyone,

I'm not able to get a private key from ECKeyPair. Error: java.lang.NoSuchMethodError: 'java.math.BigInteger org.kethereum.model.ECKeyPair.getPrivateKey-V6oYYD4()'

Test to replicate an error:

const val MNEMONIC =
    "awesome cost donate hub tank infant sheriff member awake spice all warrior pen column east"
const val EXPECTED_PRIVATE_KEY = "0x0cfa57cd6d2c2a950727f01f4131049b8cc43db20cd7fd4609ca183998f64d6e"

internal class PrivateKeyTest {
    @Test
    @ExperimentalStdlibApi
    fun `mnemonic to private key`() {
        val seed = MnemonicWords(MNEMONIC).toSeed()
        val ecKeyPair = seed
            .toKey("m/44'/1'/0'/0")
            .generateChildKey(BIP44Element(false, 0))
            .keyPair
        val prvKey = ecKeyPair.privateKey.key.toHexString()

        Assertions.assertThat(prvKey).isEqualTo(EXPECTED_PRIVATE_KEY)
    }
}

When I manually copied all the necessary code from KEthereum (550 lines of code), I had no error (but hex string did not match, "0xcfa..." instead of "0x0cfa...").

ligi commented 4 years ago

can you show me your gradle file?

Vergil333 commented 4 years ago

Hi ligi, I'm using Maven's pom.xml file. The issue is that I was installing all the komputing dependencies manually with mvn. It's strange. Now I added jitpack.io repository and I left the maven to download repositories by itself and the issue is gone. Sorry for trouble.

ligi commented 4 years ago

thanks for the update - if there is anything in KEthereum I should change to address the issue LMK