Skip to content

Commit

Permalink
Merge branch 'main' into inline-docs
Browse files Browse the repository at this point in the history
Signed-off-by: Ahmed Moussa <[email protected]>
  • Loading branch information
hamada147 committed Dec 14, 2023
2 parents bd85072 + 2b17b1b commit cff6c5e
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 21 deletions.
2 changes: 1 addition & 1 deletion atala-prism-sdk/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ kotlin {

api("org.lighthousegames:logging:1.1.2")

implementation("io.iohk.atala.prism.anoncredskmp:anoncreds-kmp:1.0.0")
implementation("io.iohk.atala.prism.anoncredskmp:anoncreds-kmp:0.3.4")
implementation("com.ionspin.kotlin:bignum:0.3.8")
implementation("org.bouncycastle:bcprov-jdk15on:1.68")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.iohk.atala.prism.walletsdk.apollo

import io.iohk.atala.prism.apollo.derivation.HDKey
import io.iohk.atala.prism.apollo.derivation.Mnemonic
import io.iohk.atala.prism.apollo.derivation.MnemonicHelper
import io.iohk.atala.prism.apollo.derivation.MnemonicLengthException
import io.iohk.atala.prism.walletsdk.apollo.helpers.BytesOps
import io.iohk.atala.prism.walletsdk.apollo.utils.Ed25519KeyPair
Expand Down Expand Up @@ -39,7 +39,7 @@ class ApolloImpl : Apollo {
* @return An array of mnemonic phrases.
*/
override fun createRandomMnemonics(): Array<String> {
return Mnemonic.createRandomMnemonics().toTypedArray()
return MnemonicHelper.createRandomMnemonics().toTypedArray()
}

/**
Expand All @@ -52,7 +52,7 @@ class ApolloImpl : Apollo {
*/
@Throws(MnemonicLengthException::class)
override fun createSeed(mnemonics: Array<String>, passphrase: String): Seed {
return Seed(Mnemonic.createSeed(mnemonics.asList(), passphrase))
return Seed(MnemonicHelper.createSeed(mnemonics.asList(), passphrase))
}

/**
Expand All @@ -66,7 +66,7 @@ class ApolloImpl : Apollo {
return SeedWords(
mnemonics,
Seed(
value = Mnemonic.createSeed(
value = MnemonicHelper.createSeed(
mnemonics = mnemonics.asList(),
passphrase = passphrase ?: ""
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import kotlinx.serialization.json.Json
* A data class representing a container for verifiable credential types.
* This data class is used to encode and decode verifiable credential types for use with JSON.
* The VerifiableCredentialTypeContainer contains properties for the ID and type of the verifiable credential.
* Note: The VerifiableCredentialTypeContainer is used to encode and decode verifiable credential types for use with JSON.
* ::: info
* The VerifiableCredentialTypeContainer is used to encode and decode verifiable credential types for use with JSON.
* :::
*/
@Serializable
data class VerifiableCredentialTypeContainer(
Expand All @@ -20,11 +22,10 @@ data class VerifiableCredentialTypeContainer(
* Enum class representing different types of verifiable credentials.
* The CredentialType is used to indicate the type of verifiable credential.
* The possible values of the enum are jwt, w3c, and unknown.
::: info
The CredentialType enum is used to indicate the type of verifiable credential.
:::
*
* ::: info
* The CredentialType enum is used to indicate the type of verifiable credential.
* :::
*/
@Serializable
enum class CredentialType(val type: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package io.iohk.atala.prism.walletsdk.apollo

import io.iohk.atala.prism.apollo.base64.base64UrlEncoded
import io.iohk.atala.prism.apollo.derivation.DerivationPath
import io.iohk.atala.prism.apollo.derivation.Mnemonic
import io.iohk.atala.prism.apollo.derivation.MnemonicHelper
import io.iohk.atala.prism.apollo.utils.ECConfig
import io.iohk.atala.prism.walletsdk.apollo.derivation.bip39Vectors
Expand Down Expand Up @@ -87,15 +86,15 @@ class ApolloTests {

@Test
fun testKeyPairGeneration() {
keyPair = Secp256k1KeyPair.generateKeyPair(Seed(Mnemonic.createRandomSeed()), KeyCurve(Curve.SECP256K1))
keyPair = Secp256k1KeyPair.generateKeyPair(Seed(MnemonicHelper.createRandomSeed()), KeyCurve(Curve.SECP256K1))
assertEquals(keyPair.publicKey.raw.size, ECConfig.PUBLIC_KEY_BYTE_SIZE)
assertEquals(keyPair.privateKey.raw.size, ECConfig.PRIVATE_KEY_BYTE_SIZE)
}

@Test
fun testSignAndVerifyTest() {
val message = "The quick brown fox jumps over the lazy dog"
keyPair = Secp256k1KeyPair.generateKeyPair(Seed(Mnemonic.createRandomSeed()), KeyCurve(Curve.SECP256K1))
keyPair = Secp256k1KeyPair.generateKeyPair(Seed(MnemonicHelper.createRandomSeed()), KeyCurve(Curve.SECP256K1))
val signature = (keyPair.privateKey as Secp256k1PrivateKey).sign(message.toByteArray())

assertEquals(signature.size <= ECConfig.SIGNATURE_MAX_BYTE_SIZE, true)
Expand All @@ -109,7 +108,7 @@ class ApolloTests {
fun testDerivePrivateKey_whenSecp256k1_thenWorksAsExpected() {
val path = "m/0'/0'/0'"

val seed = Seed(Mnemonic.createRandomSeed())
val seed = Seed(MnemonicHelper.createRandomSeed())

val properties: MutableMap<String, Any> = mutableMapOf()
properties[TypeKey().property] = KeyTypes.EC
Expand Down Expand Up @@ -175,7 +174,7 @@ class ApolloTests {
"return",
"height"
)
val seed = Seed(Mnemonic.createSeed(mnemonics = mnemonics, passphrase = "mnemonic"))
val seed = Seed(MnemonicHelper.createSeed(mnemonics = mnemonics, passphrase = "mnemonic"))

val expectedPrivateKeyBase64Url = "xURclKhT6as1Tb9vg4AJRRLPAMWb9dYTTthDvXEKjMc"

Expand Down Expand Up @@ -208,7 +207,7 @@ class ApolloTests {
@Test
fun testRestorePrivateKey_whenStorableSecp256k1_thenRestoredOk() {
val keyPairSecp256k1 =
Secp256k1KeyPair.generateKeyPair(Seed(Mnemonic.createRandomSeed()), KeyCurve(Curve.SECP256K1))
Secp256k1KeyPair.generateKeyPair(Seed(MnemonicHelper.createRandomSeed()), KeyCurve(Curve.SECP256K1))
val keyPairEd25519 = Ed25519KeyPair.generateKeyPair()
val privateKeySecp256k1 = keyPairSecp256k1.privateKey as Secp256k1PrivateKey
val privateKeyEd25519 = keyPairEd25519.privateKey as Ed25519PrivateKey
Expand All @@ -221,7 +220,7 @@ class ApolloTests {
@Test
fun testRestorePublicKey_whenStorableSecp256k1_thenRestoredOk() {
val keyPairSecp256k1 =
Secp256k1KeyPair.generateKeyPair(Seed(Mnemonic.createRandomSeed()), KeyCurve(Curve.SECP256K1))
Secp256k1KeyPair.generateKeyPair(Seed(MnemonicHelper.createRandomSeed()), KeyCurve(Curve.SECP256K1))
val keyPairEd25519 = Ed25519KeyPair.generateKeyPair()
val publicKeySecp256k1 = keyPairSecp256k1.publicKey as Secp256k1PublicKey
val publicKeyEd25519 = keyPairEd25519.publicKey as Ed25519PublicKey
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package io.iohk.atala.prism.walletsdk.prismagent

/* ktlint-disable import-ordering */
import anoncreds_wrapper.LinkSecret
import io.iohk.atala.prism.apollo.derivation.Mnemonic
import io.iohk.atala.prism.apollo.derivation.MnemonicHelper
import io.iohk.atala.prism.walletsdk.apollo.ApolloImpl
import io.iohk.atala.prism.walletsdk.apollo.utils.Secp256k1KeyPair
import io.iohk.atala.prism.walletsdk.castor.CastorImpl
Expand Down Expand Up @@ -73,7 +73,7 @@ class PrismAgentTests {

@Test
fun testCreateNewPrismDID_shouldCreateNewDID_whenCalled() = runTest {
val seed = Seed(Mnemonic.createRandomSeed())
val seed = Seed(MnemonicHelper.createRandomSeed())
val validDID = DID("did", "test", "123")
castorMock.createPrismDIDReturn = validDID
val agent = PrismAgent(
Expand Down Expand Up @@ -271,7 +271,7 @@ class PrismAgentTests {

val privateKeys = listOf(
Secp256k1KeyPair.generateKeyPair(
seed = Seed(Mnemonic.createRandomSeed()),
seed = Seed(MnemonicHelper.createRandomSeed()),
curve = KeyCurve(Curve.SECP256K1)
).privateKey
)
Expand Down
7 changes: 7 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ allprojects {
this.password = System.getenv("ATALA_GITHUB_TOKEN")
}
}
maven {
this.url = uri("https://github.com/input-output-hk/anoncreds-rs/")
credentials {
this.username = System.getenv("ATALA_GITHUB_ACTOR")
this.password = System.getenv("ATALA_GITHUB_TOKEN")
}
}
}

configurations.all {
Expand Down

0 comments on commit cff6c5e

Please sign in to comment.