From cfdb22e648fdc36960cc81693557f58700b0e0a4 Mon Sep 17 00:00:00 2001 From: Bassam Riman Date: Fri, 22 Dec 2023 14:27:17 -0500 Subject: [PATCH] feat: fix test Signed-off-by: Bassam Riman --- .../atala/pollux/anoncreds/AnoncredLib.scala | 54 ++--- .../iohk/atala/pollux/anoncreds/Models.scala | 194 +++++++++--------- .../atala/pollux/anoncreds/PoCNewLib.scala | 12 +- .../core/model/IssueCredentialRecord.scala | 4 +- .../repository/CredentialRepository.scala | 4 +- .../CredentialRepositoryInMemory.scala | 4 +- .../CredentialDefinitionServiceImpl.scala | 4 +- .../core/service/CredentialServiceImpl.scala | 30 +-- .../core/service/LinkSecretService.scala | 4 +- .../core/service/LinkSecretServiceImpl.scala | 20 +- .../core/service/PresentationService.scala | 2 +- .../service/PresentationServiceImpl.scala | 30 ++- .../AnoncredPresentationRequestV1.scala | 69 ++----- .../anoncred-presentation-schema-example.json | 2 +- .../service/CredentialServiceImplSpec.scala | 4 +- .../service/LinkSecretServiceImplSpec.scala | 4 +- .../service/PresentationServiceSpec.scala | 159 ++++++++++---- .../PresentationServiceSpecHelper.scala | 26 ++- .../AnoncredPresentationRequestSpec.scala | 56 +++-- .../repository/JdbcCredentialRepository.scala | 10 +- .../http/RequestPresentationInput.scala | 4 - .../controller/IssueControllerTestTools.scala | 4 +- 22 files changed, 381 insertions(+), 319 deletions(-) diff --git a/pollux/lib/anoncreds/src/main/scala/io/iohk/atala/pollux/anoncreds/AnoncredLib.scala b/pollux/lib/anoncreds/src/main/scala/io/iohk/atala/pollux/anoncreds/AnoncredLib.scala index 17138ac3d5..5d6b3c7cf4 100644 --- a/pollux/lib/anoncreds/src/main/scala/io/iohk/atala/pollux/anoncreds/AnoncredLib.scala +++ b/pollux/lib/anoncreds/src/main/scala/io/iohk/atala/pollux/anoncreds/AnoncredLib.scala @@ -18,16 +18,16 @@ object AnoncredLib { version: String, // SCHEMA_Version attr_names: AttributeNames, issuer_id: IssuerId, // ISSUER_DID - ): SchemaDef = uniffi.anoncreds_wrapper.Schema.apply(name, version, attr_names.toSeq.asJava, issuer_id) + ): AnoncredSchemaDef = uniffi.anoncreds_wrapper.Schema.apply(name, version, attr_names.toSeq.asJava, issuer_id) // issuer def createCredDefinition( issuer_id: String, - schema: SchemaDef, + schema: AnoncredSchemaDef, tag: String, supportRevocation: Boolean, signature_type: uniffi.anoncreds_wrapper.SignatureType.CL.type = uniffi.anoncreds_wrapper.SignatureType.CL - ) = { + ): AnoncredCreateCredentialDefinition = { val credentialDefinition: uniffi.anoncreds_wrapper.IssuerCreateCredentialDefinitionReturn = uniffi.anoncreds_wrapper .Issuer() @@ -40,7 +40,7 @@ object AnoncredLib { uniffi.anoncreds_wrapper.CredentialDefinitionConfig(supportRevocation) ) - CreateCredentialDefinition( + AnoncredCreateCredentialDefinition( credentialDefinition.getCredentialDefinition(), credentialDefinition.getCredentialDefinitionPrivate(), credentialDefinition.getCredentialKeyCorrectnessProof() @@ -49,9 +49,9 @@ object AnoncredLib { // issuer def createOffer( - credentialDefinition: CreateCredentialDefinition, + credentialDefinition: AnoncredCreateCredentialDefinition, credentialDefinitionId: String - ): CredentialOffer = + ): AnoncredCredentialOffer = uniffi.anoncreds_wrapper .Issuer() .createCredentialOffer( @@ -62,15 +62,15 @@ object AnoncredLib { // holder def createCredentialRequest( - linkSecret: LinkSecretWithId, - credentialDefinition: CredentialDefinition, - credentialOffer: CredentialOffer, + linkSecret: AnoncredLinkSecretWithId, + credentialDefinition: AnoncredCredentialDefinition, + credentialOffer: AnoncredCredentialOffer, entropy: String = { val tmp = scala.util.Random() tmp.setSeed(java.security.SecureRandom.getInstanceStrong().nextLong()) tmp.nextString(80) } - ): CreateCrendentialRequest = { + ): AnoncredCreateCrendentialRequest = { val credentialRequest = uniffi.anoncreds_wrapper .Prover() @@ -83,16 +83,16 @@ object AnoncredLib { credentialOffer, // CredentialOffer credential_offer ) - CreateCrendentialRequest(credentialRequest.getRequest(), credentialRequest.getMetadata()) + AnoncredCreateCrendentialRequest(credentialRequest.getRequest(), credentialRequest.getMetadata()) } // holder def processCredential( - credential: Credential, - metadata: CredentialRequestMetadata, - linkSecret: LinkSecretWithId, - credentialDefinition: CredentialDefinition, - ): Credential = { + credential: AnoncredCredential, + metadata: AnoncredCredentialRequestMetadata, + linkSecret: AnoncredLinkSecretWithId, + credentialDefinition: AnoncredCredentialDefinition, + ): AnoncredCredential = { uniffi.anoncreds_wrapper .Prover() .processCredential( @@ -106,16 +106,16 @@ object AnoncredLib { // issuer def createCredential( - credentialDefinition: CredentialDefinition, - credentialDefinitionPrivate: CredentialDefinitionPrivate, - credentialOffer: CredentialOffer, - credentialRequest: CredentialRequest, + credentialDefinition: AnoncredCredentialDefinition, + credentialDefinitionPrivate: AnoncredCredentialDefinitionPrivate, + credentialOffer: AnoncredCredentialOffer, + credentialRequest: AnoncredCredentialRequest, attributeValues: Seq[(String, String)] // java.util.List[AttributeValues] : java.util.List[AttributeValues] // revocationRegistryId : String // revocationStatusList : RevocationStatusList // credentialRevocationConfig : CredentialRevocationConfig - ): Credential = { + ): AnoncredCredential = { uniffi.anoncreds_wrapper .Issuer() .createCredential( @@ -141,11 +141,11 @@ object AnoncredLib { def createPresentation( presentationRequest: AnoncredPresentationRequest, - credentialRequests: Seq[CredentialRequests], + credentialRequests: Seq[AnoncredCredentialRequests], selfAttested: Map[String, String], - linkSecret: LinkSecret, - schemas: Map[SchemaId, SchemaDef], - credentialDefinitions: Map[CredentialDefinitionId, CredentialDefinition], + linkSecret: AnoncredLinkSecret, + schemas: Map[SchemaId, AnoncredSchemaDef], + credentialDefinitions: Map[CredentialDefinitionId, AnoncredCredentialDefinition], ): Either[uniffi.anoncreds_wrapper.AnoncredsException.CreatePresentationException, AnoncredPresentation] = { try { Right( @@ -183,8 +183,8 @@ object AnoncredLib { def verifyPresentation( presentation: AnoncredPresentation, presentationRequest: AnoncredPresentationRequest, - schemas: Map[SchemaId, SchemaDef], - credentialDefinitions: Map[CredentialDefinitionId, CredentialDefinition], + schemas: Map[SchemaId, AnoncredSchemaDef], + credentialDefinitions: Map[CredentialDefinitionId, AnoncredCredentialDefinition], ): Boolean = { uniffi.anoncreds_wrapper .Verifier() diff --git a/pollux/lib/anoncreds/src/main/scala/io/iohk/atala/pollux/anoncreds/Models.scala b/pollux/lib/anoncreds/src/main/scala/io/iohk/atala/pollux/anoncreds/Models.scala index 027ce4115f..38f9d4014e 100644 --- a/pollux/lib/anoncreds/src/main/scala/io/iohk/atala/pollux/anoncreds/Models.scala +++ b/pollux/lib/anoncreds/src/main/scala/io/iohk/atala/pollux/anoncreds/Models.scala @@ -21,41 +21,42 @@ import scala.jdk.CollectionConverters.* type AttributeNames = Set[String] type IssuerId = String -case class LinkSecretWithId(id: String, secret: LinkSecret) { def data = secret.data } -object LinkSecretWithId { - def apply(id: String): LinkSecretWithId = LinkSecretWithId(id, LinkSecret()) +case class AnoncredLinkSecretWithId(id: String, secret: AnoncredLinkSecret) { def data = secret.data } +object AnoncredLinkSecretWithId { + def apply(id: String): AnoncredLinkSecretWithId = AnoncredLinkSecretWithId(id, AnoncredLinkSecret()) } -case class LinkSecret(data: String) -object LinkSecret { +case class AnoncredLinkSecret(data: String) +object AnoncredLinkSecret { - def apply(): LinkSecret = LinkSecret.given_Conversion_UniffiLinkSecret_LinkSecret(UniffiLinkSecret()) + def apply(): AnoncredLinkSecret = + AnoncredLinkSecret.given_Conversion_UniffiLinkSecret_AnoncredLinkSecret(UniffiLinkSecret()) - given Conversion[LinkSecret, UniffiLinkSecret] with { - def apply(linkSecret: LinkSecret): UniffiLinkSecret = + given Conversion[AnoncredLinkSecret, UniffiLinkSecret] with { + def apply(linkSecret: AnoncredLinkSecret): UniffiLinkSecret = UniffiLinkSecret.Companion.newFromValue(linkSecret.data) } - given Conversion[UniffiLinkSecret, LinkSecret] with { - def apply(uniffiLinkSecret: UniffiLinkSecret): LinkSecret = - LinkSecret.apply(uniffiLinkSecret.getValue()) + given Conversion[UniffiLinkSecret, AnoncredLinkSecret] with { + def apply(uniffiLinkSecret: UniffiLinkSecret): AnoncredLinkSecret = + AnoncredLinkSecret.apply(uniffiLinkSecret.getValue()) } } //FIXME use same names as in https://hyperledger.github.io/anoncreds-spec/#term:schemas -case class SchemaDef( +case class AnoncredSchemaDef( name: String, // SCHEMA_ID version: String, // SCHEMA_Version attributes: AttributeNames, issuer_id: IssuerId, // ISSUER_DID ) -object SchemaDef { +object AnoncredSchemaDef { - given Conversion[SchemaDef, UniffiSchema] with { - def apply(schemaDef: SchemaDef): UniffiSchema = + given Conversion[AnoncredSchemaDef, UniffiSchema] with { + def apply(schemaDef: AnoncredSchemaDef): UniffiSchema = UniffiSchema.apply( schemaDef.name, schemaDef.version, @@ -65,9 +66,9 @@ object SchemaDef { } - given Conversion[UniffiSchema, SchemaDef] with { - def apply(schema: UniffiSchema): SchemaDef = - SchemaDef.apply( + given Conversion[UniffiSchema, AnoncredSchemaDef] with { + def apply(schema: UniffiSchema): AnoncredSchemaDef = + AnoncredSchemaDef.apply( name = schema.getName(), version = schema.getVersion(), attributes = schema.getAttrNames().asScala.toSet, @@ -106,20 +107,20 @@ object SchemaDef { // value: String, // issuerId: String, // ) -case class CredentialDefinition(data: String) { // TODO - def schemaId = CredentialDefinition - .given_Conversion_CredentialDefinition_UniffiCredentialDefinition(this) +case class AnoncredCredentialDefinition(data: String) { // TODO + def schemaId = AnoncredCredentialDefinition + .given_Conversion_AnoncredCredentialDefinition_UniffiCredentialDefinition(this) .getSchemaId() } -object CredentialDefinition { - given Conversion[CredentialDefinition, UniffiCredentialDefinition] with { - def apply(credentialDefinition: CredentialDefinition): UniffiCredentialDefinition = +object AnoncredCredentialDefinition { + given Conversion[AnoncredCredentialDefinition, UniffiCredentialDefinition] with { + def apply(credentialDefinition: AnoncredCredentialDefinition): UniffiCredentialDefinition = UniffiCredentialDefinition(credentialDefinition.data) } - given Conversion[UniffiCredentialDefinition, CredentialDefinition] with { - def apply(credentialDefinition: UniffiCredentialDefinition): CredentialDefinition = - CredentialDefinition(credentialDefinition.getJson()) + given Conversion[UniffiCredentialDefinition, AnoncredCredentialDefinition] with { + def apply(credentialDefinition: UniffiCredentialDefinition): AnoncredCredentialDefinition = + AnoncredCredentialDefinition(credentialDefinition.getJson()) } } @@ -134,90 +135,94 @@ object CredentialDefinition { // "r_key": null // } // } -case class CredentialDefinitionPrivate(data: String) -object CredentialDefinitionPrivate { - given Conversion[CredentialDefinitionPrivate, UniffiCredentialDefinitionPrivate] with { - def apply(credentialDefinitionPrivate: CredentialDefinitionPrivate): UniffiCredentialDefinitionPrivate = +case class AnoncredCredentialDefinitionPrivate(data: String) +object AnoncredCredentialDefinitionPrivate { + given Conversion[AnoncredCredentialDefinitionPrivate, UniffiCredentialDefinitionPrivate] with { + def apply(credentialDefinitionPrivate: AnoncredCredentialDefinitionPrivate): UniffiCredentialDefinitionPrivate = UniffiCredentialDefinitionPrivate(credentialDefinitionPrivate.data) } - given Conversion[UniffiCredentialDefinitionPrivate, CredentialDefinitionPrivate] with { - def apply(credentialDefinitionPrivate: UniffiCredentialDefinitionPrivate): CredentialDefinitionPrivate = - CredentialDefinitionPrivate(credentialDefinitionPrivate.getJson()) + given Conversion[UniffiCredentialDefinitionPrivate, AnoncredCredentialDefinitionPrivate] with { + def apply(credentialDefinitionPrivate: UniffiCredentialDefinitionPrivate): AnoncredCredentialDefinitionPrivate = + AnoncredCredentialDefinitionPrivate(credentialDefinitionPrivate.getJson()) } } // **************************************************************************** -case class CredentialKeyCorrectnessProof(data: String) -object CredentialKeyCorrectnessProof { - given Conversion[CredentialKeyCorrectnessProof, UniffiCredentialKeyCorrectnessProof] with { - def apply(credentialKeyCorrectnessProof: CredentialKeyCorrectnessProof): UniffiCredentialKeyCorrectnessProof = +case class AnoncredCredentialKeyCorrectnessProof(data: String) +object AnoncredCredentialKeyCorrectnessProof { + given Conversion[AnoncredCredentialKeyCorrectnessProof, UniffiCredentialKeyCorrectnessProof] with { + def apply( + credentialKeyCorrectnessProof: AnoncredCredentialKeyCorrectnessProof + ): UniffiCredentialKeyCorrectnessProof = UniffiCredentialKeyCorrectnessProof(credentialKeyCorrectnessProof.data) } - given Conversion[UniffiCredentialKeyCorrectnessProof, CredentialKeyCorrectnessProof] with { - def apply(credentialKeyCorrectnessProof: UniffiCredentialKeyCorrectnessProof): CredentialKeyCorrectnessProof = - CredentialKeyCorrectnessProof(credentialKeyCorrectnessProof.getJson()) + given Conversion[UniffiCredentialKeyCorrectnessProof, AnoncredCredentialKeyCorrectnessProof] with { + def apply( + credentialKeyCorrectnessProof: UniffiCredentialKeyCorrectnessProof + ): AnoncredCredentialKeyCorrectnessProof = + AnoncredCredentialKeyCorrectnessProof(credentialKeyCorrectnessProof.getJson()) } } -case class CreateCredentialDefinition( - cd: CredentialDefinition, - cdPrivate: CredentialDefinitionPrivate, - proofKey: CredentialKeyCorrectnessProof, +case class AnoncredCreateCredentialDefinition( + cd: AnoncredCredentialDefinition, + cdPrivate: AnoncredCredentialDefinitionPrivate, + proofKey: AnoncredCredentialKeyCorrectnessProof, ) // **************************************************************************** -case class CredentialOffer(data: String) { - lazy val schemaId = CredentialOffer - .given_Conversion_CredentialOffer_UniffiCredentialOffer(this) +case class AnoncredCredentialOffer(data: String) { + lazy val schemaId = AnoncredCredentialOffer + .given_Conversion_AnoncredCredentialOffer_UniffiCredentialOffer(this) .getSchemaId() - lazy val credDefId = CredentialOffer - .given_Conversion_CredentialOffer_UniffiCredentialOffer(this) + lazy val credDefId = AnoncredCredentialOffer + .given_Conversion_AnoncredCredentialOffer_UniffiCredentialOffer(this) .getCredDefId() } -object CredentialOffer { - given Conversion[CredentialOffer, UniffiCredentialOffer] with { - def apply(credentialOffer: CredentialOffer): UniffiCredentialOffer = +object AnoncredCredentialOffer { + given Conversion[AnoncredCredentialOffer, UniffiCredentialOffer] with { + def apply(credentialOffer: AnoncredCredentialOffer): UniffiCredentialOffer = UniffiCredentialOffer(credentialOffer.data) } - given Conversion[UniffiCredentialOffer, CredentialOffer] with { - def apply(credentialOffer: UniffiCredentialOffer): CredentialOffer = - CredentialOffer(credentialOffer.getJson()) + given Conversion[UniffiCredentialOffer, AnoncredCredentialOffer] with { + def apply(credentialOffer: UniffiCredentialOffer): AnoncredCredentialOffer = + AnoncredCredentialOffer(credentialOffer.getJson()) } } // **************************************************************************** -case class CreateCrendentialRequest( - request: CredentialRequest, - metadata: CredentialRequestMetadata +case class AnoncredCreateCrendentialRequest( + request: AnoncredCredentialRequest, + metadata: AnoncredCredentialRequestMetadata ) -case class CredentialRequest(data: String) -object CredentialRequest { +case class AnoncredCredentialRequest(data: String) +object AnoncredCredentialRequest { - given Conversion[CredentialRequest, UniffiCredentialRequest] with { - def apply(credentialRequest: CredentialRequest): UniffiCredentialRequest = + given Conversion[AnoncredCredentialRequest, UniffiCredentialRequest] with { + def apply(credentialRequest: AnoncredCredentialRequest): UniffiCredentialRequest = UniffiCredentialRequest(credentialRequest.data) } - given Conversion[UniffiCredentialRequest, CredentialRequest] with { - def apply(credentialRequest: UniffiCredentialRequest): CredentialRequest = - CredentialRequest(credentialRequest.getJson()) + given Conversion[UniffiCredentialRequest, AnoncredCredentialRequest] with { + def apply(credentialRequest: UniffiCredentialRequest): AnoncredCredentialRequest = + AnoncredCredentialRequest(credentialRequest.getJson()) } } -case class CredentialRequestMetadata( +case class AnoncredCredentialRequestMetadata( linkSecretBlinding: String, nonce: String, linkSecretName: String, ) -object CredentialRequestMetadata { - given Conversion[CredentialRequestMetadata, UniffiCredentialRequestMetadata] with { - def apply(credentialRequestMetadata: CredentialRequestMetadata): UniffiCredentialRequestMetadata = +object AnoncredCredentialRequestMetadata { + given Conversion[AnoncredCredentialRequestMetadata, UniffiCredentialRequestMetadata] with { + def apply(credentialRequestMetadata: AnoncredCredentialRequestMetadata): UniffiCredentialRequestMetadata = UniffiCredentialRequestMetadata( /*link_secret_blinding_data*/ credentialRequestMetadata.linkSecretBlinding, /*nonce*/ Nonce.Companion.newFromValue(credentialRequestMetadata.nonce), @@ -225,62 +230,63 @@ object CredentialRequestMetadata { ) } - given Conversion[UniffiCredentialRequestMetadata, CredentialRequestMetadata] with { - def apply(credentialRequestMetadata: UniffiCredentialRequestMetadata): CredentialRequestMetadata = - CredentialRequestMetadata( + given Conversion[UniffiCredentialRequestMetadata, AnoncredCredentialRequestMetadata] with { + def apply(credentialRequestMetadata: UniffiCredentialRequestMetadata): AnoncredCredentialRequestMetadata = + AnoncredCredentialRequestMetadata( linkSecretBlinding = credentialRequestMetadata.getLinkSecretBlindingData(), nonce = credentialRequestMetadata.getNonce().getValue(), linkSecretName = credentialRequestMetadata.getLinkSecretName(), ) } - given JsonDecoder[CredentialRequestMetadata] = DeriveJsonDecoder.gen[CredentialRequestMetadata] - given JsonEncoder[CredentialRequestMetadata] = DeriveJsonEncoder.gen[CredentialRequestMetadata] + given JsonDecoder[AnoncredCredentialRequestMetadata] = DeriveJsonDecoder.gen[AnoncredCredentialRequestMetadata] + given JsonEncoder[AnoncredCredentialRequestMetadata] = DeriveJsonEncoder.gen[AnoncredCredentialRequestMetadata] } // **************************************************************************** //Credential -case class Credential(data: String) { - lazy val credDefId: String = Credential - .given_Conversion_Credential_UniffiCredential(this) +case class AnoncredCredential(data: String) { + lazy val credDefId: String = AnoncredCredential + .given_Conversion_AnoncredCredential_UniffiCredential(this) .getCredDefId } -object Credential { - given Conversion[Credential, UniffiCredential] with { - def apply(credential: Credential): UniffiCredential = +object AnoncredCredential { + given Conversion[AnoncredCredential, UniffiCredential] with { + def apply(credential: AnoncredCredential): UniffiCredential = UniffiCredential(credential.data) } - given Conversion[UniffiCredential, Credential] with { - def apply(credential: UniffiCredential): Credential = - Credential(credential.getJson()) + given Conversion[UniffiCredential, AnoncredCredential] with { + def apply(credential: UniffiCredential): AnoncredCredential = + AnoncredCredential(credential.getJson()) } } // **************************************************************************** -case class CredentialRequests( - credential: Credential, +case class AnoncredCredentialRequests( + credential: AnoncredCredential, requestedAttribute: Seq[String], requestedPredicate: Seq[String], ) -object CredentialRequests { - given Conversion[CredentialRequests, UniffiCredentialRequests] with { +object AnoncredCredentialRequests { + given Conversion[AnoncredCredentialRequests, UniffiCredentialRequests] with { import uniffi.anoncreds_wrapper.RequestedAttribute import uniffi.anoncreds_wrapper.RequestedPredicate - def apply(credentialRequests: CredentialRequests): UniffiCredentialRequests = { - val credential = Credential.given_Conversion_Credential_UniffiCredential(credentialRequests.credential) + def apply(credentialRequests: AnoncredCredentialRequests): UniffiCredentialRequests = { + val credential = + AnoncredCredential.given_Conversion_AnoncredCredential_UniffiCredential(credentialRequests.credential) val requestedAttributes = credentialRequests.requestedAttribute.map(a => RequestedAttribute(a, true)) val requestedPredicates = credentialRequests.requestedPredicate.map(p => RequestedPredicate(p)) UniffiCredentialRequests(credential, requestedAttributes.asJava, requestedPredicates.asJava) } } - given Conversion[UniffiCredentialRequests, CredentialRequests] with { - def apply(credentialRequests: UniffiCredentialRequests): CredentialRequests = { - CredentialRequests( - Credential.given_Conversion_UniffiCredential_Credential(credentialRequests.getCredential()), + given Conversion[UniffiCredentialRequests, AnoncredCredentialRequests] with { + def apply(credentialRequests: UniffiCredentialRequests): AnoncredCredentialRequests = { + AnoncredCredentialRequests( + AnoncredCredential.given_Conversion_UniffiCredential_AnoncredCredential(credentialRequests.getCredential()), credentialRequests .getRequestedAttribute() .asScala diff --git a/pollux/lib/anoncredsTest/src/test/scala/io/iohk/atala/pollux/anoncreds/PoCNewLib.scala b/pollux/lib/anoncredsTest/src/test/scala/io/iohk/atala/pollux/anoncreds/PoCNewLib.scala index 98cda7596b..fd75b61a4b 100644 --- a/pollux/lib/anoncredsTest/src/test/scala/io/iohk/atala/pollux/anoncreds/PoCNewLib.scala +++ b/pollux/lib/anoncredsTest/src/test/scala/io/iohk/atala/pollux/anoncreds/PoCNewLib.scala @@ -15,13 +15,13 @@ class PoCNewLib extends AnyFlatSpec { "LinkSecret" should "be able to parse back to the anoncreds lib" in { import scala.language.implicitConversions - val ls1 = LinkSecret("65965334953670062552662719679603258895632947953618378932199361160021795698890") + val ls1 = AnoncredLinkSecret("65965334953670062552662719679603258895632947953618378932199361160021795698890") val ls1p = ls1: uniffi.anoncreds_wrapper.LinkSecret assert(ls1p.getValue() == "65965334953670062552662719679603258895632947953618378932199361160021795698890") - val ls0 = LinkSecret() + val ls0 = AnoncredLinkSecret() val ls0p = ls0: uniffi.anoncreds_wrapper.LinkSecret - val ls0_ = ls0p: LinkSecret + val ls0_ = ls0p: AnoncredLinkSecret assert(ls0.data == ls0_.data) } @@ -58,8 +58,8 @@ class PoCNewLib extends AnyFlatSpec { // ############## println("*** holder " + ("*" * 100)) - val ls1 = LinkSecret("65965334953670062552662719679603258895632947953618378932199361160021795698890") - val linkSecret = LinkSecretWithId("ID_of_some_secret_1", ls1) + val ls1 = AnoncredLinkSecret("65965334953670062552662719679603258895632947953618378932199361160021795698890") + val linkSecret = AnoncredLinkSecretWithId("ID_of_some_secret_1", ls1) val credentialRequest = AnoncredLib.createCredentialRequest(linkSecret, credentialDefinition.cd, credentialOffer) println("*" * 100) @@ -109,7 +109,7 @@ class PoCNewLib extends AnyFlatSpec { val presentation = AnoncredLib.createPresentation( presentationRequest, // : PresentationRequest, Seq( - CredentialRequests(processedCredential, Seq("sex"), Seq("age")) + AnoncredCredentialRequests(processedCredential, Seq("sex"), Seq("age")) ), // credentials: Seq[Credential], Map(), // selfAttested: Map[String, String], linkSecret.secret, // linkSecret: LinkSecret, diff --git a/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/model/IssueCredentialRecord.scala b/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/model/IssueCredentialRecord.scala index 7ec80dcde7..1551c85f53 100644 --- a/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/model/IssueCredentialRecord.scala +++ b/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/model/IssueCredentialRecord.scala @@ -9,7 +9,7 @@ import io.iohk.atala.mercury.protocol.issuecredential.{ OfferCredential, RequestCredential } -import io.iohk.atala.pollux.anoncreds.CredentialRequestMetadata +import io.iohk.atala.pollux.anoncreds.AnoncredCredentialRequestMetadata import io.iohk.atala.pollux.core.model.IssueCredentialRecord.* import java.time.Instant @@ -31,7 +31,7 @@ final case class IssueCredentialRecord( protocolState: ProtocolState, offerCredentialData: Option[OfferCredential], requestCredentialData: Option[RequestCredential], - anonCredsRequestMetadata: Option[CredentialRequestMetadata], + anonCredsRequestMetadata: Option[AnoncredCredentialRequestMetadata], issueCredentialData: Option[IssueCredential], issuedCredentialRaw: Option[String], issuingDID: Option[CanonicalPrismDID], diff --git a/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/repository/CredentialRepository.scala b/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/repository/CredentialRepository.scala index 186bc0276c..2f2b9615e5 100644 --- a/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/repository/CredentialRepository.scala +++ b/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/repository/CredentialRepository.scala @@ -1,7 +1,7 @@ package io.iohk.atala.pollux.core.repository import io.iohk.atala.mercury.protocol.issuecredential.{IssueCredential, RequestCredential} -import io.iohk.atala.pollux.anoncreds.CredentialRequestMetadata +import io.iohk.atala.pollux.anoncreds.AnoncredCredentialRequestMetadata import io.iohk.atala.pollux.core.model.* import io.iohk.atala.pollux.core.model.IssueCredentialRecord.ProtocolState import io.iohk.atala.shared.models.WalletAccessContext @@ -53,7 +53,7 @@ trait CredentialRepository { def updateWithAnonCredsRequestCredential( recordId: DidCommID, request: RequestCredential, - metadata: CredentialRequestMetadata, + metadata: AnoncredCredentialRequestMetadata, protocolState: ProtocolState ): RIO[WalletAccessContext, Int] diff --git a/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/repository/CredentialRepositoryInMemory.scala b/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/repository/CredentialRepositoryInMemory.scala index 5b2ba4dbea..c329a2548a 100644 --- a/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/repository/CredentialRepositoryInMemory.scala +++ b/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/repository/CredentialRepositoryInMemory.scala @@ -1,7 +1,7 @@ package io.iohk.atala.pollux.core.repository import io.iohk.atala.mercury.protocol.issuecredential.{IssueCredential, RequestCredential} -import io.iohk.atala.pollux.anoncreds.CredentialRequestMetadata +import io.iohk.atala.pollux.anoncreds.AnoncredCredentialRequestMetadata import io.iohk.atala.pollux.core.model.* import io.iohk.atala.pollux.core.model.IssueCredentialRecord.ProtocolState import io.iohk.atala.pollux.core.model.error.CredentialRepositoryError.* @@ -315,7 +315,7 @@ class CredentialRepositoryInMemory( override def updateWithAnonCredsRequestCredential( recordId: DidCommID, request: RequestCredential, - metadata: CredentialRequestMetadata, + metadata: AnoncredCredentialRequestMetadata, protocolState: ProtocolState ): RIO[WalletAccessContext, RuntimeFlags] = { for { diff --git a/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/service/CredentialDefinitionServiceImpl.scala b/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/service/CredentialDefinitionServiceImpl.scala index 7aca15f038..601207b260 100644 --- a/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/service/CredentialDefinitionServiceImpl.scala +++ b/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/service/CredentialDefinitionServiceImpl.scala @@ -2,7 +2,7 @@ package io.iohk.atala.pollux.core.service import io.iohk.atala.agent.walletapi.storage import io.iohk.atala.agent.walletapi.storage.GenericSecretStorage -import io.iohk.atala.pollux.anoncreds.{AnoncredLib, SchemaDef} +import io.iohk.atala.pollux.anoncreds.{AnoncredLib, AnoncredSchemaDef} import io.iohk.atala.pollux.core.model.error.CredentialSchemaError import io.iohk.atala.pollux.core.model.error.CredentialSchemaError.URISyntaxError import io.iohk.atala.pollux.core.model.schema.CredentialDefinition.{Filter, FilteredEntries} @@ -39,7 +39,7 @@ class CredentialDefinitionServiceImpl( vcSchema <- parseCredentialSchema(content) anoncredSchema <- AnoncredSchemaSerDesV1.schemaSerDes.deserialize(vcSchema.schema) anoncredLibSchema = - SchemaDef( + AnoncredSchemaDef( in.schemaId, anoncredSchema.version, anoncredSchema.attrNames, diff --git a/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/service/CredentialServiceImpl.scala b/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/service/CredentialServiceImpl.scala index 2550e62047..1c26452fe2 100644 --- a/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/service/CredentialServiceImpl.scala +++ b/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/service/CredentialServiceImpl.scala @@ -10,7 +10,7 @@ import io.iohk.atala.castor.core.service.DIDService import io.iohk.atala.mercury.model.* import io.iohk.atala.mercury.protocol.issuecredential.* import io.iohk.atala.pollux.* -import io.iohk.atala.pollux.anoncreds.{AnoncredLib, CreateCredentialDefinition, CredentialOffer} +import io.iohk.atala.pollux.anoncreds.{AnoncredLib, AnoncredCreateCredentialDefinition, AnoncredCredentialOffer} import io.iohk.atala.pollux.core.model.* import io.iohk.atala.pollux.core.model.CredentialFormat.AnonCreds import io.iohk.atala.pollux.core.model.IssueCredentialRecord.ProtocolState.OfferReceived @@ -318,7 +318,7 @@ private class CredentialServiceImpl( case Base64(value) => for { _ <- ZIO - .attempt(CredentialOffer(value)) + .attempt(AnoncredCredentialOffer(value)) .mapError(e => CredentialServiceError.UnexpectedError( s"Unexpected error parsing credential offer attachment: ${e.toString}" @@ -536,12 +536,12 @@ private class CredentialServiceImpl( } ) .mapError(_ => InvalidFlowStateError(s"No AnonCreds offer attachment found")) - credentialOffer = anoncreds.CredentialOffer(attachmentData) + credentialOffer = anoncreds.AnoncredCredentialOffer(attachmentData) _ <- ZIO.logInfo(s"Cred def ID => ${credentialOffer.getCredDefId}") credDefContent <- uriDereferencer .dereference(new URI(credentialOffer.getCredDefId)) .mapError(err => UnexpectedError(err.toString)) - credentialDefinition = anoncreds.CredentialDefinition(credDefContent) + credentialDefinition = anoncreds.AnoncredCredentialDefinition(credDefContent) linkSecret <- linkSecretService .fetchOrCreate() .mapError(e => CredentialServiceError.LinkSecretError.apply(e.cause)) @@ -644,11 +644,11 @@ private class CredentialServiceImpl( private[this] def processAnonCredsCredential(record: IssueCredentialRecord, credentialBytes: Array[Byte]) = { for { - credential <- ZIO.succeed(anoncreds.Credential(new String(credentialBytes))) + credential <- ZIO.succeed(anoncreds.AnoncredCredential(new String(credentialBytes))) credDefContent <- uriDereferencer .dereference(new URI(credential.getCredDefId)) .mapError(err => UnexpectedError(err.toString)) - credentialDefinition = anoncreds.CredentialDefinition(credDefContent) + credentialDefinition = anoncreds.AnoncredCredentialDefinition(credDefContent) metadata <- ZIO .fromOption(record.anonCredsRequestMetadata) .mapError(_ => CredentialServiceError.UnexpectedError(s"No request metadata Id found un record: ${record.id}")) @@ -658,7 +658,7 @@ private class CredentialServiceImpl( _ <- ZIO .attempt( AnoncredLib.processCredential( - anoncreds.Credential(new String(credentialBytes)), + anoncreds.AnoncredCredential(new String(credentialBytes)), metadata, linkSecret, credentialDefinition @@ -856,16 +856,16 @@ private class CredentialServiceImpl( credentialDefinition <- credentialDefinitionService .getByGUID(credentialDefinitionGUID) .mapError(e => CredentialServiceError.UnexpectedError(e.toString)) - cd = anoncreds.CredentialDefinition(credentialDefinition.definition.toString) - kcp = anoncreds.CredentialKeyCorrectnessProof(credentialDefinition.keyCorrectnessProof.toString) + cd = anoncreds.AnoncredCredentialDefinition(credentialDefinition.definition.toString) + kcp = anoncreds.AnoncredCredentialKeyCorrectnessProof(credentialDefinition.keyCorrectnessProof.toString) maybeCredentialDefinitionSecret <- genericSecretStorage .get[UUID, CredentialDefinitionSecret](credentialDefinition.guid) .orDie credentialDefinitionSecret <- ZIO .fromOption(maybeCredentialDefinitionSecret) .mapError(_ => CredentialServiceError.CredentialDefinitionPrivatePartNotFound(credentialDefinition.guid)) - cdp = anoncreds.CredentialDefinitionPrivate(credentialDefinitionSecret.json.toString) - createCredentialDefinition = CreateCredentialDefinition(cd, cdp, kcp) + cdp = anoncreds.AnoncredCredentialDefinitionPrivate(credentialDefinitionSecret.json.toString) + createCredentialDefinition = AnoncredCreateCredentialDefinition(cd, cdp, kcp) offer = AnoncredLib.createOffer(createCredentialDefinition, credentialDefinitionId) } yield offer @@ -1069,7 +1069,7 @@ private class CredentialServiceImpl( credentialDefinition <- credentialDefinitionService .getByGUID(credentialDefinitionId) .mapError(e => CredentialServiceError.UnexpectedError(e.toString)) - cd = anoncreds.CredentialDefinition(credentialDefinition.definition.toString) + cd = anoncreds.AnoncredCredentialDefinition(credentialDefinition.definition.toString) offerCredential <- ZIO .fromOption(record.offerCredentialData) .mapError(_ => InvalidFlowStateError(s"No offer found for this record: ${record.id}")) @@ -1084,7 +1084,7 @@ private class CredentialServiceImpl( } ) .mapError(_ => InvalidFlowStateError(s"No AnonCreds offer attachment found")) - credentialOffer = anoncreds.CredentialOffer(offerCredentialAttachmentData) + credentialOffer = anoncreds.AnoncredCredentialOffer(offerCredentialAttachmentData) requestCredential <- ZIO .fromOption(record.requestCredentialData) .mapError(_ => InvalidFlowStateError(s"No request found for this record: ${record.id}")) @@ -1099,7 +1099,7 @@ private class CredentialServiceImpl( } ) .mapError(_ => InvalidFlowStateError(s"No AnonCreds request attachment found")) - credentialRequest = anoncreds.CredentialRequest(requestCredentialAttachmentData) + credentialRequest = anoncreds.AnoncredCredentialRequest(requestCredentialAttachmentData) attrValues = offerCredential.body.credential_preview.body.attributes.map { attr => (attr.name, attr.value) } @@ -1109,7 +1109,7 @@ private class CredentialServiceImpl( credentialDefinitionSecret <- ZIO .fromOption(maybeCredentialDefinitionSecret) .mapError(_ => CredentialServiceError.CredentialDefinitionPrivatePartNotFound(credentialDefinition.guid)) - cdp = anoncreds.CredentialDefinitionPrivate(credentialDefinitionSecret.json.toString) + cdp = anoncreds.AnoncredCredentialDefinitionPrivate(credentialDefinitionSecret.json.toString) credential = AnoncredLib.createCredential( cd, cdp, diff --git a/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/service/LinkSecretService.scala b/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/service/LinkSecretService.scala index c87c63e6ed..f0d6aa2448 100644 --- a/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/service/LinkSecretService.scala +++ b/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/service/LinkSecretService.scala @@ -1,6 +1,6 @@ package io.iohk.atala.pollux.core.service -import io.iohk.atala.pollux.anoncreds.LinkSecretWithId +import io.iohk.atala.pollux.anoncreds.AnoncredLinkSecretWithId import io.iohk.atala.pollux.core.model.error.LinkSecretError import io.iohk.atala.shared.models.WalletAccessContext import zio.ZIO @@ -8,5 +8,5 @@ import zio.ZIO trait LinkSecretService { type Result[T] = ZIO[WalletAccessContext, LinkSecretError, T] - def fetchOrCreate(): Result[LinkSecretWithId] + def fetchOrCreate(): Result[AnoncredLinkSecretWithId] } diff --git a/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/service/LinkSecretServiceImpl.scala b/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/service/LinkSecretServiceImpl.scala index 4219d2bbd0..88e51199be 100644 --- a/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/service/LinkSecretServiceImpl.scala +++ b/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/service/LinkSecretServiceImpl.scala @@ -1,7 +1,7 @@ package io.iohk.atala.pollux.core.service import io.iohk.atala.agent.walletapi.storage.{GenericSecret, GenericSecretStorage} -import io.iohk.atala.pollux.anoncreds.{LinkSecret, LinkSecretWithId} +import io.iohk.atala.pollux.anoncreds.{AnoncredLinkSecret, AnoncredLinkSecretWithId} import io.iohk.atala.pollux.core.model.error.LinkSecretError import io.iohk.atala.shared.models.WalletAccessContext import zio.* @@ -15,18 +15,18 @@ class LinkSecretServiceImpl(genericSecretStorage: GenericSecretStorage) extends type Result[T] = ZIO[WalletAccessContext, LinkSecretError, T] - override def fetchOrCreate(): Result[LinkSecretWithId] = { + override def fetchOrCreate(): Result[AnoncredLinkSecretWithId] = { genericSecretStorage - .get[String, LinkSecret](LinkSecretServiceImpl.defaultLinkSecretId) + .get[String, AnoncredLinkSecret](LinkSecretServiceImpl.defaultLinkSecretId) .flatMap { case Some(secret) => ZIO.succeed(secret) case None => - val linkSecret = LinkSecret() + val linkSecret = AnoncredLinkSecret() genericSecretStorage - .set[String, LinkSecret](LinkSecretServiceImpl.defaultLinkSecretId, linkSecret) + .set[String, AnoncredLinkSecret](LinkSecretServiceImpl.defaultLinkSecretId, linkSecret) .as(linkSecret) } - .map(linkSecret => LinkSecretWithId(LinkSecretServiceImpl.defaultLinkSecretId, linkSecret)) + .map(linkSecret => AnoncredLinkSecretWithId(LinkSecretServiceImpl.defaultLinkSecretId, linkSecret)) .mapError(LinkSecretError.apply) } } @@ -40,13 +40,13 @@ object LinkSecretServiceImpl { ] = ZLayer.fromFunction(LinkSecretServiceImpl(_)) - given GenericSecret[String, LinkSecret] = new { + given GenericSecret[String, AnoncredLinkSecret] = new { override def keyPath(id: String): String = s"link-secret/${id.toString}" - override def encodeValue(secret: LinkSecret): Json = Json.Str(secret.data) + override def encodeValue(secret: AnoncredLinkSecret): Json = Json.Str(secret.data) - override def decodeValue(json: Json): Try[LinkSecret] = json match { - case Json.Str(data) => Try(LinkSecret(data)) + override def decodeValue(json: Json): Try[AnoncredLinkSecret] = json match { + case Json.Str(data) => Try(AnoncredLinkSecret(data)) case _ => scala.util.Failure(new Exception("Invalid JSON format for LinkSecret")) } } 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 80d9dfca46..9727983870 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 @@ -49,7 +49,7 @@ trait PresentationService { record: DidCommID, issuer: Issuer, anoncredCredentialProof: AnoncredCredentialProofsV1, - issuanceDate: Instant, + issuanceDate: Instant ): ZIO[WalletAccessContext, PresentationError, AnoncredPresentation] def createAnoncredPresentation( diff --git a/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/service/PresentationServiceImpl.scala b/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/service/PresentationServiceImpl.scala index 1c833ae65d..0afd246161 100644 --- a/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/service/PresentationServiceImpl.scala +++ b/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/service/PresentationServiceImpl.scala @@ -517,7 +517,10 @@ private class PresentationServiceImpl( credentialDefinition <- credentialDefinitionService .getByGUID(credentialDefinitionId) .mapError(e => UnexpectedError(e.toString)) - } yield (credentialDefinition.longId, CredentialDefinition(credentialDefinition.definition.toString)) + } yield ( + credentialDefinition.longId, + AnoncredCredentialDefinition(credentialDefinition.definition.toString) + ) }) .map(_.toMap) credentialProofsMap = credentialProofs.map(credentialProof => (credentialProof.credential, credentialProof)).toMap @@ -563,18 +566,20 @@ private class PresentationServiceImpl( .fetchOrCreate() .map(_.secret) .mapError(t => AnoncredPresentationCreationError(t.cause)) + credentialRequest = + verifiableCredentials.map(verifiableCredential => + AnoncredCredentialRequests( + AnoncredCredential(verifiableCredential.credential), + verifiableCredential.requestedAttribute, + verifiableCredential.requestedPredicate + ) + ) presentation <- ZIO .fromEither( AnoncredLib.createPresentation( AnoncredPresentationRequest(presentationRequestData), - verifiableCredentials.map(verifiableCredential => - CredentialRequests( - Credential(verifiableCredential.credential), - verifiableCredential.requestedAttribute, - verifiableCredential.requestedPredicate - ) - ), + credentialRequest, Map.empty, // TO FIX linkSecret, schemaMap, @@ -585,7 +590,7 @@ private class PresentationServiceImpl( } yield presentation } - private def resolveSchema(schemaId: String): IO[UnexpectedError, (String, SchemaDef)] = { + private def resolveSchema(schemaId: String): IO[UnexpectedError, (String, AnoncredSchemaDef)] = { for { uri <- ZIO.attempt(new URI(schemaId)).mapError(e => UnexpectedError(e.getMessage)) content <- uriDereferencer.dereference(uri).mapError(e => UnexpectedError(e.error)) @@ -594,7 +599,7 @@ private class PresentationServiceImpl( .deserialize(vcSchema.schema) .mapError(e => UnexpectedError(e.error)) anoncredLibSchema = - SchemaDef( + AnoncredSchemaDef( schemaId, anoncredSchema.version, anoncredSchema.attrNames, @@ -962,7 +967,10 @@ private class PresentationServiceImpl( credentialDefinition <- credentialDefinitionService .getByGUID(credentialDefinitionId) .mapError(e => UnexpectedError(e.toString)) - } yield (credentialDefinition.longId, CredentialDefinition(credentialDefinition.definition.toString)) + } yield ( + credentialDefinition.longId, + AnoncredCredentialDefinition(credentialDefinition.definition.toString) + ) }) .map(_.toMap) serialisedPresentation <- presentation.attachments.head.data match { diff --git a/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/service/serdes/AnoncredPresentationRequestV1.scala b/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/service/serdes/AnoncredPresentationRequestV1.scala index c4063533eb..e16fe79fff 100644 --- a/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/service/serdes/AnoncredPresentationRequestV1.scala +++ b/pollux/lib/core/src/main/scala/io/iohk/atala/pollux/core/service/serdes/AnoncredPresentationRequestV1.scala @@ -13,24 +13,17 @@ case class AnoncredPresentationRequestV1( non_revoked: Option[AnoncredNonRevokedIntervalV1] ) -case class AnoncredRequestedAttributeV1(name: String, restrictions: List[AnoncredAttributeRestrictionV1]) +case class AnoncredRequestedAttributeV1( + name: String, + restrictions: List[Map[String, String]], + non_revoked: Option[AnoncredNonRevokedIntervalV1] +) case class AnoncredRequestedPredicateV1( name: String, p_type: String, p_value: Int, - restrictions: List[AnoncredPredicateRestrictionV1] -) - -case class AnoncredAttributeRestrictionV1( - schema_id: Option[String], - cred_def_id: Option[String], - non_revoked: Option[AnoncredNonRevokedIntervalV1] -) - -case class AnoncredPredicateRestrictionV1( - schema_id: Option[String], - cred_def_id: Option[String], + restrictions: List[Map[String, String]], non_revoked: Option[AnoncredNonRevokedIntervalV1] ) @@ -54,20 +47,16 @@ object AnoncredPresentationRequestV1 { | "restrictions": { | "type": "array", | "items": { - | "type": "object", - | "properties": { - | "schema_id": { "type": "string" }, - | "cred_def_id": { "type": "string" }, - | "non_revoked": { - | "type": "object", - | "properties": { - | "from": { "type": "integer" }, - | "to": { "type": "integer" } - | } - | } - | } + | "type": "object" | } - | } + | }, + | "non_revoked": { + | "type": "object", + | "properties": { + | "from": { "type": "integer" }, + | "to": { "type": "integer" } + | } + | } | }, | "required": ["name", "restrictions"] | } @@ -83,19 +72,15 @@ object AnoncredPresentationRequestV1 { | "restrictions": { | "type": "array", | "items": { - | "type": "object", - | "properties": { - | "schema_id": { "type": "string" }, - | "cred_def_id": { "type": "string" }, - | "non_revoked": { - | "type": "object", - | "properties": { + | "type": "object" + | } + | }, + | "non_revoked": { + | "type": "object", + | "properties": { | "from": { "type": "integer" }, | "to": { "type": "integer" } - | } - | } | } - | } | } | }, | "required": ["name", "p_type", "p_value", "restrictions"] @@ -131,24 +116,12 @@ object AnoncredPresentationRequestV1 { given JsonEncoder[AnoncredRequestedPredicateV1] = DeriveJsonEncoder.gen[AnoncredRequestedPredicateV1] - given JsonDecoder[AnoncredAttributeRestrictionV1] = - DeriveJsonDecoder.gen[AnoncredAttributeRestrictionV1] - given JsonEncoder[AnoncredNonRevokedIntervalV1] = DeriveJsonEncoder.gen[AnoncredNonRevokedIntervalV1] given JsonDecoder[AnoncredNonRevokedIntervalV1] = DeriveJsonDecoder.gen[AnoncredNonRevokedIntervalV1] - given JsonEncoder[AnoncredAttributeRestrictionV1] = - DeriveJsonEncoder.gen[AnoncredAttributeRestrictionV1] - - given JsonDecoder[AnoncredPredicateRestrictionV1] = - DeriveJsonDecoder.gen[AnoncredPredicateRestrictionV1] - - given JsonEncoder[AnoncredPredicateRestrictionV1] = - DeriveJsonEncoder.gen[AnoncredPredicateRestrictionV1] - given JsonDecoder[AnoncredPresentationRequestV1] = DeriveJsonDecoder.gen[AnoncredPresentationRequestV1] diff --git a/pollux/lib/core/src/test/resources/anoncred-presentation-schema-example.json b/pollux/lib/core/src/test/resources/anoncred-presentation-schema-example.json index 3d1f765fa9..14b1ffcfbe 100644 --- a/pollux/lib/core/src/test/resources/anoncred-presentation-schema-example.json +++ b/pollux/lib/core/src/test/resources/anoncred-presentation-schema-example.json @@ -10,7 +10,7 @@ "description": "Simple credential schema for the driving licence verifiable credential.", "type": "AnoncredSchemaV1", "schema": { - "name": "schema:uri2", + "name": "resource:///anoncred-presentation-schema-example.json", "version": "1.0", "attrNames": [ "name", diff --git a/pollux/lib/core/src/test/scala/io/iohk/atala/pollux/core/service/CredentialServiceImplSpec.scala b/pollux/lib/core/src/test/scala/io/iohk/atala/pollux/core/service/CredentialServiceImplSpec.scala index 1be703bf0f..5b26f677d1 100644 --- a/pollux/lib/core/src/test/scala/io/iohk/atala/pollux/core/service/CredentialServiceImplSpec.scala +++ b/pollux/lib/core/src/test/scala/io/iohk/atala/pollux/core/service/CredentialServiceImplSpec.scala @@ -9,7 +9,7 @@ import io.iohk.atala.castor.core.service.MockDIDService import io.iohk.atala.mercury.model import io.iohk.atala.mercury.model.* import io.iohk.atala.mercury.protocol.issuecredential.* -import io.iohk.atala.pollux.anoncreds.Credential +import io.iohk.atala.pollux.anoncreds.AnoncredCredential import io.iohk.atala.pollux.core.model.* import io.iohk.atala.pollux.core.model.IssueCredentialRecord.{ProtocolState, Role} import io.iohk.atala.pollux.core.model.error.CredentialServiceError @@ -602,7 +602,7 @@ object CredentialServiceImplSpec extends MockSpecDefault with CredentialServiceS assertTrue(record.issueCredentialData.get.attachments.head.data match case model.Base64(value) => val ba = new String(Base64.getUrlDecoder.decode(value)) - Credential(ba).credDefId == credDefId + AnoncredCredential(ba).credDefId == credDefId case _ => false ) } diff --git a/pollux/lib/core/src/test/scala/io/iohk/atala/pollux/core/service/LinkSecretServiceImplSpec.scala b/pollux/lib/core/src/test/scala/io/iohk/atala/pollux/core/service/LinkSecretServiceImplSpec.scala index c6ea4e6b49..c65219bc37 100644 --- a/pollux/lib/core/src/test/scala/io/iohk/atala/pollux/core/service/LinkSecretServiceImplSpec.scala +++ b/pollux/lib/core/src/test/scala/io/iohk/atala/pollux/core/service/LinkSecretServiceImplSpec.scala @@ -2,7 +2,7 @@ package io.iohk.atala.pollux.core.service import io.iohk.atala.agent.walletapi.memory.GenericSecretStorageInMemory import io.iohk.atala.agent.walletapi.storage.GenericSecretStorage -import io.iohk.atala.pollux.anoncreds.LinkSecret +import io.iohk.atala.pollux.anoncreds.AnoncredLinkSecret import io.iohk.atala.shared.models.WalletId.* import io.iohk.atala.shared.models.{WalletAccessContext, WalletId} import zio.* @@ -30,7 +30,7 @@ object LinkSecretServiceImplSpec extends ZIOSpecDefault { record1 <- svc.fetchOrCreate() storage <- ZIO.service[GenericSecretStorage] maybeDidSecret <- storage - .get[String, LinkSecret](LinkSecretServiceImpl.defaultLinkSecretId) + .get[String, AnoncredLinkSecret](LinkSecretServiceImpl.defaultLinkSecretId) } yield { assertTrue(record.id == LinkSecretServiceImpl.defaultLinkSecretId) assertTrue(record == record1) diff --git a/pollux/lib/core/src/test/scala/io/iohk/atala/pollux/core/service/PresentationServiceSpec.scala b/pollux/lib/core/src/test/scala/io/iohk/atala/pollux/core/service/PresentationServiceSpec.scala index 41c757f5bb..55ad83e633 100644 --- a/pollux/lib/core/src/test/scala/io/iohk/atala/pollux/core/service/PresentationServiceSpec.scala +++ b/pollux/lib/core/src/test/scala/io/iohk/atala/pollux/core/service/PresentationServiceSpec.scala @@ -2,10 +2,22 @@ package io.iohk.atala.pollux.core.service import io.circe.parser.decode import io.circe.syntax.* +import io.iohk.atala.agent.walletapi.model.Entity +import io.iohk.atala.agent.walletapi.storage.GenericSecretStorage import io.iohk.atala.mercury.model.{AttachmentDescriptor, Base64, DidId} import io.iohk.atala.mercury.protocol.issuecredential.{IssueCredential, IssueCredentialIssuedFormat} import io.iohk.atala.mercury.protocol.presentproof.* -import io.iohk.atala.pollux.anoncreds.AnoncredLib +import io.iohk.atala.pollux.anoncreds.{ + AnoncredCredentialDefinition, + AnoncredCredentialDefinitionPrivate, + AnoncredCredentialKeyCorrectnessProof, + AnoncredLib, + AnoncredPresentation, + AnoncredPresentationRequest, + AnoncredCreateCredentialDefinition, + AnoncredCredential, + AnoncredCredentialRequests +} import io.iohk.atala.pollux.core.model.* import io.iohk.atala.pollux.core.model.IssueCredentialRecord.* import io.iohk.atala.pollux.core.model.PresentationRecord.* @@ -13,12 +25,14 @@ import io.iohk.atala.pollux.core.model.error.PresentationError import io.iohk.atala.pollux.core.model.error.PresentationError.* import io.iohk.atala.pollux.core.model.presentation.Options import io.iohk.atala.pollux.core.model.schema.CredentialDefinition.Input +import io.iohk.atala.pollux.core.model.secret.CredentialDefinitionSecret import io.iohk.atala.pollux.core.repository.{CredentialRepository, PresentationRepository} import io.iohk.atala.pollux.core.service.serdes.{ AnoncredCredentialProofV1, AnoncredCredentialProofsV1, AnoncredPresentationRequestV1, - AnoncredPresentationV1 + AnoncredPresentationV1, + PrivateCredentialDefinitionSchemaSerDesV1 } import io.iohk.atala.pollux.vc.jwt.* import io.iohk.atala.shared.models.{WalletAccessContext, WalletId} @@ -27,12 +41,14 @@ import zio.test.* import zio.test.Assertion.* import java.time.{Instant, OffsetDateTime} -import java.util.Base64 as JBase64 +import java.util.{UUID, Base64 as JBase64} object PresentationServiceSpec extends ZIOSpecDefault with PresentationServiceSpecHelper { override def spec = - suite("PresentationService")(singleWalletSpec, multiWalletSpec).provide(presentationServiceLayer) + suite("PresentationService")(singleWalletSpec, multiWalletSpec).provide( + presentationServiceLayer ++ genericSecretStorageLayer + ) private val singleWalletSpec = suite("singleWalletSpec")( @@ -366,11 +382,11 @@ object PresentationServiceSpec extends ZIOSpecDefault with PresentationServiceSp }, test("verify anoncred presentation") { for { - svc <- ZIO.service[CredentialDefinitionService] + credentialDefinitionService <- ZIO.service[CredentialDefinitionService] issuerId = "did:prism:issuer" holderID = "did:prism:holder" schemaId = "resource:///anoncred-presentation-schema-example.json" - credentialDefinitionDb <- svc.create( + credentialDefinitionDb <- credentialDefinitionService.create( Input( name = "Credential Definition Name", description = "Credential Definition Description", @@ -383,44 +399,59 @@ object PresentationServiceSpec extends ZIOSpecDefault with PresentationServiceSp supportRevocation = false ) ) + credentialDefinitionDb <- credentialDefinitionService + .getByGUID(credentialDefinitionDb.guid) repo <- ZIO.service[CredentialRepository] schema = AnoncredLib.createSchema( schemaId, - "0.1.0", + "1.0", Set("name", "sex", "age"), issuerId ) linkSecretService <- ZIO.service[LinkSecretService] linkSecret <- linkSecretService.fetchOrCreate() - credentialDefinition = AnoncredLib.createCredDefinition(issuerId, schema, "tag", supportRevocation = false) + cenericSecretStorage <- ZIO.service[GenericSecretStorage] + maybeCredentialDefintionPrivate <- + cenericSecretStorage + .get[UUID, CredentialDefinitionSecret](credentialDefinitionDb.guid) + credentialDefinition = AnoncredCreateCredentialDefinition( + AnoncredCredentialDefinition(credentialDefinitionDb.definition.toString()), + AnoncredCredentialDefinitionPrivate(maybeCredentialDefintionPrivate.get.json.toString()), + AnoncredCredentialKeyCorrectnessProof(credentialDefinitionDb.keyCorrectnessProof.toString()) + ) credentialOffer = AnoncredLib.createOffer(credentialDefinition, credentialDefinitionDb.longId) credentialRequest = AnoncredLib.createCredentialRequest(linkSecret, credentialDefinition.cd, credentialOffer) - credential = - AnoncredLib - .createCredential( - credentialDefinition.cd, - credentialDefinition.cdPrivate, - credentialOffer, - credentialRequest.request, - Seq( - ("name", "Miguel"), - ("sex", "M"), - ("age", "31"), + processedCredential = + AnoncredLib.processCredential( + AnoncredLib + .createCredential( + credentialDefinition.cd, + credentialDefinition.cdPrivate, + credentialOffer, + credentialRequest.request, + Seq( + ("name", "Miguel"), + ("sex", "M"), + ("age", "31"), + ) + ), + credentialRequest.metadata, + linkSecret, + credentialDefinition.cd + ) + issueCredential = + IssueCredential( + from = DidId(issuerId), + to = DidId(holderID), + body = IssueCredential.Body(), + attachments = Seq( + AttachmentDescriptor.buildBase64Attachment( + mediaType = Some("application/json"), + format = Some(IssueCredentialIssuedFormat.Anoncred.name), + payload = processedCredential.data.getBytes() ) ) - .data - issueCredential = IssueCredential( - from = DidId(issuerId), - to = DidId(holderID), - body = IssueCredential.Body(), - attachments = Seq( - AttachmentDescriptor.buildBase64Attachment( - mediaType = Some("application/json"), - format = Some(IssueCredentialIssuedFormat.Anoncred.name), - payload = credential.getBytes() - ) ) - ) aIssueCredentialRecord = IssueCredentialRecord( id = DidCommID(), @@ -448,7 +479,12 @@ object PresentationServiceSpec extends ZIOSpecDefault with PresentationServiceSp ) _ <- repo.createIssueCredentialRecord(aIssueCredentialRecord) svc <- ZIO.service[PresentationService] - aRecord <- svc.createAnoncredRecordNoRestriction() + aRecord <- svc.createAnoncredRecordNoRestriction(credentialDefinitionId = credentialDefinitionDb.longId) + serialisedPresentationRequest <- aRecord.requestPresentationData.get.attachments.head.data match { + case Base64(data) => + ZIO.succeed(AnoncredPresentationRequest(new String(JBase64.getUrlDecoder.decode(data)))) + case _ => ZIO.fail(InvalidAnoncredPresentationRequest("Expecting Base64-encoded data")) + } repo <- ZIO.service[PresentationRepository] credentialsToUse = AnoncredCredentialProofsV1( @@ -463,12 +499,13 @@ object PresentationServiceSpec extends ZIOSpecDefault with PresentationServiceSp credentialsToUseJson <- ZIO.fromEither( AnoncredCredentialProofsV1.schemaSerDes.serialize(credentialsToUse) ) - _ <- repo.updateAnoncredPresentationWithCredentialsToUse( - aRecord.id, - Some(AnoncredPresentationV1.version), - Some(credentialsToUseJson), - PresentationRecord.ProtocolState.RequestPending - ) + _ <- + repo.updateAnoncredPresentationWithCredentialsToUse( + aRecord.id, + Some(AnoncredPresentationV1.version), + Some(credentialsToUseJson), + PresentationRecord.ProtocolState.RequestPending + ) issuer = createIssuer(DID("did:prism:issuer")) presentation <- svc.createAnoncredPresentation( aRecord.requestPresentationData.get, @@ -478,12 +515,48 @@ object PresentationServiceSpec extends ZIOSpecDefault with PresentationServiceSp Instant.now() ) _ <- svc.receivePresentation(presentation) - validateRecord <- svc.verifyAnoncredPresentation( - presentation, - aRecord.requestPresentationData.get, - aRecord.id - ) + serialisedPresentation <- presentation.attachments.head.data match { + case Base64(data) => ZIO.succeed(AnoncredPresentation(new String(JBase64.getUrlDecoder.decode(data)))) + case _ => ZIO.fail(InvalidAnoncredPresentation("Expecting Base64-encoded data")) + } + validateRecord <- + svc.verifyAnoncredPresentation( + presentation, + aRecord.requestPresentationData.get, + aRecord.id + ) } yield { + val presentation1 = serialisedPresentation + val presentation2 = + AnoncredLib.createPresentation( + serialisedPresentationRequest, + Seq( + AnoncredCredentialRequests(AnoncredCredential(processedCredential.data), Seq("sex"), Seq("age")) + ), + Map.empty, // TO FIX + linkSecret.secret, + Map(credentialOffer.schemaId -> schema), // schemas: Map[SchemaId, SchemaDef], + Map( + credentialOffer.credDefId -> credentialDefinition.cd + ) + ) + val verifyPresentation = AnoncredLib.verifyPresentation( + presentation2.toOption.get, // : Presentation, + serialisedPresentationRequest, // : PresentationRequest, + Map(credentialOffer.schemaId -> schema), // schemas: Map[SchemaId, SchemaDef], + Map( + credentialOffer.credDefId -> credentialDefinition.cd + ), // credentialDefinitions: Map[CredentialDefinitionId, CredentialDefinition], + ) + println(s"AnoncredPresentationRequest: ${serialisedPresentationRequest}") + println(s"credentialRequest: ${Seq( + AnoncredCredentialRequests(AnoncredCredential(processedCredential.data), Seq("sex"), Seq("age")) + )}") + println(s"linkSecret: ${linkSecret}") + println(s"schemaMap: ${Map(credentialOffer.schemaId -> schema)}") + println(s"credentialDefinitionMap: ${Map( + credentialOffer.credDefId -> credentialDefinition.cd + )}") assert(validateRecord.protocolState)(equalTo(PresentationRecord.ProtocolState.PresentationVerified)) } }, diff --git a/pollux/lib/core/src/test/scala/io/iohk/atala/pollux/core/service/PresentationServiceSpecHelper.scala b/pollux/lib/core/src/test/scala/io/iohk/atala/pollux/core/service/PresentationServiceSpecHelper.scala index 186023aed4..13111d137f 100644 --- a/pollux/lib/core/src/test/scala/io/iohk/atala/pollux/core/service/PresentationServiceSpecHelper.scala +++ b/pollux/lib/core/src/test/scala/io/iohk/atala/pollux/core/service/PresentationServiceSpecHelper.scala @@ -180,12 +180,11 @@ trait PresentationServiceSpecHelper { "sex" -> AnoncredRequestedAttributeV1( name = "sex", restrictions = List( - AnoncredAttributeRestrictionV1( - schema_id = None, - cred_def_id = Some("$CRED_DEF_ID"), - non_revoked = None + Map( + ("cred_def_id" -> "$CRED_DEF_ID") ) - ) + ), + non_revoked = None ) ), requested_predicates = Map( @@ -193,7 +192,8 @@ trait PresentationServiceSpecHelper { name = "age", p_type = ">=", p_value = 18, - restrictions = List.empty + restrictions = List.empty, + non_revoked = None ) ), name = "proof_req_1", @@ -211,6 +211,7 @@ trait PresentationServiceSpecHelper { } def createAnoncredRecordNoRestriction( + credentialDefinitionId: String, pairwiseVerifierDID: DidId = DidId("did:prism:issuer"), pairwiseProverDID: DidId = DidId("did:prism:prover-pairwise"), thid: DidCommID = DidCommID() @@ -219,7 +220,13 @@ trait PresentationServiceSpecHelper { requested_attributes = Map( "sex" -> AnoncredRequestedAttributeV1( name = "sex", - restrictions = List.empty + restrictions = List( + Map( + ("attr::sex::value" -> "M"), + ("cred_def_id" -> credentialDefinitionId) + ) + ), + non_revoked = None ) ), requested_predicates = Map( @@ -227,13 +234,14 @@ trait PresentationServiceSpecHelper { name = "age", p_type = ">=", p_value = 18, - restrictions = List.empty + restrictions = List.empty, + non_revoked = None ) ), name = "proof_req_1", nonce = "1103253414365527824079144", version = "0.1", - non_revoked = Some(AnoncredNonRevokedIntervalV1(from = Some(1), to = Some(4))) + non_revoked = None ) svc.createAnoncredPresentationRecord( thid = thid, diff --git a/pollux/lib/core/src/test/scala/io/iohk/atala/pollux/core/service/serdes/AnoncredPresentationRequestSpec.scala b/pollux/lib/core/src/test/scala/io/iohk/atala/pollux/core/service/serdes/AnoncredPresentationRequestSpec.scala index 791d6cfa9d..85a18f3204 100644 --- a/pollux/lib/core/src/test/scala/io/iohk/atala/pollux/core/service/serdes/AnoncredPresentationRequestSpec.scala +++ b/pollux/lib/core/src/test/scala/io/iohk/atala/pollux/core/service/serdes/AnoncredPresentationRequestSpec.scala @@ -13,13 +13,13 @@ object AnoncredPresentationRequestSpec extends ZIOSpecDefault { | "name": "Attribute 1", | "restrictions": [ | { - | "cred_def_id": "credential_definition_id_of_attribute1", - | "non_revoked": { - | "from": 1635734400, - | "to": 1735734400 - | } + | "cred_def_id": "credential_definition_id_of_attribute1" | } - | ] + | ], + | "non_revoked": { + | "from": 1635734400, + | "to": 1735734400 + | } | } | }, | "requested_predicates": { @@ -29,12 +29,12 @@ object AnoncredPresentationRequestSpec extends ZIOSpecDefault { | "p_value": 18, | "restrictions": [ | { - | "schema_id": "schema_id_of_predicate1", - | "non_revoked": { - | "from": 1635734400 - | } + | "schema_id": "schema_id_of_predicate1" | } - | ] + | ], + | "non_revoked": { + | "from": 1635734400 + | } | } | }, | "name": "Example Presentation Request", @@ -54,15 +54,14 @@ object AnoncredPresentationRequestSpec extends ZIOSpecDefault { "attribute1" -> AnoncredRequestedAttributeV1( "Attribute 1", List( - AnoncredAttributeRestrictionV1( - None, - Some("credential_definition_id_of_attribute1"), - Some( - AnoncredNonRevokedIntervalV1( - Some(1635734400), - Some(1735734400) - ) - ) + Map( + "cred_def_id" -> "credential_definition_id_of_attribute1" + ) + ), + Some( + AnoncredNonRevokedIntervalV1( + Some(1635734400), + Some(1735734400) ) ) ) @@ -74,15 +73,14 @@ object AnoncredPresentationRequestSpec extends ZIOSpecDefault { ">=", 18, List( - AnoncredPredicateRestrictionV1( - Some("schema_id_of_predicate1"), - None, - Some( - AnoncredNonRevokedIntervalV1( - Some(1635734400), - None - ) - ) + Map( + "schema_id" -> "schema_id_of_predicate1" + ) + ), + Some( + AnoncredNonRevokedIntervalV1( + Some(1635734400), + None ) ) ) diff --git a/pollux/lib/sql-doobie/src/main/scala/io/iohk/atala/pollux/sql/repository/JdbcCredentialRepository.scala b/pollux/lib/sql-doobie/src/main/scala/io/iohk/atala/pollux/sql/repository/JdbcCredentialRepository.scala index c56e3c10ac..3ce67f30bd 100644 --- a/pollux/lib/sql-doobie/src/main/scala/io/iohk/atala/pollux/sql/repository/JdbcCredentialRepository.scala +++ b/pollux/lib/sql-doobie/src/main/scala/io/iohk/atala/pollux/sql/repository/JdbcCredentialRepository.scala @@ -9,7 +9,7 @@ import io.circe.parser.* import io.circe.syntax.* import io.iohk.atala.castor.core.model.did.* import io.iohk.atala.mercury.protocol.issuecredential.{IssueCredential, OfferCredential, RequestCredential} -import io.iohk.atala.pollux.anoncreds.CredentialRequestMetadata +import io.iohk.atala.pollux.anoncreds.AnoncredCredentialRequestMetadata import io.iohk.atala.pollux.core.model.* import io.iohk.atala.pollux.core.model.error.CredentialRepositoryError import io.iohk.atala.pollux.core.model.error.CredentialRepositoryError.* @@ -51,9 +51,9 @@ class JdbcCredentialRepository(xa: Transactor[ContextAwareTask], xb: Transactor[ given requestCredentialGet: Get[RequestCredential] = Get[String].map(decode[RequestCredential](_).getOrElse(???)) given requestCredentialPut: Put[RequestCredential] = Put[String].contramap(_.asJson.toString) - given acRequestMetadataGet: Get[CredentialRequestMetadata] = - Get[String].map(_.fromJson[CredentialRequestMetadata].getOrElse(???)) - given acRequestMetadataPut: Put[CredentialRequestMetadata] = Put[String].contramap(_.toJson) + given acRequestMetadataGet: Get[AnoncredCredentialRequestMetadata] = + Get[String].map(_.fromJson[AnoncredCredentialRequestMetadata].getOrElse(???)) + given acRequestMetadataPut: Put[AnoncredCredentialRequestMetadata] = Put[String].contramap(_.toJson) given issueCredentialGet: Get[IssueCredential] = Get[String].map(decode[IssueCredential](_).getOrElse(???)) given issueCredentialPut: Put[IssueCredential] = Put[String].contramap(_.asJson.toString) @@ -384,7 +384,7 @@ class JdbcCredentialRepository(xa: Transactor[ContextAwareTask], xb: Transactor[ override def updateWithAnonCredsRequestCredential( recordId: DidCommID, request: RequestCredential, - metadata: CredentialRequestMetadata, + metadata: AnoncredCredentialRequestMetadata, protocolState: ProtocolState ): RIO[WalletAccessContext, Int] = { val cxnIO = diff --git a/prism-agent/service/server/src/main/scala/io/iohk/atala/presentproof/controller/http/RequestPresentationInput.scala b/prism-agent/service/server/src/main/scala/io/iohk/atala/presentproof/controller/http/RequestPresentationInput.scala index 4f50e50f30..dd460c4c25 100644 --- a/prism-agent/service/server/src/main/scala/io/iohk/atala/presentproof/controller/http/RequestPresentationInput.scala +++ b/prism-agent/service/server/src/main/scala/io/iohk/atala/presentproof/controller/http/RequestPresentationInput.scala @@ -75,9 +75,5 @@ object RequestPresentationInput { given Schema[AnoncredNonRevokedIntervalV1] = Schema.derived - given Schema[AnoncredAttributeRestrictionV1] = Schema.derived - - given Schema[AnoncredPredicateRestrictionV1] = Schema.derived - given schema: Schema[RequestPresentationInput] = Schema.derived } diff --git a/prism-agent/service/server/src/test/scala/io/iohk/atala/issue/controller/IssueControllerTestTools.scala b/prism-agent/service/server/src/test/scala/io/iohk/atala/issue/controller/IssueControllerTestTools.scala index e8c9a52135..b5fd42f818 100644 --- a/prism-agent/service/server/src/test/scala/io/iohk/atala/issue/controller/IssueControllerTestTools.scala +++ b/prism-agent/service/server/src/test/scala/io/iohk/atala/issue/controller/IssueControllerTestTools.scala @@ -16,7 +16,7 @@ import io.iohk.atala.issue.controller.http.{ IssueCredentialRecord, IssueCredentialRecordPage } -import io.iohk.atala.pollux.anoncreds.LinkSecretWithId +import io.iohk.atala.pollux.anoncreds.AnoncredLinkSecretWithId import io.iohk.atala.pollux.core.model.CredentialFormat import io.iohk.atala.pollux.core.repository.{CredentialDefinitionRepositoryInMemory, CredentialRepositoryInMemory} import io.iohk.atala.pollux.core.service.* @@ -81,7 +81,7 @@ trait IssueControllerTestTools extends PostgresTestContainerSupport { didResolverLayer >+> ResourceURIDereferencerImpl.layer >+> CredentialRepositoryInMemory.layer >+> - ZLayer.succeed(LinkSecretWithId("Unused Linked Secret ID")) >+> + ZLayer.succeed(AnoncredLinkSecretWithId("Unused Linked Secret ID")) >+> MockDIDService.empty >+> MockManagedDIDService.empty >+> CredentialServiceImpl.layer >+>