Giter Site home page Giter Site logo

kethereum's Introduction

Mission statement

This is a Kotlin library for Ethereum. It is striving towards being 100% Kotlin (the code in the lib is Kotlin anyway - but also trying to not drag in JVM dependencies). This is done in order to enable multi-platform support in the future. Currently this library is mainly used in JVM projects but could this way also target e.g. JavaScript and WebAssembly that are broadly used in the web3 space. Another core principle of this library is to be as modular as possible. Ethereum has a wide range of use-cases and should not be supported by huge monolithic libraries. With KEthereum you can pick and choose the modules you need and keep the footprint of the library small this way.

Module overview

Name Description Status Documentation
abi Application Binary Interface (ABI) for contracts beta
abi_codegen Kotlin code generation from ABIs beta
abi_filter Functions for filtering ABIs beta
blockscout BlockScout BlockExplorer helper functions beta
bloomfilter Space-efficient probabilistic data structure beta
eip137 Model and functions for ENS NameHash beta
eip155 TX signing with Simple replay attack protection production example code
eip191 Functions to sign data via signed data standard beta
eip712 Ethereum typed structured data hashing and signing experimental
ens ENS (Ethereum Name Service) functionality beta README
erc1328 WalletConnect Standard URI Format beta
erc1450 ERC-20 extension - e.g. including token minting beta example code
erc181 ENS reverse resolution of addresses beta
erc20 Contract wrapper for the ERC20 Token standard beta
erc55 Mixed-case checksum address encoding production README
erc634 Storage of text records in ENS beta README
erc67 Standard URI scheme for transactions beta
erc681 URL Format for Transaction Requests (successor of ERC67) beta
erc831 URI Format for Ethereum (used by 681, 961, ..) beta
erc961 URI standard for tokens beta
etherscan EtherScan BlockExplorer function beta
example_cli CLI App to demo KEthereum functionality demonstration example code
extensions_kotlin Extension functions for Kotlin types beta
extensions_transactions Extension functions for the Transaction class beta
flows Coroutine flows for blocks and transactions beta example code
keccak_shortcut Proxy extension function for keccak hashing beta
keystore Storage for wallet files (e.g. to use the geth keystore) beta
metadata Model and parser for contract metadata beta
method_signatures Functionality for method signatures (4byte repository,..) beta
model Data-/Inline-Classes and constants beta
rlp Recursive Length Prefix (RLP) encoder/decoder beta
rpc Remote Procedure Calls (RPC) abstraction beta
rpc_min3 Minimal INCUBED (IN3) RPC experimental README
test_data Data used in KEthereum tests production -
types Handling of EVM types (e.g. used code from abi_codegen ) beta
uri_common Used by several URI modules (681, 1328, 961, ..) beta
wallet functions for keys from and to JSON wallet files beta

Projects that use KEthereum

Links

Get it

KEthereum is available via jitpack:

License

MIT

kethereum's People

Contributors

abhimanyu121 avatar ackintosh avatar atarasenko avatar bigman212 avatar dependabot[bot] avatar ensbot avatar friedger avatar fullkomnun avatar jolestar avatar klblk avatar krisbitney avatar ligi avatar mahdi13 avatar mirceanis avatar petertheone avatar riccardom avatar rmeissner avatar vchernetskyi993 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kethereum's Issues

'generateWalletFile()' crash on Android

Simple code:

val mnemonic = Mnemonic.generateMnemonic()
val password = "qweasdzxc"
val extendedKey = Mnemonic.mnemonicToKey(mnemonic, "m/44'/60'/0'/0", password)
val keyPair = extendedKey.keyPair;
keyPair.generateWalletFile(password, filesDir, LIGHT_SCRYPT_CONFIG)

Crash log:

java.lang.VerifyError: Rejecting class org.kethereum.wallet.model.KdfSerializer because it failed compile-time verification (declaration of 'org.kethereum.wallet.model.KdfSerializer' appears in /data/app/package.name-1/base.apk:classes3.dex)
        at org.kethereum.wallet.model.WalletCrypto.write$Self(Wallet.kt)
        at org.kethereum.wallet.model.WalletCrypto$$serializer.save(Wallet.kt)
        at org.kethereum.wallet.model.WalletCrypto$$serializer.save(Wallet.kt:15)
        at kotlinx.serialization.KOutput.writeSerializableValue(Serialization.kt:146)
        at kotlinx.serialization.KOutput.writeSerializableElementValue(Serialization.kt:191)
        at org.kethereum.wallet.model.Wallet.write$Self(Wallet.kt)
        at org.kethereum.wallet.model.Wallet$$serializer.save(Wallet.kt)
        at org.kethereum.wallet.model.Wallet$$serializer.save(Wallet.kt:53)
        at kotlinx.serialization.KOutput.write(Serialization.kt:99)
        at kotlinx.serialization.json.JSON.stringify(JSON.kt:40)
        at kotlinx.serialization.json.JSON$Companion.stringify(JSON.kt:57)
        at org.kethereum.wallet.WalletFileKt.generateWalletFile(WalletFile.kt:30)

Implement RIPEMD160

Or find a pure Kotlin implementation. This is a step towards #1

This is a good starting-point:

Bounty acceptance criteria:

Motivation:

  • RIPEMD160 is used in BIP32 and so important for the MNEMONIC code
  • Moving it from Java to Kotlin opens up the possibility to use it in multi platform projects and remove some chains that tie us to the JVM

Accepts ERC-67 with a malformed URL

Follow up from #4 :
I think the problem of the user came from a malformed URL as tests showed that parsing ERC-67 that contains gas works
I could reproduce the problem with a malformed URL that looks like this:
ethereum:0xabc?value=100000000?gas=2030000000000000000

then in WALLETH the gas-value from is taken as value as described here:
https://www.reddit.com/r/ethereum/comments/78wj3s/erc67_support_by_ethereum_wallet_providers_so/

Fix is to detect ERC-67 as invalid when gas or value are not plain numbers

use KHash instead of `org.walleth.sha3`

KHash provides implementations for some (if not all) of the hashing methods needed by KEthereum.
Dependencies on any legacy hashing methods should be replaced with KHash.

Using KHash in combination with KEthereum in the same project can create duplicate class conflicts with the current latest versions (0.8 & 0.75.0)

If there is a reason for not using KHash (yet) of which I am unaware, please comment and close this issue.

Decouple/Replace SpongyCastle

Ideally SpongyCastle should be gone completely to allow multi-platform use cases in the future and work towards #1 . But I did not yet find a replacement library in Kotlin for it. I think it might be possible to extract and convert the needed functions from SpongyCastle - but this needs to be audited. So it also needs to be decoupled. This way users can stick to the well-tried SpongyCastle until the replacement gained trust.

acceptance criteria:

  • option to not use spongycastle anymore (replace with plain kotlin alternative - goal is to get rid of JVM dependency)
  • initializeCrypto() is gone there also ;-)

Better spongyCastle initialisation / decoupling

This is a follow-up for: #21

There are now multiple of these blocks in kethereum:

    init {
        Security.insertProviderAt(org.spongycastle.jce.provider.BouncyCastleProvider(), 1)
    }

I would really like a cleaner way of initializing spongyCastle - and ideally a decoupling from sponygCastle from kethereum so it can also be used with bouncyCastle in a JVM context where the whole spongyCastle is not needed.

One Idea:

  • create a kethereum-android module that has to be included when using kethereum in combination with Android
  • inside this module there is a content-provider that initializes spongyCastle

@mirceanis what do you think?

Have to set lenient on JsonReader for RPC

I am trying to connect to a basic auth web3 node. If basic auth fails, it returns back non-json text to say that you're not authenticated..
You have to set leninet = true for moshi to be able to return this text back without the client failing. Or perhaps check if it's json, if not jsonify it before handing it to moshi?

Caused by: com.squareup.moshi.JsonEncodingException: Use JsonReader.setLenient(true) to accept malformed JSON at path $
	at com.squareup.moshi.JsonReader.syntaxError(JsonReader.java:220)
	at com.squareup.moshi.JsonUtf8Reader.checkLenient(JsonUtf8Reader.java:1031)
	at com.squareup.moshi.JsonUtf8Reader.doPeek(JsonUtf8Reader.java:344)
	at com.squareup.moshi.JsonUtf8Reader.peek(JsonUtf8Reader.java:171)
	at com.squareup.moshi.JsonAdapter$2.fromJson(JsonAdapter.java:134)
	at com.squareup.moshi.JsonAdapter.fromJson(JsonAdapter.java:36)
	at org.kethereum.rpc.EthereumRPC.getBlockNumberString(EthereumRPC.kt:34)

Inline classess when switching to 1.3

Kotlin 1.3 is around the corner - when we switch to 1.3 the following classes should be declared inline:

  • MnemonicWords in MnemonicWords.kt
  • PrivateKey in ECKeyPair
  • PublicKey in ECKeyPair
  • XPriv bip32.model
  • Seed bip32.model
  • EthereumABI
  • TextMethodSignature
  • HexMethodSignature

also remove the equals/toString/hashCode from there then

ERC-681

At DevCon3 we finally have consensus on ERC-681 (ethereum/EIPs#681 (comment)) - so now we need implementations of it - at least 2 to get this thing merged. Also do not forget to ping @nagydani after implementing so he can do the interoperability test (plan so far MyEtherWallet<>WALLETH) which is the condition to get this EIP merged.

Modular approach to signing

Currently the only signing method exposed is:
fun signMessage(message: ByteArray, keyPair: ECKeyPair): SignatureData
which hashes the message using keccak and then signs the hash using the given keyPair. The signature is then canonicalized.
This method is suitable for ETH signing but that's about it.

A given set of keys can be used to sign other types of signatures and it makes sense to me to allow customization of the hashing method and canonicalization.

I propose exposing an extra signing method to allow other signing algorithms to be used.

Program type already present: org.kethereum.crypto.impl.ec.EllipticCurve

Description

While try running some instrumented tests (or running the application), I run into an exception during the build.

I'm trying running the application on a Nexus 5 API 28 image without Google Play Services.

Reproduce

  1. Start a fresh new Android Studio project
  2. Include Kethereum as an implementation dependency
  3. Try starting the application

Solutions tried

  • Re-starting the project
  • Invalidating the cache and restarting Android Studio

Project build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.3.11'
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url 'https://jitpack.io' }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Module build.gradle

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "it.riccardomontagnin.playground"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'

    implementation 'com.github.walleth:kethereum:0.71.4'

    testImplementation 'junit:junit:4.12'

    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

Attached build logs

> Task :app:mergeDebugAssets UP-TO-DATE
AGPBI: {"kind":"error","text":"Program type already present: org.kethereum.crypto.impl.ec.EllipticCurve","sources":[{}],"tool":"D8"}

> Task :app:mergeExtDexDebug FAILED
java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: 
Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
Program type already present: org.kethereum.crypto.impl.ec.EllipticCurve
  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
  at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
  at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
  at java.util.concurrent.ForkJoinTask.getThrowableException(ForkJoinTask.java:593)
  at java.util.concurrent.ForkJoinTask.reportException(ForkJoinTask.java:677)
  at java.util.concurrent.ForkJoinTask.join(ForkJoinTask.java:720)
  at com.android.build.gradle.internal.tasks.DexMergingTaskDelegate.run(DexMergingTask.kt:316)
  at com.android.build.gradle.internal.tasks.DexMergingTask.taskAction(DexMergingTask.kt:132)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:498)
  at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
  at org.gradle.api.internal.project.taskfactory.StandardTaskAction.doExecute(StandardTaskAction.java:46)
  at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
  at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
  at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:801)
  at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:768)
  at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:131)
  at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:300)
  at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:292)
  at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:174)
  at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
  at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
  at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:120)
  at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:99)
  at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:77)
  at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
  at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:59)
  at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
  at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:59)
  at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:101)
  at org.gradle.api.internal.tasks.execution.FinalizeInputFilePropertiesTaskExecuter.execute(FinalizeInputFilePropertiesTaskExecuter.java:44)
  at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:91)
  at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:62)
  at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:59)
  at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
  at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
  at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
  at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.run(EventFiringTaskExecuter.java:51)
  at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:300)
  at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:292)
  at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:174)
  at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
  at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
  at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:46)
  at org.gradle.execution.taskgraph.LocalTaskInfoExecutor.execute(LocalTaskInfoExecutor.java:42)
  at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareWorkItemExecutor.execute(DefaultTaskExecutionGraph.java:277)
  at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareWorkItemExecutor.execute(DefaultTaskExecutionGraph.java:262)
  at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:135)
  at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:130)
  at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.execute(DefaultTaskPlanExecutor.java:200)
  at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.executeWithWork(DefaultTaskPlanExecutor.java:191)
  at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.run(DefaultTaskPlanExecutor.java:130)
  at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
  at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
  at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
  at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: 
Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
Program type already present: org.kethereum.crypto.impl.ec.EllipticCurve
  at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1431)
  at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
  at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
  at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
  at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
Caused by: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: 
Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
Program type already present: org.kethereum.crypto.impl.ec.EllipticCurve
  at com.android.builder.dexing.D8DexArchiveMerger.getExceptionToRethrow(D8DexArchiveMerger.java:131)
  at com.android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger.java:118)
  at com.android.build.gradle.internal.transforms.DexMergerTransformCallable.call(DexMergerTransformCallable.java:102)
  at com.android.build.gradle.internal.transforms.DexMergerTransformCallable.call(DexMergerTransformCallable.java:37)
  at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424)
  ... 4 more
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete
  at com.android.tools.r8.utils.ExceptionUtils.withCompilationHandler(ExceptionUtils.java:70)
  at com.android.tools.r8.utils.ExceptionUtils.withD8CompilationHandler(ExceptionUtils.java:43)
  at com.android.tools.r8.D8.run(D8.java:94)
  at com.android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger.java:116)
  ... 7 more
Caused by: com.android.tools.r8.utils.AbortException: Error: Program type already present: org.kethereum.crypto.impl.ec.EllipticCurve
  at com.android.tools.r8.utils.Reporter.failIfPendingErrors(Reporter.java:89)
  at com.android.tools.r8.utils.Reporter.fatalError(Reporter.java:60)
  at com.android.tools.r8.utils.ExceptionUtils.withCompilationHandler(ExceptionUtils.java:64)
  ... 10 more


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeExtDexDebug'.
> com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: 
  Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
  Program type already present: org.kethereum.crypto.impl.ec.EllipticCurve

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 3s
18 actionable tasks: 1 executed, 17 up-to-date

BigInteger RLP bug

@Test
    fun testBigIntRLP() {
        val bigInt = BigInteger.valueOf(54408193066555392L)
        val rlp = bigInt.toRLP()
        println(rlp.bytes.size)
        val bitInt1 = rlp.toBigIntegerFromRLP()
        Assert.assertEquals(bigInt, bitInt1)
}
7

java.lang.AssertionError: 
Expected :54408193066555392
Actual   :-17649400971372544

same as #49

Investigate building a JavaScript library

Not yet sure what a good project structure for this can be - ideally someone javascript-affine has a look here - I would love the reuse of code - but I am not really a javascript kinda guy..

Testnet support in bip32

internal val xprv = byteArrayOf(0x04, 0x88.toByte(), 0xAD.toByte(), 0xE4.toByte())

The Testnet network could be supported in bip32's ExtendedKey deserialization:

internal val xprvTestnet = byteArrayOf(0x04, 0x88.toByte(), 0xAD.toByte(), 0xE4.toByte())
internal val xpubTestnet = byteArrayOf(0x04, 0x35.toByte(), 0x87.toByte(), 0xCF.toByte())

And it could be considered in XPriv.toExtendedKey() method:

    val hasPrivate = when {
        Arrays.equals(type, xprv) -> true
        Arrays.equals(type, xprvTestnet) -> true
        Arrays.equals(type, xpub) -> false
        Arrays.equals(type, xpubTestnet) -> false
        else -> throw KeyException("invalid magic number for an extended key")
    }

Crypto API Multiplatform

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.

Mnemonics require provider for PBKDF2withHmacSHA512

Calling Mnemonic methods on android in a project that does not use Keys ends up crashing because of a missing provider for PBKDF2withHmacSHA512

I guess the tests for bip39 run on JVM pass because the JVM provider stack probably already contains one for that key derivation function.

RLP encode and decode zero bytes bug

@Test
    val zeroBytes = ByteArray(1){0.toByte()}
        val rlp = zeroBytes.toRLP()
        val bytes = rlp.encode()
        val rlp1 = bytes.decodeRLP()
        Assert.assertEquals(rlp, rlp1)
java.lang.AssertionError: expected:<RLPElement(bytes=[0])> but was:<RLPElement(bytes=[])>
Expected :RLPElement(bytes=[0])
Actual   :RLPElement(bytes=[])

Remove all java-dependencies

This is more a long-term goal. But it would be nice to get rid of java-dependencies to use Kotlin-Native and compile to WASM/JS/..

Breakdown of this meta-issue in smaller issues:

  • RIPEMD160 #33
  • SHA-2 / SHA-256 #34
  • Replace Moshi with Kotlinx serializing #31
  • SpongyCastle #44
  • TODO - Identify more java dependencies

trie module

Perhaps you can recommend a jvm implementation apart from the one in Pantheon?

int to RLP mismatching with RLP to int

import org.kethereum.functions.rlp.toIntFromRLP
import org.kethereum.functions.rlp.toRLP

class RLPTest{

    @Test
    fun testIntRLP(){
        val int = 1838383984
        val rlp = int.toRLP()
        println(rlp.bytes.size)
        val int1 = rlp.toIntFromRLP()
        Assert.assertEquals(int, int1)
    }
}

output:

4

java.lang.AssertionError: 
Expected :1838383984
Actual   :1821541232

Multiplatform setup

Currently the project heavily depends on some methods that are available only on the JVM platform.

For example, we can see the usage of System.arrayCopy method used in a lot of places, as well as String.toCharArray and other JVM-only methods.

I think it would be great to set up the whole project to ne multiplatform ready, allowing us to delegate the implementation of such methods inside the proper JVM/JS/native modules.

The problem is: I don't know which organization would be the best. Having all those small modules, how should be proceed into this?

Working on this would make #61 easier

KotlinX Knit documentation configuration

Acceptance criteria:

  • overview of all modules with short description of each
  • scaffold for documentation of all modules
  • user sees which classes/functions belong to which module
  • a example cross-reference between modules
  • can be a github page e.g. ktehereum.walleth.org
  • IPFS deployment pipeline
  • prepare kotlin-playground integration

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.