diff --git a/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/service/CredentialService.scala b/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/service/CredentialService.scala index d06b1d5dd6..efa651ffc8 100644 --- a/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/service/CredentialService.scala +++ b/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/service/CredentialService.scala @@ -555,9 +555,12 @@ private class CredentialServiceImpl( ) // TODO: get schema when schema registry is available if schema ID is provided credential = W3cCredentialPayload( - `@context` = Set.empty, // TODO: his information should come from Schema registry by record.schemaId + `@context` = Set( + "https://www.w3.org/2018/credentials/v1" + ), // TODO: his information should come from Schema registry by record.schemaId maybeId = None, - `type` = Set.empty, // TODO: This information should come from Schema registry by record.schemaId + `type` = + Set("VerifiableCredential"), // TODO: This information should come from Schema registry by record.schemaId issuer = issuer.did, issuanceDate = issuanceDate, maybeExpirationDate = record.validityPeriod.map(sec => issuanceDate.plusSeconds(sec.toLong)), diff --git a/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/service/PresentationService.scala b/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/service/PresentationService.scala index c0ceb734fd..8d29744fb8 100644 --- a/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/service/PresentationService.scala +++ b/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/service/PresentationService.scala @@ -2,7 +2,9 @@ package io.iohk.atala.pollux.core.service import com.google.protobuf.ByteString import io.circe.Json +import io.circe.parser._ import io.circe.syntax.* +import io.circe._ import io.iohk.atala.pollux.core.model.EncodedJWTCredential import io.iohk.atala.pollux.core.model.PresentationRecord import io.iohk.atala.pollux.core.model.error.PresentationError @@ -29,6 +31,7 @@ import java.security.PublicKey import io.iohk.atala.mercury.protocol.issuecredential.IssueCredential import io.iohk.atala.pollux.core.model.IssueCredentialRecord import io.iohk.atala.pollux.core.repository.CredentialRepository +import org.didcommx.didcomm.message.Attachment.Data.Base64 trait PresentationService { @@ -208,18 +211,23 @@ private class PresentationServiceImpl( ): IO[PresentationError, JWT] = { val verifiableCredentials = issuedCredentials.map { issuedCredential => - JwtVerifiableCredentialPayload(JWT(issuedCredential.signedCredential)) + decode[io.iohk.atala.mercury.model.Base64](issuedCredential.signedCredential) + .map(x => new String(java.util.Base64.getDecoder().decode(x.base64))) + .map(_.drop(1).dropRight(1)) + .map(x => JwtVerifiableCredentialPayload(JWT(x))) + .getOrElse(???) }.toVector + val w3cPresentationPayload = W3cPresentationPayload( - `@context` = IndexedSeq.empty, + `@context` = Vector("https://www.w3.org/2018/presentations/v1"), maybeId = None, `type` = Vector("VerifiablePresentation"), verifiableCredential = verifiableCredentials, holder = prover.did.value, verifier = Vector("https://example.edu/issuers/565049"), // TODO Fix this maybeIssuanceDate = None, - maybeExpirationDate = Some(Instant.parse("2010-01-12T00:00:00Z")) + maybeExpirationDate = None ) val encodedJWT = JwtPresentation.toEncodedJwt(w3cPresentationPayload, prover) @@ -310,6 +318,7 @@ private class PresentationServiceImpl( record <- presentationRepository .getPresentationRecord(record.id) .mapError(RepositoryError.apply) + } yield record } @@ -421,14 +430,6 @@ private class PresentationServiceImpl( } yield record } - private[this] def verifyPresentation( - presentation: Presentation - ) = { - for { - _ <- ZIO.log(s"************Verify Presentation Not Implemented*************") - } yield () - } - private[this] def createDidCommRequestPresentation( proofTypes: Seq[ProofType], thid: UUID, diff --git a/pollux/lib/vc-jwt/src/main/scala/io/iohk/atala/pollux/vc/jwt/JWTVerification.scala b/pollux/lib/vc-jwt/src/main/scala/io/iohk/atala/pollux/vc/jwt/JWTVerification.scala index b98335438a..a1b1031d5b 100644 --- a/pollux/lib/vc-jwt/src/main/scala/io/iohk/atala/pollux/vc/jwt/JWTVerification.scala +++ b/pollux/lib/vc-jwt/src/main/scala/io/iohk/atala/pollux/vc/jwt/JWTVerification.scala @@ -147,8 +147,7 @@ object JWTVerification { curve <- publicKeyJwk.crv x <- publicKeyJwk.x.map(Base64URL.from) y <- publicKeyJwk.y.map(Base64URL.from) - d <- publicKeyJwk.d.map(Base64URL.from) - } yield new ECKey.Builder(Curve.parse(curve), x, y).d(d).build().toPublicKey + } yield new ECKey.Builder(Curve.parse(curve), x, y).build().toPublicKey Validation.fromOptionWith("Unable to parse Public Key")(maybePublicKey) } }