Skip to content

Commit

Permalink
fix: pick right key type when creating corresponding issuer (#1157)
Browse files Browse the repository at this point in the history
Signed-off-by: Pat Losoponkul <[email protected]>
  • Loading branch information
patlo-iog authored Jun 7, 2024
1 parent 888ebb4 commit 22f0448
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
)
Expand Down Expand Up @@ -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")
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.*
Expand Down Expand Up @@ -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")
)
Expand All @@ -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")
)
Expand Down

0 comments on commit 22f0448

Please sign in to comment.