diff --git a/.github/labeler.yml b/.github/labeler.yml
index ec8718c7bc..4dfe0b1404 100644
--- a/.github/labeler.yml
+++ b/.github/labeler.yml
@@ -1,3 +1,4 @@
+---
 castor:
   - changed-files:
       - any-glob-to-any-file:
diff --git a/build.sbt b/build.sbt
index 4e6b7f85ef..0d1c98cd73 100644
--- a/build.sbt
+++ b/build.sbt
@@ -14,6 +14,7 @@ inThisBuild(
     githubOwner := "input-output-hk",
     githubRepository := "atala-prism-building-blocks",
     resolvers += "Local Maven Repository" at "file://" + Path.userHome.absolutePath + "/.m2/repository",
+    resolvers += "jitpack" at "https://jitpack.io",
   )
 )
 
@@ -57,7 +58,7 @@ lazy val V = new {
   val zioMock = "1.0.0-RC11"
   val mockito = "3.2.16.0"
 
-    // https://mvnrepository.com/artifact/io.circe/circe-core
+  // https://mvnrepository.com/artifact/io.circe/circe-core
   val circe = "0.14.6"
 
   val tapir = "1.6.4"
@@ -120,7 +121,7 @@ lazy val D = new {
 
   // https://mvnrepository.com/artifact/org.didcommx/didcomm/0.3.2
   val didcommx: ModuleID = "org.didcommx" % "didcomm" % "0.3.1"
-  val peerDidcommx: ModuleID = "org.didcommx" % "peerdid" % "0.3.0"
+  val peerDidcommx: ModuleID = "org.didcommx" % "peerdid" % "0.5.0"
   val didScala: ModuleID = "app.fmgp" %% "did" % "0.0.0+113-61efa271-SNAPSHOT"
 
   // Customized version of numbus jose jwt
@@ -417,6 +418,7 @@ val commonSetttings = Seq(
   testFrameworks ++= Seq(new TestFramework("zio.test.sbt.ZTestFramework")),
   // Needed for Kotlin coroutines that support new memory management mode
   resolvers += "JetBrains Space Maven Repository" at "https://maven.pkg.jetbrains.space/public/p/kotlinx-coroutines/maven",
+  resolvers += "jitpack" at "https://jitpack.io",
   // Override 'updateLicenses' for all project to inject custom DependencyResolution.
   // https://github.com/sbt/sbt-license-report/blob/9675cedb19c794de1119cbcf46a255fc8dcd5d4e/src/main/scala/sbtlicensereport/SbtLicenseReport.scala#L84
   updateLicenses := {
diff --git a/mercury/mercury-library/agent-didcommx/src/main/scala/io/iohk/atala/mercury/AgentPeerService.scala b/mercury/mercury-library/agent-didcommx/src/main/scala/io/iohk/atala/mercury/AgentPeerService.scala
index c5f59165ef..fd4870d2dd 100644
--- a/mercury/mercury-library/agent-didcommx/src/main/scala/io/iohk/atala/mercury/AgentPeerService.scala
+++ b/mercury/mercury-library/agent-didcommx/src/main/scala/io/iohk/atala/mercury/AgentPeerService.scala
@@ -30,22 +30,26 @@ object AgentPeerService {
 
     val keyIdAgreement = PeerDIDUtils.createMultibaseEncnumbasis(keyAgreement).drop(1)
     val keyIdAuthentication = PeerDIDUtils.createMultibaseEncnumbasis(keyAuthentication).drop(1)
+    val keyIdAgreementIndex = agent.id.value.indexOf(keyIdAgreement)
+    val keyIdAuthenticationIndex = agent.id.value.indexOf(keyIdAuthentication)
+    val (keyAgreementId, keyAuthenticationId) =
+      if keyIdAgreementIndex < keyIdAuthenticationIndex then (1, 2) else (2, 1)
 
     val secretKeyAgreement = new Secret(
-      s"${agent.id.value}#$keyIdAgreement",
+      s"${agent.id.value}#key-$keyAgreementId",
       VerificationMethodType.JSON_WEB_KEY_2020,
       new VerificationMaterial(VerificationMaterialFormat.JWK, agent.jwkForKeyAgreement.head.toJSONString)
     )
     val secretKeyAuthentication = new Secret(
-      s"${agent.id.value}#$keyIdAuthentication",
+      s"${agent.id.value}#key-$keyAuthenticationId",
       VerificationMethodType.JSON_WEB_KEY_2020,
       new VerificationMaterial(VerificationMaterialFormat.JWK, agent.jwkForKeyAuthentication.head.toJSONString)
     )
 
     new SecretResolverInMemory(
       Map(
-        s"${agent.id.value}#$keyIdAgreement" -> secretKeyAgreement,
-        s"${agent.id.value}#$keyIdAuthentication" -> secretKeyAuthentication,
+        s"${agent.id.value}#key-$keyAgreementId" -> secretKeyAgreement,
+        s"${agent.id.value}#key-$keyAuthenticationId" -> secretKeyAuthentication,
       ).asJava
     )
   }
diff --git a/mercury/mercury-library/agent-didcommx/src/main/scala/io/iohk/atala/mercury/PeerDID.scala b/mercury/mercury-library/agent-didcommx/src/main/scala/io/iohk/atala/mercury/PeerDID.scala
index 4094ee2cf7..a4a9f052ed 100644
--- a/mercury/mercury-library/agent-didcommx/src/main/scala/io/iohk/atala/mercury/PeerDID.scala
+++ b/mercury/mercury-library/agent-didcommx/src/main/scala/io/iohk/atala/mercury/PeerDID.scala
@@ -54,21 +54,27 @@ object PeerDID {
     *   routingKeys are OPTIONAL. An ordered array of strings referencing keys to be used when preparing the message for
     *   transmission as specified in Sender Process to Enable Forwarding, above.
     */
+
+  case class ServiceEndpoint(uri: String, r: Seq[String] = Seq.empty, a: Seq[String] = Seq("didcomm/v2"))
+  object ServiceEndpoint {
+    implicit val encoder: Encoder[ServiceEndpoint] = deriveEncoder[ServiceEndpoint]
+    implicit val decoder: Decoder[ServiceEndpoint] = deriveDecoder[ServiceEndpoint]
+    def apply(endpoint: String) = new ServiceEndpoint(uri = endpoint)
+  }
+
   case class Service(
       t: String = "dm",
-      s: String,
-      r: Seq[String] = Seq.empty,
-      a: Seq[String] = Seq("didcomm/v2")
+      s: ServiceEndpoint
   ) {
     def `type` = t
     def serviceEndpoint = s
-    def routingKeys = r
-    def accept = a
+    def routingKeys = s.r
+    def accept = s.a
   }
   object Service {
     implicit val encoder: Encoder[Service] = deriveEncoder[Service]
     implicit val decoder: Decoder[Service] = deriveDecoder[Service]
-    def apply(endpoint: String) = new Service(s = endpoint)
+    def apply(endpoint: String) = new Service(s = ServiceEndpoint(endpoint))
   }
 
   def makeNewJwkKeyX25519: OctetKeyPair = new OctetKeyPairGenerator(Curve.X25519).generate()
diff --git a/mercury/mercury-library/resolver/src/main/scala/io/iohk/atala/resolvers/PeerDidResolver.scala b/mercury/mercury-library/resolver/src/main/scala/io/iohk/atala/resolvers/PeerDidResolver.scala
index 2e40ec5a25..a6df34ca72 100644
--- a/mercury/mercury-library/resolver/src/main/scala/io/iohk/atala/resolvers/PeerDidResolver.scala
+++ b/mercury/mercury-library/resolver/src/main/scala/io/iohk/atala/resolvers/PeerDidResolver.scala
@@ -43,10 +43,13 @@ object PeerDidResolver {
         _.map { item =>
           val id = item.hcursor.downField("id").as[String].getOrElse(???)
           // val typ = item.hcursor.downField("type").as[String].getOrElse(???)
-          val serviceEndpoint = item.hcursor.downField("serviceEndpoint").as[String].getOrElse(???)
-          val routingKeys: Seq[String] = item.hcursor.downField("routingKeys").as[List[String]].getOrElse(Seq.empty)
-          val accept: Seq[String] = item.hcursor.downField("accept").as[List[String]].getOrElse(Seq.empty)
-          new DIDCommService(id, serviceEndpoint, routingKeys.asJava, accept.asJava)
+          val serviceEndpointJson = item.hcursor.downField("serviceEndpoint")
+          // val serviceEndpoint = item.hcursor.downField("serviceEndpoint").as[String].getOrElse(???)
+          val uri = serviceEndpointJson.downField("uri").as[String].getOrElse(???)
+          val routingKeys: Seq[String] =
+            serviceEndpointJson.downField("routingKeys").as[List[String]].getOrElse(Seq.empty)
+          val accept: Seq[String] = serviceEndpointJson.downField("accept").as[List[String]].getOrElse(Seq.empty)
+          new DIDCommService(id, uri, routingKeys.asJava, accept.asJava)
         }
       }
       .getOrElse(List.empty)
diff --git a/mercury/mercury-library/resolver/src/test/scala/io/iohk/atala/resolvers/PeerDidResolverSpec.scala b/mercury/mercury-library/resolver/src/test/scala/io/iohk/atala/resolvers/PeerDidResolverSpec.scala
index e31ec7121d..a21c7b204a 100644
--- a/mercury/mercury-library/resolver/src/test/scala/io/iohk/atala/resolvers/PeerDidResolverSpec.scala
+++ b/mercury/mercury-library/resolver/src/test/scala/io/iohk/atala/resolvers/PeerDidResolverSpec.scala
@@ -15,13 +15,13 @@ class PeerDidResolverSpec extends ZSuite {
         |   "id": "did:peer:2.Ez6LSbysY2xFMRpGMhb7tFTLMpeuPRaqaWM1yECx2AtzE3KCc.Vz6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V.Vz6MkgoLTnTypo3tDRwCkZXSccTPHRLhF4ZnjhueYAFpEX6vg.SeyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9lbmRwb2ludCIsInIiOlsiZGlkOmV4YW1wbGU6c29tZW1lZGlhdG9yI3NvbWVrZXkiXSwiYSI6WyJkaWRjb21tL3YyIiwiZGlkY29tbS9haXAyO2Vudj1yZmM1ODciXX0",
         |   "authentication": [
         |       {
-        |           "id": "did:peer:2.Ez6LSbysY2xFMRpGMhb7tFTLMpeuPRaqaWM1yECx2AtzE3KCc.Vz6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V.Vz6MkgoLTnTypo3tDRwCkZXSccTPHRLhF4ZnjhueYAFpEX6vg.SeyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9lbmRwb2ludCIsInIiOlsiZGlkOmV4YW1wbGU6c29tZW1lZGlhdG9yI3NvbWVrZXkiXSwiYSI6WyJkaWRjb21tL3YyIiwiZGlkY29tbS9haXAyO2Vudj1yZmM1ODciXX0#6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V",
+        |           "id": "did:peer:2.Ez6LSbysY2xFMRpGMhb7tFTLMpeuPRaqaWM1yECx2AtzE3KCc.Vz6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V.Vz6MkgoLTnTypo3tDRwCkZXSccTPHRLhF4ZnjhueYAFpEX6vg.SeyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9lbmRwb2ludCIsInIiOlsiZGlkOmV4YW1wbGU6c29tZW1lZGlhdG9yI3NvbWVrZXkiXSwiYSI6WyJkaWRjb21tL3YyIiwiZGlkY29tbS9haXAyO2Vudj1yZmM1ODciXX0#key-2",
         |           "type": "Ed25519VerificationKey2020",
         |           "controller": "did:peer:2.Ez6LSbysY2xFMRpGMhb7tFTLMpeuPRaqaWM1yECx2AtzE3KCc.Vz6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V.Vz6MkgoLTnTypo3tDRwCkZXSccTPHRLhF4ZnjhueYAFpEX6vg.SeyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9lbmRwb2ludCIsInIiOlsiZGlkOmV4YW1wbGU6c29tZW1lZGlhdG9yI3NvbWVrZXkiXSwiYSI6WyJkaWRjb21tL3YyIiwiZGlkY29tbS9haXAyO2Vudj1yZmM1ODciXX0",
         |           "publicKeyMultibase": "z6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V"
         |       },
         |       {
-        |           "id": "did:peer:2.Ez6LSbysY2xFMRpGMhb7tFTLMpeuPRaqaWM1yECx2AtzE3KCc.Vz6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V.Vz6MkgoLTnTypo3tDRwCkZXSccTPHRLhF4ZnjhueYAFpEX6vg.SeyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9lbmRwb2ludCIsInIiOlsiZGlkOmV4YW1wbGU6c29tZW1lZGlhdG9yI3NvbWVrZXkiXSwiYSI6WyJkaWRjb21tL3YyIiwiZGlkY29tbS9haXAyO2Vudj1yZmM1ODciXX0#6MkgoLTnTypo3tDRwCkZXSccTPHRLhF4ZnjhueYAFpEX6vg",
+        |           "id": "did:peer:2.Ez6LSbysY2xFMRpGMhb7tFTLMpeuPRaqaWM1yECx2AtzE3KCc.Vz6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V.Vz6MkgoLTnTypo3tDRwCkZXSccTPHRLhF4ZnjhueYAFpEX6vg.SeyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9lbmRwb2ludCIsInIiOlsiZGlkOmV4YW1wbGU6c29tZW1lZGlhdG9yI3NvbWVrZXkiXSwiYSI6WyJkaWRjb21tL3YyIiwiZGlkY29tbS9haXAyO2Vudj1yZmM1ODciXX0#key-3",
         |           "type": "Ed25519VerificationKey2020",
         |           "controller": "did:peer:2.Ez6LSbysY2xFMRpGMhb7tFTLMpeuPRaqaWM1yECx2AtzE3KCc.Vz6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V.Vz6MkgoLTnTypo3tDRwCkZXSccTPHRLhF4ZnjhueYAFpEX6vg.SeyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9lbmRwb2ludCIsInIiOlsiZGlkOmV4YW1wbGU6c29tZW1lZGlhdG9yI3NvbWVrZXkiXSwiYSI6WyJkaWRjb21tL3YyIiwiZGlkY29tbS9haXAyO2Vudj1yZmM1ODciXX0",
         |           "publicKeyMultibase": "z6MkgoLTnTypo3tDRwCkZXSccTPHRLhF4ZnjhueYAFpEX6vg"
@@ -29,7 +29,7 @@ class PeerDidResolverSpec extends ZSuite {
         |   ],
         |   "keyAgreement": [
         |       {
-        |           "id": "did:peer:2.Ez6LSbysY2xFMRpGMhb7tFTLMpeuPRaqaWM1yECx2AtzE3KCc.Vz6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V.Vz6MkgoLTnTypo3tDRwCkZXSccTPHRLhF4ZnjhueYAFpEX6vg.SeyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9lbmRwb2ludCIsInIiOlsiZGlkOmV4YW1wbGU6c29tZW1lZGlhdG9yI3NvbWVrZXkiXSwiYSI6WyJkaWRjb21tL3YyIiwiZGlkY29tbS9haXAyO2Vudj1yZmM1ODciXX0#6LSbysY2xFMRpGMhb7tFTLMpeuPRaqaWM1yECx2AtzE3KCc",
+        |           "id": "did:peer:2.Ez6LSbysY2xFMRpGMhb7tFTLMpeuPRaqaWM1yECx2AtzE3KCc.Vz6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V.Vz6MkgoLTnTypo3tDRwCkZXSccTPHRLhF4ZnjhueYAFpEX6vg.SeyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9lbmRwb2ludCIsInIiOlsiZGlkOmV4YW1wbGU6c29tZW1lZGlhdG9yI3NvbWVrZXkiXSwiYSI6WyJkaWRjb21tL3YyIiwiZGlkY29tbS9haXAyO2Vudj1yZmM1ODciXX0#key-1",
         |           "type": "X25519KeyAgreementKey2020",
         |           "controller": "did:peer:2.Ez6LSbysY2xFMRpGMhb7tFTLMpeuPRaqaWM1yECx2AtzE3KCc.Vz6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V.Vz6MkgoLTnTypo3tDRwCkZXSccTPHRLhF4ZnjhueYAFpEX6vg.SeyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9lbmRwb2ludCIsInIiOlsiZGlkOmV4YW1wbGU6c29tZW1lZGlhdG9yI3NvbWVrZXkiXSwiYSI6WyJkaWRjb21tL3YyIiwiZGlkY29tbS9haXAyO2Vudj1yZmM1ODciXX0",
         |           "publicKeyMultibase": "z6LSbysY2xFMRpGMhb7tFTLMpeuPRaqaWM1yECx2AtzE3KCc"
@@ -37,15 +37,17 @@ class PeerDidResolverSpec extends ZSuite {
         |   ],
         |   "service": [
         |       {
-        |           "id": "did:peer:2.Ez6LSbysY2xFMRpGMhb7tFTLMpeuPRaqaWM1yECx2AtzE3KCc.Vz6MkqRYqQiSgvZQdnBytw86Qbs2ZWUkGv22od935YF4s8M7V.Vz6MkgoLTnTypo3tDRwCkZXSccTPHRLhF4ZnjhueYAFpEX6vg.SeyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9lbmRwb2ludCIsInIiOlsiZGlkOmV4YW1wbGU6c29tZW1lZGlhdG9yI3NvbWVrZXkiXSwiYSI6WyJkaWRjb21tL3YyIiwiZGlkY29tbS9haXAyO2Vudj1yZmM1ODciXX0#didcommmessaging-0",
+        |           "id": "#service",
         |           "type": "DIDCommMessaging",
-        |           "serviceEndpoint": "https://example.com/endpoint",
-        |           "routingKeys": [
+        |           "serviceEndpoint": {
+        |             "uri" : "https://example.com/endpoint",
+        |             "routingKeys": [
         |               "did:example:somemediator#somekey"
-        |           ],
-        |           "accept": [
+        |             ],
+        |             "accept": [
         |                "didcomm/v2", "didcomm/aip2;env=rfc587"
-        |           ]
+        |             ]
+        |           }
         |       }
         |   ]
         |}""".stripMargin).toOption