Skip to content

Commit

Permalink
refactor: Upgrade dependencies & Code enhancements (#98)
Browse files Browse the repository at this point in the history
Signed-off-by: Ahmed Moussa <[email protected]>
  • Loading branch information
hamada147 authored Sep 9, 2023
1 parent c23e0ac commit 3e44f3f
Show file tree
Hide file tree
Showing 46 changed files with 198 additions and 205 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Atala Prism Wallet SDK - Kotlin Multiplatform (Android/JVM)

[![Kotlin](https://img.shields.io/badge/kotlin-1.7.20-blue.svg?logo=kotlin)](http://kotlinlang.org)
[![Kotlin](https://img.shields.io/badge/kotlin-1.9.10-blue.svg?logo=kotlin)](http://kotlinlang.org)
![android](https://camo.githubusercontent.com/b1d9ad56ab51c4ad1417e9a5ad2a8fe63bcc4755e584ec7defef83755c23f923/687474703a2f2f696d672e736869656c64732e696f2f62616467652f706c6174666f726d2d616e64726f69642d3645444238442e7376673f7374796c653d666c6174)
![jvm](https://camo.githubusercontent.com/700f5dcd442fd835875568c038ae5cd53518c80ae5a0cf12c7c5cf4743b5225b/687474703a2f2f696d672e736869656c64732e696f2f62616467652f706c6174666f726d2d6a766d2d4442343133442e7376673f7374796c653d666c6174)

Expand All @@ -20,32 +20,32 @@ Atala PRISM is a self-sovereign identity (SSI) platform and service suite for ve
The complete platform is separated in multiple repositories:

* [atala-prism-wallet-sdk-swift](https://github.com/input-output-hk/atala-prism-wallet-sdk-swift) - Repo that implements Atala PRISM for Apple platforms in Swift.
* [atala-prism-wallet-sdk-ts](https://github.com/input-output-hk/atala-prism-wallet-sdk-ts) - Repo that implements Atala PRISM for Browser and NodeJS platforms in Typescript.
* [atala-prism-wallet-sdk-ts](https://github.com/input-output-hk/atala-prism-wallet-sdk-ts) - Repo that implements Atala PRISM for Browser and Node.js platforms in Typescript.
* [atala-prism-building-blocks](https://github.com/input-output-hk/atala-prism-building-blocks) - Repo that contains the platform Building Blocks.

### Modules / APIs

Atala PRISM Kotlin multiplatform SDK provides the following building blocks to create, manage and resolve decentralized identifiers, issue, manage and verify verifiable credentials, establish and manage trusted, peer-to-peer connections and interactions between DIDs, and store, manage, and recover verifiable data linked to DIDs.

* __Apollo__: Building block that provides a suite of criptographic operations.
* __Apollo__: Building block that provides a suite of cryptographic operations.
* __Castor__: Building block that provides a suite of DID operations in a user-controlled manner.
* __Pollux__: Building block that provides a suite of credential operations in a privacy-preserving manner.
* __Mercury__: Building block that provides a set of secure, standards-based communications protocols in a transport-agnostic and interoperable manner.
* __Pluto__: Building block that provides an interface for storage operations in a portable, storage-agnostic manner.
* __PrismAgent__: PrismAgent using all the building blocks provides a agent that can provide a set of high level DID functionalities.
* __PrismAgent__: PrismAgent using all the building blocks provides an agent that can provide a set of high level DID functionalities.

## Getting started

### Setup

To get started with the Atala PRISM kotlin multiplaform SDK, you can set up the SDK and start a new project or integrate it into an existing project. Before you start, make sure you have the following installed on your development machine:
To get started with the Atala PRISM kotlin multiplatform SDK, you can set up the SDK and start a new project or integrate it into an existing project. Before you start, make sure you have the following installed on your development machine:

- Android: API level 21 and above.
- Kotlin 1.7.20 or later.
- Kotlin 1.9.10 or later.
- JVM: 11 or later.

### Integrating the SDK in an existing project

To integrate the SDK into an exiting project, you have to import the SDK into your project:
To integrate the SDK into an existing project, you have to import the SDK into your project:

`implementation("io.iohk.atala.prism:walletsdk:$sdk_version")`
42 changes: 21 additions & 21 deletions atala-prism-sdk/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ val didpeerVersion = project.property("didpeer_version")
plugins {
id("com.squareup.sqldelight")
kotlin("multiplatform")
kotlin("plugin.serialization") version "1.7.20"
kotlin("plugin.serialization")
id("com.android.library")
id("org.jetbrains.dokka")
id("org.jetbrains.kotlinx.kover") version "0.7.0"
id("org.jetbrains.kotlinx.kover") version "0.7.3"
}

koverReport {
Expand All @@ -39,7 +39,7 @@ koverReport {
}

kotlin {
android {
androidTarget {
publishAllLibraryVariants()
}

Expand Down Expand Up @@ -100,14 +100,14 @@ kotlin {
kotlin.srcDir("${project(":protosLib").buildDir}/generated/source/proto/main/kotlin")
resources.srcDir("${project(":protosLib").projectDir}/src/main")
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4")
implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.4.0")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3")
implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.4.1")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.0")

implementation("io.ktor:ktor-client-core:2.1.3")
implementation("io.ktor:ktor-client-content-negotiation:2.1.3")
implementation("io.ktor:ktor-serialization-kotlinx-json:2.1.3")
implementation("io.ktor:ktor-client-logging:2.1.3")
implementation("io.ktor:ktor-client-core:2.3.4")
implementation("io.ktor:ktor-client-content-negotiation:2.3.4")
implementation("io.ktor:ktor-serialization-kotlinx-json:2.3.4")
implementation("io.ktor:ktor-client-logging:2.3.4")

implementation("io.iohk.atala.prism.didcomm:didpeer:$didpeerVersion")

Expand All @@ -122,29 +122,29 @@ kotlin {

implementation("pro.streem.pbandk:pbandk-runtime:0.14.2")

implementation("org.didcommx:didcomm:0.3.0")
implementation("org.didcommx:didcomm:0.3.2")

implementation("com.google.protobuf:protoc:3.12.0") {
exclude("com.google.protobuf")
}

implementation("com.squareup.sqldelight:coroutines-extensions:1.5.4")
implementation("com.squareup.sqldelight:coroutines-extensions:1.5.5")

api("org.lighthousegames:logging:1.1.2")
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4")
implementation("io.ktor:ktor-client-mock:2.1.3")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.3")
implementation("io.ktor:ktor-client-mock:2.3.4")
}
}
val jvmMain by getting {
dependencies {
implementation("io.ktor:ktor-client-okhttp:2.1.3")
implementation("io.ktor:ktor-client-okhttp:2.3.4")
implementation("org.bouncycastle:bcprov-jdk15on:1.68")
implementation("com.squareup.sqldelight:sqlite-driver:1.5.4")
implementation("com.squareup.sqldelight:sqlite-driver:1.5.5")
}
}
val jvmTest by getting {
Expand All @@ -154,13 +154,13 @@ kotlin {
}
val androidMain by getting {
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4")
implementation("io.ktor:ktor-client-okhttp:2.1.3")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3")
implementation("io.ktor:ktor-client-okhttp:2.3.4")
implementation("org.bouncycastle:bcprov-jdk15on:1.68")
implementation("com.squareup.sqldelight:android-driver:1.5.4")
implementation("com.squareup.sqldelight:android-driver:1.5.5")
}
}
val androidTest by getting {
val androidUnitTest by getting {
dependencies {
implementation("junit:junit:4.13.2")
}
Expand Down Expand Up @@ -257,7 +257,7 @@ tasks.withType<DokkaTask>().configureEach {
val antlrGenerationTask by tasks.register<com.strumenta.antlrkotlin.gradleplugin.AntlrKotlinTask>("generateKotlinCommonGrammarSource") {
// the classpath used to run antlr code generation
antlrClasspath = configurations.detachedConfiguration(
project.dependencies.create("com.github.piacenti:antlr-kotlin-runtime:0.0.14"),
project.dependencies.create("com.github.piacenti:antlr-kotlin-runtime:0.0.14")
)
maxHeapSize = "64m"
packageName = "io.iohk.atala.prism.walletsdk.castor.antlrgrammar"
Expand Down
2 changes: 1 addition & 1 deletion atala-prism-sdk/docs/Apollo.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Public-key encryption uses a public encryption key to encrypt data so that only

### Accumulators

Cryptographic accumulators allow for the accumulation of multiple values into one. Merkle trees are the most common type of accumulator used in the cryptocurrency domain. Accumulators make it possible to check (and prove) whether a given value has been accumulated.
Cryptographic accumulators allow for the accumulation of multiple values into one. Merkle's trees are the most common type of accumulator used in the cryptocurrency domain. Accumulators make it possible to check (and prove) whether a given value has been accumulated.

### MAC

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,11 @@ import io.iohk.atala.prism.walletsdk.domain.models.PlutoError

actual class DbConnection actual constructor() {
actual var driver: SqlDriver? = null
actual suspend fun connectDb(
context: Any?,
): PrismPlutoDb {
actual suspend fun connectDb(context: Any?): PrismPlutoDb {
val androidContext: Context = (context as? Context) ?: throw PlutoError.DatabaseContextError()
val driver = AndroidSqliteDriver(PrismPlutoDb.Schema, androidContext, "prism.db")
this.driver = driver
return PrismPlutoDb(
driver,
)
return PrismPlutoDb(driver)
}
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ class ApolloImpl : Apollo {
return Seed(
value = KeyDerivation.binarySeed(
seed = mnemonicCode,
passphrase = passphrase,
),
passphrase = passphrase
)
)
}

Expand All @@ -70,9 +70,9 @@ class ApolloImpl : Apollo {
Seed(
value = KeyDerivation.binarySeed(
seed = mnemonicCode,
passphrase = passphrase ?: "",
),
),
passphrase = passphrase ?: ""
)
)
)
}

Expand All @@ -98,12 +98,12 @@ class ApolloImpl : Apollo {
keyCurve = curve,
privateKey = PrivateKey(
keyCurve = curve,
value = privateKey.getEncoded(),
value = privateKey.getEncoded()
),
publicKey = PublicKey(
curve = curve,
value = publicKey.getEncoded(),
),
value = publicKey.getEncoded()
)
)
}

Expand Down Expand Up @@ -133,12 +133,12 @@ class ApolloImpl : Apollo {
keyCurve = privateKey.keyCurve,
privateKey = PrivateKey(
keyCurve = privateKey.keyCurve,
value = kmmPrivateKey.getEncoded(),
value = kmmPrivateKey.getEncoded()
),
publicKey = PublicKey(
curve = privateKey.keyCurve,
value = kmmPrivateKey.getPublicKey().getEncoded(),
),
value = kmmPrivateKey.getPublicKey().getEncoded()
)
)
}

Expand All @@ -150,12 +150,12 @@ class ApolloImpl : Apollo {
keyCurve = privateKey.keyCurve,
privateKey = PrivateKey(
keyCurve = privateKey.keyCurve,
value = edPrivateKey.encoded,
value = edPrivateKey.encoded
),
publicKey = PublicKey(
curve = privateKey.keyCurve,
value = edPublicKey.encoded,
),
value = edPublicKey.encoded
)
)
}

Expand All @@ -167,12 +167,12 @@ class ApolloImpl : Apollo {
keyCurve = privateKey.keyCurve,
privateKey = PrivateKey(
keyCurve = privateKey.keyCurve,
value = xPrivateKey.encoded,
value = xPrivateKey.encoded
),
publicKey = PublicKey(
curve = privateKey.keyCurve,
value = xPublicKey.encoded,
),
value = xPublicKey.encoded
)
)
}
}
Expand All @@ -189,7 +189,7 @@ class ApolloImpl : Apollo {
val kmmCompressed = kmmPublicKey.getEncodedCompressed()
return CompressedPublicKey(
uncompressed = publicKey,
value = kmmCompressed,
value = kmmCompressed
)
}

Expand All @@ -204,11 +204,11 @@ class ApolloImpl : Apollo {
val kmmCompressed = kmmPublicKey.getEncodedCompressed()
val publicKey = PublicKey(
curve = KeyCurve(Curve.SECP256K1),
value = kmmPublicKey.getEncoded(),
value = kmmPublicKey.getEncoded()
)
return CompressedPublicKey(
uncompressed = publicKey,
value = kmmCompressed,
value = kmmCompressed
)
}

Expand All @@ -226,7 +226,7 @@ class ApolloImpl : Apollo {
val kmmPublicKey = KMMECSecp256k1PublicKey.secp256k1FromByteCoordinates(x, y)
PublicKey(
curve = curve,
value = kmmPublicKey.getEncoded(),
value = kmmPublicKey.getEncoded()
)
}

Expand All @@ -250,7 +250,7 @@ class ApolloImpl : Apollo {
val kmmPublicKey = KMMECSecp256k1PublicKey.secp256k1FromBytes(x)
PublicKey(
curve = curve,
value = kmmPublicKey.getEncoded(),
value = kmmPublicKey.getEncoded()
)
}

Expand All @@ -275,21 +275,17 @@ class ApolloImpl : Apollo {
val kmmSignature = KMMECDSA.sign(
type = ECDSAType.ECDSA_SHA256,
data = message,
privateKey = kmmPrivateKey,
)
Signature(
value = kmmSignature,
privateKey = kmmPrivateKey
)
Signature(value = kmmSignature)
}

Curve.ED25519 -> {
val signature = Ed25519.sign(
privateKey = privateKey,
message = message
)
Signature(
value = signature
)
Signature(value = signature)
}

else -> {
Expand Down Expand Up @@ -344,7 +340,7 @@ class ApolloImpl : Apollo {
type = ECDSAType.ECDSA_SHA256,
data = challenge,
publicKey = kmmPublicKey,
signature = signature.value,
signature = signature.value
)
}
Curve.ED25519 -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class CastorImpl(apollo: Apollo, private val logger: PrismLogger = PrismLoggerIm
this.apollo = apollo
this.resolvers = arrayOf(
PeerDIDResolver(),
LongFormPrismDIDResolver(this.apollo),
LongFormPrismDIDResolver(this.apollo)
)
}

Expand Down Expand Up @@ -63,7 +63,7 @@ class CastorImpl(apollo: Apollo, private val logger: PrismLogger = PrismLoggerIm
return CastorShared.createPrismDID(
apollo = apollo,
masterPublicKey = masterPublicKey,
services = services,
services = services
)
}

Expand All @@ -83,7 +83,7 @@ class CastorImpl(apollo: Apollo, private val logger: PrismLogger = PrismLoggerIm
): DID {
return CastorShared.createPeerDID(
keyPairs = keyPairs,
services = services,
services = services
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ object DIDUrlParser {
did,
listener.path ?: emptyArray(),
listener.query,
listener.fragment,
listener.fragment
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ constructor(val did: DID) {

init {
val methodId = PrismDIDMethodId(
did.methodId,
did.methodId
)

if (methodId.sections.size != 2) {
Expand Down
Loading

0 comments on commit 3e44f3f

Please sign in to comment.