diff --git a/cloud-agent/service/server/src/main/scala/org/hyperledger/identus/agent/server/jobs/BackgroundJobsHelper.scala b/cloud-agent/service/server/src/main/scala/org/hyperledger/identus/agent/server/jobs/BackgroundJobsHelper.scala index 550c82257a..8766e644d1 100644 --- a/cloud-agent/service/server/src/main/scala/org/hyperledger/identus/agent/server/jobs/BackgroundJobsHelper.scala +++ b/cloud-agent/service/server/src/main/scala/org/hyperledger/identus/agent/server/jobs/BackgroundJobsHelper.scala @@ -5,6 +5,7 @@ import org.hyperledger.identus.agent.walletapi.model.error.DIDSecretStorageError import org.hyperledger.identus.agent.walletapi.service.ManagedDIDService import org.hyperledger.identus.agent.walletapi.storage.DIDNonSecretStorage import org.hyperledger.identus.castor.core.model.did.{LongFormPrismDID, PrismDID, VerificationRelationship} +import org.hyperledger.identus.castor.core.model.did.EllipticCurve import org.hyperledger.identus.castor.core.service.DIDService import org.hyperledger.identus.mercury.{AgentPeerService, DidAgent} import org.hyperledger.identus.mercury.model.DidId @@ -52,7 +53,11 @@ trait BackgroundJobsHelper { .resolveDID(jwtIssuerDID) .mapError(e => RuntimeException(s"Error occured while resolving Issuing DID during VC creation: ${e.toString}")) .someOrFail(RuntimeException(s"Issuing DID resolution result is not found")) - .map { case (_, didData) => didData.publicKeys.find(_.purpose == verificationRelationship).map(_.id) } + .map { case (_, didData) => + didData.publicKeys + .find(pk => pk.purpose == verificationRelationship && pk.publicKeyData.crv == EllipticCurve.SECP256K1) + .map(_.id) + } .someOrFail( RuntimeException(s"Issuing DID doesn't have a key in ${verificationRelationship.name} to use: $jwtIssuerDID") ) @@ -120,7 +125,11 @@ trait BackgroundJobsHelper { .resolveDID(jwtIssuerDID) .mapError(e => RuntimeException(s"Error occured while resolving Issuing DID during VC creation: ${e.toString}")) .someOrFail(RuntimeException(s"Issuing DID resolution result is not found")) - .map { case (_, didData) => didData.publicKeys.find(_.purpose == verificationRelationship).map(_.id) } + .map { case (_, didData) => + didData.publicKeys + .find(pk => pk.purpose == verificationRelationship && pk.publicKeyData.crv == EllipticCurve.ED25519) + .map(_.id) + } .someOrFail( RuntimeException(s"Issuing DID doesn't have a key in ${verificationRelationship.name} to use: $jwtIssuerDID") ) diff --git a/pollux/core/src/main/scala/org/hyperledger/identus/pollux/core/service/CredentialServiceImpl.scala b/pollux/core/src/main/scala/org/hyperledger/identus/pollux/core/service/CredentialServiceImpl.scala index 7f77f74fc2..cebb0b6f80 100644 --- a/pollux/core/src/main/scala/org/hyperledger/identus/pollux/core/service/CredentialServiceImpl.scala +++ b/pollux/core/src/main/scala/org/hyperledger/identus/pollux/core/service/CredentialServiceImpl.scala @@ -7,6 +7,7 @@ import org.hyperledger.identus.agent.walletapi.model.{ManagedDIDState, Publicati import org.hyperledger.identus.agent.walletapi.service.ManagedDIDService import org.hyperledger.identus.agent.walletapi.storage.GenericSecretStorage import org.hyperledger.identus.castor.core.model.did.{CanonicalPrismDID, PrismDID, VerificationRelationship} +import org.hyperledger.identus.castor.core.model.did.EllipticCurve import org.hyperledger.identus.castor.core.service.DIDService import org.hyperledger.identus.mercury.model.* import org.hyperledger.identus.mercury.protocol.issuecredential.* @@ -544,7 +545,11 @@ private class CredentialServiceImpl( .resolveDID(jwtIssuerDID) .mapError(e => UnexpectedError(s"Error occured while resolving Issuing DID during VC creation: ${e.toString}")) .someOrFail(UnexpectedError(s"Issuing DID resolution result is not found")) - .map { case (_, didData) => didData.publicKeys.find(_.purpose == verificationRelationship).map(_.id) } + .map { case (_, didData) => + didData.publicKeys + .find(pk => pk.purpose == verificationRelationship && pk.publicKeyData.crv == EllipticCurve.SECP256K1) + .map(_.id) + } .someOrFail( UnexpectedError(s"Issuing DID doesn't have a key in ${verificationRelationship.name} to use: $jwtIssuerDID") ) @@ -571,7 +576,11 @@ private class CredentialServiceImpl( .resolveDID(jwtIssuerDID) .mapError(e => UnexpectedError(s"Error occured while resolving Issuing DID during VC creation: ${e.toString}")) .someOrFail(UnexpectedError(s"Issuing DID resolution result is not found")) - .map { case (_, didData) => didData.publicKeys.find(_.purpose == verificationRelationship).map(_.id) } + .map { case (_, didData) => + didData.publicKeys + .find(pk => pk.purpose == verificationRelationship && pk.publicKeyData.crv == EllipticCurve.ED25519) + .map(_.id) + } .someOrFail( UnexpectedError(s"Issuing DID doesn't have a key in ${verificationRelationship.name} to use: $jwtIssuerDID") )