Skip to content

Commit

Permalink
Merge branch 'release/0.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
mirceanis committed Aug 30, 2019
2 parents 08aa465 + 85aa071 commit b94cab9
Show file tree
Hide file tree
Showing 13 changed files with 104 additions and 111 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
* 0.2.0
* update to kethereum 0.76.1 [#5](https://github.com/uport-project/kotlin-common/pull/5)
* [breaking] isolate implementation details for each module (#5)
* may require adjusting imports
* removed all direct references to java classes in production code (#5)

* 0.1.2
* maintenance - add test coverage

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ allprojects {
In your module `build.gradle` file, add:

```groovy
def uport_kotlin_common_version = "0.1.2"
def uport_kotlin_common_version = "0.2.0"
dependencies {
//...
// core lib
Expand Down
13 changes: 7 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
buildscript {

ext {
kotlin_version = '1.3.41'
kotlin_serialization_version = '0.11.1'
coroutines_version = "1.2.2"
kotlin_version = '1.3.50'
kotlin_serialization_version = '0.12.0'
coroutines_version = "1.3.0"

junit_version = "4.12"
mockk_version = "1.9.3"
Expand All @@ -17,10 +17,11 @@ buildscript {
okhttp_version = "3.14.1"

spongycastle_version = "1.58.0.0"
kmnid_version = "0.3.2"
kethereum_version = "0.75.1"
kmnid_version = "0.4.0"
kethereum_version = "0.76.1"
khex_version = "1.0.0-RC3"

current_release_version = "0.1.2"
current_release_version = "0.2.0"
}

repositories {
Expand Down
11 changes: 2 additions & 9 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,13 @@ apply plugin: "com.jfrog.bintray"

project.ext.description = "core class definitions of the uPort kotlin SDK"

//XXX: this is needed until https://github.com/komputing/KEthereum/issues/65 is fixed
configurations.all {
exclude group: "com.github.walleth"
}

dependencies {

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"

api "com.squareup.okhttp3:okhttp:$okhttp_version"
api "com.github.uport-project:kmnid:$kmnid_version"
api "com.github.komputing.KEthereum:functions:$kethereum_version"
api "com.github.komputing.KEthereum:crypto:$kethereum_version"
implementation "com.squareup.okhttp3:okhttp:$okhttp_version"
implementation "com.github.komputing.KHex:extensions-jvm:$khex_version"
implementation "com.madgag.spongycastle:core:$spongycastle_version"

testImplementation "junit:junit:$junit_version"
Expand Down
17 changes: 10 additions & 7 deletions core/src/main/java/me/uport/sdk/core/Networks.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

package me.uport.sdk.core

import me.uport.mnid.MNID
import org.walleth.khex.clean0xPrefix
import org.walleth.khex.prepend0xPrefix
import org.komputing.khex.extensions.clean0xPrefix
import org.komputing.khex.extensions.prepend0xPrefix

/**
* Convenience singleton that holds URLs and addresses for different eth networks.
Expand All @@ -31,7 +30,8 @@ object Networks {
rpcUrl = "https://mainnet.infura.io/v3/e72b472993ff46d3b5b88faa47214d7f",
ethrDidRegistry = DEFAULT_ERC1056_REGISTRY,
explorerUrl = "https://etherscan.io",
uPortRegistry = MNID.encode(mainnetId, "0xab5c8051b9a1df1aab0149f8b0630848b7ecabf6"),
// MNID.encode(mainnetId, "0xab5c8051b9a1df1aab0149f8b0630848b7ecabf6"),
uPortRegistry = "2ngV6QowStW3ebKXYUhy43wCqeLXcuTfHj2",
faucetUrl = defaultFaucetUrl,
relayUrl = defaultTxRelayUrl,
txRelayAddress = "0xec2642cd5a47fd5cca2a8a280c3b5f88828aa578"
Expand All @@ -44,7 +44,8 @@ object Networks {
rpcUrl = "https://rinkeby.infura.io/v3/e72b472993ff46d3b5b88faa47214d7f",
ethrDidRegistry = DEFAULT_ERC1056_REGISTRY,
explorerUrl = "https://rinkeby.etherscan.io",
uPortRegistry = MNID.encode(rinkebyId, "0x2cc31912b2b0f3075a87b3640923d45a26cef3ee"),
//MNID.encode(rinkebyId, "0x2cc31912b2b0f3075a87b3640923d45a26cef3ee"),
uPortRegistry = "2ogxWTKKfy6kwfqdgdEE6GCdoFD4vm4YRZe",
faucetUrl = "https://api.uport.me/sensui/fund/",
relayUrl = "https://api.uport.me/sensui/relay/",
txRelayAddress = "0xda8c6dce9e9a85e6f9df7b09b2354da44cb48331"
Expand All @@ -57,7 +58,8 @@ object Networks {
rpcUrl = "https://ropsten.infura.io/v3/e72b472993ff46d3b5b88faa47214d7f",
ethrDidRegistry = DEFAULT_ERC1056_REGISTRY,
explorerUrl = "https://ropsten.etherscan.io",
uPortRegistry = MNID.encode(ropstenId, "0x41566e3a081f5032bdcad470adb797635ddfe1f0"),
//MNID.encode(ropstenId, "0x41566e3a081f5032bdcad470adb797635ddfe1f0"),
uPortRegistry = "2oKVhUttUcwaFAopRBGA21NDJoYcBb3a6iz",
faucetUrl = defaultFaucetUrl,
relayUrl = defaultTxRelayUrl,
txRelayAddress = "0xa5e04cf2942868f5a66b9f7db790b8ab662039d5"
Expand All @@ -70,7 +72,8 @@ object Networks {
rpcUrl = "https://kovan.infura.io/v3/e72b472993ff46d3b5b88faa47214d7f",
ethrDidRegistry = DEFAULT_ERC1056_REGISTRY,
explorerUrl = "https://kovan.etherscan.io",
uPortRegistry = MNID.encode(kovanId, "0x5f8e9351dc2d238fb878b6ae43aa740d62fc9758"),
//MNID.encode(kovanId, "0x5f8e9351dc2d238fb878b6ae43aa740d62fc9758"),
uPortRegistry = "354S1QuCzkmKoQ3ADSLp1KtqAe8gZ74F9am",
faucetUrl = defaultFaucetUrl,
relayUrl = defaultTxRelayUrl,
txRelayAddress = "0xa9235151d3afa7912e9091ab76a36cbabe219a0c"
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
13 changes: 3 additions & 10 deletions jsonrpc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,16 @@ compileKotlin {
}
}

//XXX: this is needed until https://github.com/komputing/KEthereum/issues/65 is fixed
configurations.all {
exclude group: "com.github.walleth"
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"

implementation "com.squareup.moshi:moshi-kotlin:$moshi_version"

api "com.github.komputing.KEthereum:model:$kethereum_version"
api "com.github.komputing.KEthereum:rlp:$kethereum_version"
api "com.github.komputing.KEthereum:functions:$kethereum_version"
api "com.github.komputing.KEthereum:extensions:$kethereum_version"
implementation "com.github.komputing.KEthereum:extensions:$kethereum_version"
implementation "com.github.komputing.KHex:extensions-jvm:$khex_version"

api project(":core")
implementation project(":core")

testImplementation "junit:junit:$junit_version"
testImplementation "com.willowtreeapps.assertk:assertk-jvm:$assertk_version"
Expand Down
2 changes: 1 addition & 1 deletion jsonrpc/src/main/java/me/uport/sdk/jsonrpc/JsonRPC.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import com.squareup.moshi.Types
import me.uport.sdk.core.HttpClient
import org.kethereum.extensions.hexToBigInteger
import org.kethereum.extensions.toHexStringNoPrefix
import org.walleth.khex.prepend0xPrefix
import org.komputing.khex.extensions.prepend0xPrefix
import java.io.IOException
import java.lang.reflect.ParameterizedType
import java.math.BigInteger
Expand Down
2 changes: 1 addition & 1 deletion jsonrpc/src/main/java/me/uport/sdk/jsonrpc/JsonRPCBase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import com.squareup.moshi.ToJson
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
import org.kethereum.extensions.maybeHexToBigInteger
import org.kethereum.extensions.toHexStringNoPrefix
import org.walleth.khex.prepend0xPrefix
import org.komputing.khex.extensions.prepend0xPrefix
import java.math.BigInteger


Expand Down
18 changes: 8 additions & 10 deletions signer-common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,20 @@ apply plugin: "com.jfrog.bintray"

project.ext.description = "Signer interface and default implementation for uPort kotlin SDK"

//XXX: this is needed until https://github.com/komputing/KEthereum/issues/65 is fixed
configurations.all {
exclude group: "com.github.walleth"
}

dependencies {

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"

api project(":core")
api "com.github.komputing.KEthereum:extensions:$kethereum_version"
api "com.github.komputing.KEthereum:model:$kethereum_version"
api "com.github.komputing.KEthereum:hashes:$kethereum_version"
implementation project(":core")
implementation "com.github.komputing.KHex:extensions-jvm:$khex_version"
implementation "com.github.komputing.KEthereum:extensions:$kethereum_version"
implementation "com.github.komputing.KEthereum:functions:$kethereum_version"
implementation "com.github.komputing.KEthereum:crypto:$kethereum_version"
implementation "com.github.komputing.KEthereum:model:$kethereum_version"
implementation "com.github.komputing.KEthereum:hashes:$kethereum_version"
implementation "com.madgag.spongycastle:core:$spongycastle_version"
api "com.github.komputing.KEthereum:crypto_impl_spongycastle:$kethereum_version"
implementation "com.github.komputing.KEthereum:crypto_impl_spongycastle:$kethereum_version"


testImplementation "junit:junit:$junit_version"
Expand Down
17 changes: 8 additions & 9 deletions signer-common/src/main/java/me/uport/sdk/signer/Extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,16 @@ import org.kethereum.extensions.toBigInteger
import org.kethereum.extensions.toBytesPadded
import org.kethereum.extensions.toHexStringNoPrefix
import org.kethereum.model.*
import org.komputing.khex.extensions.clean0xPrefix
import org.komputing.khex.extensions.prepend0xPrefix
import org.komputing.khex.extensions.toNoPrefixHexString
import org.spongycastle.asn1.ASN1EncodableVector
import org.spongycastle.asn1.ASN1Encoding
import org.spongycastle.asn1.ASN1Integer
import org.spongycastle.asn1.DERSequence
import org.walleth.khex.clean0xPrefix
import org.walleth.khex.prepend0xPrefix
import org.walleth.khex.toNoPrefixHexString
import java.io.ByteArrayOutputStream
import java.math.BigInteger
import java.nio.charset.Charset
import java.util.*


/**
* Converts a hex string to another hex string pre-padded with zeroes until it represents at least 32 bytes
Expand Down Expand Up @@ -89,7 +87,7 @@ fun SignatureData.getJoseEncoded(recoverable: Boolean = false): String {
bos.write(this.r.toBytesPadded(SIG_COMPONENT_SIZE))
bos.write(this.s.toBytesPadded(SIG_COMPONENT_SIZE))
if (recoverable) {
bos.write(byteArrayOf((this.v - 27).toByte()))
bos.write(byteArrayOf((this.v.toByte() - 27).toByte()))
}
return bos.toByteArray().toBase64UrlSafe()
}
Expand All @@ -105,20 +103,21 @@ fun String.decodeJose(recoveryParam: Byte = 27): SignatureData = this.decodeBase
* @param recoveryParam can be used in case the signature is non recoverable to be added as recovery byte
*/
fun ByteArray.decodeJose(recoveryParam: Byte = 27): SignatureData {
val rBytes = Arrays.copyOfRange(this, 0, SIG_COMPONENT_SIZE)
val sBytes = Arrays.copyOfRange(this, SIG_COMPONENT_SIZE, SIG_SIZE)
val rBytes = this.copyOfRange(0, SIG_COMPONENT_SIZE)
val sBytes = this.copyOfRange(SIG_COMPONENT_SIZE, SIG_SIZE)
val v = if (this.size > SIG_SIZE)
this[SIG_SIZE].let {
if (it < 27) (it + 27).toByte() else it
}
else
recoveryParam
return SignatureData(BigInteger(1, rBytes), BigInteger(1, sBytes), v)
return SignatureData(BigInteger(1, rBytes), BigInteger(1, sBytes), v.toInt().toBigInteger())
}

/**
* Returns the DER encoding of the standard signature components
*/
@Deprecated("This method will be removed in the next major release")
fun SignatureData.getDerEncoded(): String {

val v = ASN1EncodableVector()
Expand Down
10 changes: 5 additions & 5 deletions signer-common/src/test/java/me/uport/sdk/signer/KPSignerTests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import kotlinx.coroutines.runBlocking
import org.junit.Test
import org.kethereum.extensions.hexToBigInteger
import org.kethereum.model.SignatureData
import org.walleth.khex.hexToByteArray
import org.komputing.khex.extensions.hexToByteArray

class KPSignerTests {

Expand All @@ -17,7 +17,7 @@ class KPSignerTests {
val expectedSignature = SignatureData(
r = "809e3b5ef25f4a3b039139e2fb70f70b636eba89c77a3b01e0c71c1a36d84126".hexToBigInteger(),
s = "38524dfcd3e412cb6bc37f4594bbad104b6764bb14c64e42c699730106d1885a".hexToBigInteger(),
v = 28.toByte()
v = 28.toBigInteger()
)

val rawTransactionBytes =
Expand All @@ -38,7 +38,7 @@ class KPSignerTests {
val referenceSignature = SignatureData(
r = "6bcd81446183af193ca4a172d5c5c26345903b24770d90b5d790f74a9dec1f68".hexToBigInteger(),
s = "e2b85b3c92c9b4f3cf58de46e7997d8efb6e14b2e532d13dfa22ee02f3a43d5d".hexToBigInteger(),
v = 28.toByte()
v = 28.toBigInteger()
)

val signer = KPSigner("65fc670d9351cb87d1f56702fb56a7832ae2aab3427be944ab8c9f2a0ab87960")
Expand All @@ -55,7 +55,7 @@ class KPSignerTests {
val expectedSignature = SignatureData(
r = "809e3b5ef25f4a3b039139e2fb70f70b636eba89c77a3b01e0c71c1a36d84126".hexToBigInteger(),
s = "38524dfcd3e412cb6bc37f4594bbad104b6764bb14c64e42c699730106d1885a".hexToBigInteger(),
v = 28.toByte()
v = 28.toBigInteger()
)

val rawTransactionBytes =
Expand All @@ -74,7 +74,7 @@ class KPSignerTests {
val referenceSignature = SignatureData(
r = "6bcd81446183af193ca4a172d5c5c26345903b24770d90b5d790f74a9dec1f68".hexToBigInteger(),
s = "e2b85b3c92c9b4f3cf58de46e7997d8efb6e14b2e532d13dfa22ee02f3a43d5d".hexToBigInteger(),
v = 28.toByte()
v = 28.toBigInteger()
)

val signer = KPSigner("65fc670d9351cb87d1f56702fb56a7832ae2aab3427be944ab8c9f2a0ab87960")
Expand Down
Loading

0 comments on commit b94cab9

Please sign in to comment.