diff --git a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/apollo/ApolloImpl.kt b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/apollo/ApolloImpl.kt index 758c4e19d..89d6ea35b 100644 --- a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/apollo/ApolloImpl.kt +++ b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/apollo/ApolloImpl.kt @@ -38,13 +38,11 @@ import org.hyperledger.identus.walletsdk.domain.models.keyManagement.PublicKey import org.hyperledger.identus.walletsdk.domain.models.keyManagement.RawKey import org.hyperledger.identus.walletsdk.domain.models.keyManagement.SeedKey import org.hyperledger.identus.walletsdk.domain.models.keyManagement.StorableKey -import org.hyperledger.identus.walletsdk.domain.models.keyManagement.StorablePrivateKey import org.hyperledger.identus.walletsdk.domain.models.keyManagement.TypeKey import org.hyperledger.identus.walletsdk.logger.LogComponent import org.hyperledger.identus.walletsdk.logger.LogLevel import org.hyperledger.identus.walletsdk.logger.Logger import org.hyperledger.identus.walletsdk.logger.LoggerImpl -import pbandk.ByteArr /** * Apollo defines the set of cryptographic operations that are used in the Atala PRISM. @@ -299,8 +297,8 @@ class ApolloImpl( if (curvePointX != null && curvePointY != null) { // Compressed key val nativePublicKey = KMMECSecp256k1PublicKey.secp256k1FromByteCoordinates( - x = (curvePointX as ByteArr).array, - y = (curvePointY as ByteArr).array + x = (curvePointX as String).base64UrlDecodedBytes, + y = (curvePointY as String).base64UrlDecodedBytes ) return Secp256k1PublicKey(nativePublicKey.raw) } else { diff --git a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/castor/CastorImpl.kt b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/castor/CastorImpl.kt index 989faa6c4..172ecfdae 100644 --- a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/castor/CastorImpl.kt +++ b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/castor/CastorImpl.kt @@ -125,7 +125,8 @@ constructor( try { val resolved = resolver.resolve(did) return resolved - } catch (_: CastorError) { + } catch (err: CastorError) { + println(err.message) } } throw Exception("No resolver could resolve the provided DID.") diff --git a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/castor/did/prismdid/PrismDIDPublicKey.kt b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/castor/did/prismdid/PrismDIDPublicKey.kt index 5ae2c08e1..bab6e5c41 100644 --- a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/castor/did/prismdid/PrismDIDPublicKey.kt +++ b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/castor/did/prismdid/PrismDIDPublicKey.kt @@ -1,7 +1,9 @@ package org.hyperledger.identus.walletsdk.castor.did.prismdid import org.hyperledger.identus.apollo.base64.base64DecodedBytes +import org.hyperledger.identus.apollo.base64.base64Encoded import org.hyperledger.identus.apollo.base64.base64UrlDecodedBytes +import org.hyperledger.identus.apollo.base64.base64UrlEncoded import org.hyperledger.identus.protos.CompressedECKeyData import org.hyperledger.identus.protos.ECKeyData import org.hyperledger.identus.protos.KeyUsage @@ -79,8 +81,8 @@ class PrismDIDPublicKey { properties = mapOf( TypeKey().property to KeyTypes.EC, CurveKey().property to ecKeyData.curve, - CurvePointXKey().property to ecKeyData.x, - CurvePointYKey().property to ecKeyData.y + CurvePointXKey().property to ecKeyData.x.array.base64UrlEncoded, + CurvePointYKey().property to ecKeyData.y.array.base64UrlEncoded ) ) } diff --git a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/edgeagent/EdgeAgent.kt b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/edgeagent/EdgeAgent.kt index 01e39198d..1ba089eda 100644 --- a/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/edgeagent/EdgeAgent.kt +++ b/edge-agent-sdk/src/commonMain/kotlin/org/hyperledger/identus/walletsdk/edgeagent/EdgeAgent.kt @@ -378,8 +378,8 @@ open class EdgeAgent { ed25519PrivateKeyProperties[TypeKey().property] = KeyTypes.EC ed25519PrivateKeyProperties[SeedKey().property] = seed.value.base64UrlEncoded - ed25519PrivateKeyProperties[CurveKey().property] = Curve.SECP256K1.value - ed25519PrivateKeyProperties[IndexKey().property] = index + ed25519PrivateKeyProperties[CurveKey().property] = Curve.ED25519.value + ed25519PrivateKeyProperties[IndexKey().property] = index+1 val masterKey = this.apollo.createPrivateKey( secp256k1PrivateKeyProperties diff --git a/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/edgeagent/ApolloMock.kt b/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/edgeagent/ApolloMock.kt index eb0bf336b..118b3a4e8 100644 --- a/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/edgeagent/ApolloMock.kt +++ b/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/edgeagent/ApolloMock.kt @@ -1,10 +1,14 @@ package org.hyperledger.identus.walletsdk.edgeagent +import io.iohk.atala.prism.didcomm.didpeer.base64.base64UrlDecoded +import io.iohk.atala.prism.didcomm.didpeer.base64.base64UrlDecodedBytes +import org.bouncycastle.util.encoders.Hex import org.hyperledger.identus.walletsdk.apollo.utils.Ed25519KeyPair import org.hyperledger.identus.walletsdk.apollo.utils.Ed25519PrivateKey import org.hyperledger.identus.walletsdk.apollo.utils.Ed25519PublicKey import org.hyperledger.identus.walletsdk.apollo.utils.Secp256k1PrivateKey import org.hyperledger.identus.walletsdk.domain.buildingblocks.Apollo +import org.hyperledger.identus.walletsdk.domain.models.Curve import org.hyperledger.identus.walletsdk.domain.models.Seed import org.hyperledger.identus.walletsdk.domain.models.SeedWords import org.hyperledger.identus.walletsdk.domain.models.keyManagement.JWK @@ -15,6 +19,8 @@ import org.hyperledger.identus.walletsdk.domain.models.keyManagement.PublicKey import org.hyperledger.identus.walletsdk.domain.models.keyManagement.StorableKey class ApolloMock : Apollo { + val validRawBase64UrlSecp256k1Sk = Hex.decode("67E56582298859DDAE725F972992A07C6C4FB9F62A8FFF58CE3CA926A1063530".lowercase()) + val validRawBase64UrlEd25519Sk = "JLIJQ5jlkyqtGmtOth6yggJLLC0zuRhUPiBhd1-rGPs".base64UrlDecodedBytes var createRandomMnemonicsReturn: Array = emptyArray() var createSeedReturn: Seed = Seed(ByteArray(0)) var createRandomSeedReturn: SeedWords = SeedWords(emptyArray(), Seed(ByteArray(0))) @@ -35,7 +41,13 @@ class ApolloMock : Apollo { } override fun createPrivateKey(properties: Map): PrivateKey { - return createPrivateKey ?: Secp256k1PrivateKey(ByteArray(0)) + val curve = properties["curve"]; + if (curve === Curve.SECP256K1.value) { + return Secp256k1PrivateKey(validRawBase64UrlSecp256k1Sk) + } else if (curve === Curve.ED25519.value) { + return Ed25519PrivateKey(validRawBase64UrlEd25519Sk) + } + TODO("Not yet implemented") } override fun createPublicKey(properties: Map): PublicKey { diff --git a/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/edgeagent/EdgeAgentTests.kt b/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/edgeagent/EdgeAgentTests.kt index acd2efeb0..fd4629b31 100644 --- a/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/edgeagent/EdgeAgentTests.kt +++ b/edge-agent-sdk/src/commonTest/kotlin/org/hyperledger/identus/walletsdk/edgeagent/EdgeAgentTests.kt @@ -380,7 +380,7 @@ class EdgeAgentTests { val apollo = ApolloImpl() val castor = CastorImpl(apollo) val agent = EdgeAgent( - apollo = apollo, + apollo = apolloMockOld, castor = castor, pluto = plutoMockOld, mercury = mercuryMockOld,