diff --git a/build.sbt b/build.sbt index f4dddede15..331fef7031 100644 --- a/build.sbt +++ b/build.sbt @@ -1,6 +1,8 @@ import org.scoverage.coveralls.Imports.CoverallsKeys.* import sbtbuildinfo.BuildInfoPlugin.autoImport.* +// externalResolvers += "ScalaLibrary packages" at "https://maven.pkg.github.com/input-output-hk/anoncreds-rs" // use plugin"sbt-github-packages" + inThisBuild( Seq( organization := "io.iohk.atala", @@ -10,7 +12,8 @@ inThisBuild( releaseUseGlobalVersion := false, versionScheme := Some("semver-spec"), githubOwner := "input-output-hk", - githubRepository := "atala-prism-building-blocks" + githubRepository := "atala-prism-building-blocks", + resolvers += "Local Maven Repository" at "file://" + Path.userHome.absolutePath + "/.m2/repository", ) ) @@ -420,7 +423,8 @@ val commonSetttings = Seq( val overrides = licenseOverrides.value.lift val depExclusions = licenseDepExclusions.value.lift val originatingModule = DepModuleInfo(organization.value, name.value, version.value) - val resolution = DependencyResolution(new LicenseReportCustomDependencyResolution(ivyConfiguration.value, ivyModule.value)) + val resolution = + DependencyResolution(new LicenseReportCustomDependencyResolution(ivyConfiguration.value, ivyModule.value)) license.LicenseReport.makeReport( ivyModule.value, resolution, @@ -740,6 +744,7 @@ lazy val polluxAnoncreds = project Compile / unmanagedResourceDirectories ++= Seq( baseDirectory.value / "native-lib" / "NATIVE" ), + // libraryDependencies += "io.iohk.atala.prism.anoncredskmp" % "anoncreds-kmp-jvm" % "0.3.5-M2", libraryDependencies ++= D_Pollux_AnonCreds.baseDependencies ) diff --git a/pollux/lib/anoncreds/README_anoncreds.md b/pollux/lib/anoncreds/README_anoncreds.md index 4df672d7e9..89d940d491 100644 --- a/pollux/lib/anoncreds/README_anoncreds.md +++ b/pollux/lib/anoncreds/README_anoncreds.md @@ -21,11 +21,7 @@ Go into the folder `uniffi` and generate the file `anoncreds.kt` Assuming uniffi_bindgen is install. Install with `cargo install uniffi_bindgen --version $(cargo pkgid uniffi | cut -f 2 -d '@')` -(Note you can also the run the script `build-release-linux.sh` in there) - -Run the command `~/.cargo/bin/uniffi-bindgen generate src/anoncreds.udl --language kotlin -o ./wrappers/kotlin/anoncreds` - -Replace the `anoncreds.kt` file in the `output-frameworks/anoncreds-jvm` project (`output-frameworks/anoncreds-jvm/src/main/uniffi/anoncreds/anoncreds.kt`) +Run the script `build-release-linux.sh` in there Generate the Jar with `./gradlew jar` in the `output-frameworks/anoncreds-jvm` project diff --git a/pollux/lib/anoncreds/anoncreds-jvm-1.0-SNAPSHOT.jar b/pollux/lib/anoncreds/anoncreds-jvm-1.0-SNAPSHOT.jar index 99cde9911b..a691fdfea9 100644 Binary files a/pollux/lib/anoncreds/anoncreds-jvm-1.0-SNAPSHOT.jar and b/pollux/lib/anoncreds/anoncreds-jvm-1.0-SNAPSHOT.jar differ diff --git a/pollux/lib/anoncreds/native-lib/NATIVE/darwin-aarch64/libuniffi_anoncreds.dylib b/pollux/lib/anoncreds/native-lib/NATIVE/darwin-aarch64/libuniffi_anoncreds_wrapper.dylib similarity index 52% rename from pollux/lib/anoncreds/native-lib/NATIVE/darwin-aarch64/libuniffi_anoncreds.dylib rename to pollux/lib/anoncreds/native-lib/NATIVE/darwin-aarch64/libuniffi_anoncreds_wrapper.dylib index 5c2899c872..7c404068ce 100755 Binary files a/pollux/lib/anoncreds/native-lib/NATIVE/darwin-aarch64/libuniffi_anoncreds.dylib and b/pollux/lib/anoncreds/native-lib/NATIVE/darwin-aarch64/libuniffi_anoncreds_wrapper.dylib differ diff --git a/pollux/lib/anoncreds/native-lib/NATIVE/darwin-x86-64/libuniffi_anoncreds.dylib b/pollux/lib/anoncreds/native-lib/NATIVE/darwin-x86-64/libuniffi_anoncreds_wrapper.dylib similarity index 57% rename from pollux/lib/anoncreds/native-lib/NATIVE/darwin-x86-64/libuniffi_anoncreds.dylib rename to pollux/lib/anoncreds/native-lib/NATIVE/darwin-x86-64/libuniffi_anoncreds_wrapper.dylib index b5efdd6895..e9586974ae 100755 Binary files a/pollux/lib/anoncreds/native-lib/NATIVE/darwin-x86-64/libuniffi_anoncreds.dylib and b/pollux/lib/anoncreds/native-lib/NATIVE/darwin-x86-64/libuniffi_anoncreds_wrapper.dylib differ diff --git a/pollux/lib/anoncreds/native-lib/NATIVE/linux-aarch64/libuniffi_anoncreds.so b/pollux/lib/anoncreds/native-lib/NATIVE/linux-aarch64/libuniffi_anoncreds_wrapper.so similarity index 62% rename from pollux/lib/anoncreds/native-lib/NATIVE/linux-aarch64/libuniffi_anoncreds.so rename to pollux/lib/anoncreds/native-lib/NATIVE/linux-aarch64/libuniffi_anoncreds_wrapper.so index 51495c275f..862fd37717 100755 Binary files a/pollux/lib/anoncreds/native-lib/NATIVE/linux-aarch64/libuniffi_anoncreds.so and b/pollux/lib/anoncreds/native-lib/NATIVE/linux-aarch64/libuniffi_anoncreds_wrapper.so differ diff --git a/pollux/lib/anoncreds/native-lib/NATIVE/linux-x86-64/libuniffi_anoncreds.so b/pollux/lib/anoncreds/native-lib/NATIVE/linux-x86-64/libuniffi_anoncreds_wrapper.so similarity index 62% rename from pollux/lib/anoncreds/native-lib/NATIVE/linux-x86-64/libuniffi_anoncreds.so rename to pollux/lib/anoncreds/native-lib/NATIVE/linux-x86-64/libuniffi_anoncreds_wrapper.so index aea4d32d5e..fb40daed07 100755 Binary files a/pollux/lib/anoncreds/native-lib/NATIVE/linux-x86-64/libuniffi_anoncreds.so and b/pollux/lib/anoncreds/native-lib/NATIVE/linux-x86-64/libuniffi_anoncreds_wrapper.so differ diff --git a/pollux/lib/anoncreds/native-lib/helper_script_to_update.sh b/pollux/lib/anoncreds/native-lib/helper_script_to_update.sh index 7f8f235dca..3d0aa14bff 100644 --- a/pollux/lib/anoncreds/native-lib/helper_script_to_update.sh +++ b/pollux/lib/anoncreds/native-lib/helper_script_to_update.sh @@ -1,24 +1,29 @@ #!/usr/bin/env bash +# https://github.com/input-output-hk/anoncreds-rs/releases/download/0.4.0/library-darwin-aarch64-0ce097bbc9afa8a17a491248d75dcdf03f133dc4.tar.gz RELEASES=https://github.com/input-output-hk/anoncreds-rs/releases/download/ -VERSION=expose_presentation_methods_in_uniffi -SHA="16a7178ca979f7643788f6ebf8189131ab922a53" +VERSION="0.4.0" +SHA="0ce097bbc9afa8a17a491248d75dcdf03f133dc4" -mkdir NATIVE_new -mkdir NATIVE_new/darwin-aarch64 -mkdir NATIVE_new/darwin-x86-64 -mkdir NATIVE_new/linux-aarch64 -mkdir NATIVE_new/linux-x86-64 +rm -rf NATIVE/darwin-aarch64 +rm -rf NATIVE/darwin-x86-64 +rm -rf NATIVE/linux-aarch64 +rm -rf NATIVE/linux-x86-64 -wget -c $RELEASES/$VERSION/library-darwin-aarch64-$SHA.tar.gz -O - | tar -xz -C NATIVE_new/darwin-aarch64 -wget -c $RELEASES/$VERSION/library-darwin-x86_64-$SHA.tar.gz -O - | tar -xz -C NATIVE_new/darwin-x86-64 -wget -c $RELEASES/$VERSION/library-linux-aarch64-$SHA.tar.gz -O - | tar -xz -C NATIVE_new/linux-aarch64 -wget -c $RELEASES/$VERSION/library-linux-x86_64-$SHA.tar.gz -O - | tar -xz -C NATIVE_new/linux-x86-64 +mkdir NATIVE/darwin-aarch64 +mkdir NATIVE/darwin-x86-64 +mkdir NATIVE/linux-aarch64 +mkdir NATIVE/linux-x86-64 -rename 'libanoncreds_uniffi.so' 'libuniffi_anoncreds.so' NATIVE_new/**/*.so -rename 'libanoncreds_uniffi.dylib' 'libuniffi_anoncreds.dylib' NATIVE_new/**/*.dylib +wget -c $RELEASES/$VERSION/library-darwin-aarch64-$SHA.tar.gz -O - | tar -xz -C NATIVE/darwin-aarch64 +wget -c $RELEASES/$VERSION/library-darwin-x86_64-$SHA.tar.gz -O - | tar -xz -C NATIVE/darwin-x86-64 +wget -c $RELEASES/$VERSION/library-linux-aarch64-$SHA.tar.gz -O - | tar -xz -C NATIVE/linux-aarch64 +wget -c $RELEASES/$VERSION/library-linux-x86_64-$SHA.tar.gz -O - | tar -xz -C NATIVE/linux-x86-64 + +rename 'libanoncreds_uniffi.so' 'libuniffi_anoncreds_wrapper.so' NATIVE/**/*.so +rename 'libanoncreds_uniffi.dylib' 'libuniffi_anoncreds_wrapper.dylib' NATIVE/**/*.dylib ## TODO missing anoncreds-jvm-1.0-SNAPSHOT.jar ## run https://github.com/input-output-hk/anoncreds-rs/blob/main/uniffi/build-release-linux.sh -## copy jar from uniffi/output-frameworks/anoncreds-jvm/build/libs/anoncreds-jvm-1.0-SNAPSHOT.jar \ No newline at end of file +## copy jar from uniffi/output-frameworks/anoncreds-jvm/build/libs/anoncreds-jvm-1.0-SNAPSHOT.jar 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 d4987bd8de..9bd681714c 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 @@ -1,7 +1,5 @@ package io.iohk.atala.pollux.anoncreds -import uniffi.anoncreds - import scala.jdk.CollectionConverters.* import scala.language.implicitConversions @@ -20,7 +18,7 @@ object AnoncredLib { version: String, // SCHEMA_Version attr_names: AttributeNames, issuer_id: IssuerId, // ISSUER_DID - ): SchemaDef = anoncreds.Schema.apply(name, version, attr_names.toSeq.asJava, issuer_id) + ): SchemaDef = uniffi.anoncreds_wrapper.Schema.apply(name, version, attr_names.toSeq.asJava, issuer_id) // issuer def createCredDefinition( @@ -28,18 +26,18 @@ object AnoncredLib { schema: SchemaDef, tag: String, supportRevocation: Boolean, - signature_type: anoncreds.SignatureType.CL.type = anoncreds.SignatureType.CL + signature_type: uniffi.anoncreds_wrapper.SignatureType.CL.type = uniffi.anoncreds_wrapper.SignatureType.CL ) = { - val credentialDefinition: anoncreds.IssuerCreateCredentialDefinitionReturn = - anoncreds + val credentialDefinition: uniffi.anoncreds_wrapper.IssuerCreateCredentialDefinitionReturn = + uniffi.anoncreds_wrapper .Issuer() .createCredentialDefinition( schema.name, - schema: anoncreds.Schema, + schema: uniffi.anoncreds_wrapper.Schema, issuer_id, tag, signature_type, - anoncreds.CredentialDefinitionConfig(supportRevocation) + uniffi.anoncreds_wrapper.CredentialDefinitionConfig(supportRevocation) ) CreateCredentialDefinition( @@ -54,7 +52,7 @@ object AnoncredLib { credentialDefinition: CreateCredentialDefinition, credentialDefinitionId: String ): CredentialOffer = - anoncreds + uniffi.anoncreds_wrapper .Issuer() .createCredentialOffer( credentialDefinition.cd.schemaId, // string schema_id, @@ -74,7 +72,7 @@ object AnoncredLib { } ): CreateCrendentialRequest = { val credentialRequest = - anoncreds + uniffi.anoncreds_wrapper .Prover() .createCredentialRequest( entropy, // string? entropy, @@ -94,8 +92,8 @@ object AnoncredLib { metadata: CredentialRequestMetadata, linkSecret: LinkSecretWithId, credentialDefinition: CredentialDefinition, - ): Unit = { - anoncreds + ): Credential = { + uniffi.anoncreds_wrapper .Prover() .processCredential( credential, // Credential, @@ -118,8 +116,7 @@ object AnoncredLib { // revocationStatusList : RevocationStatusList // credentialRevocationConfig : CredentialRevocationConfig ): Credential = { - - anoncreds + uniffi.anoncreds_wrapper .Issuer() .createCredential( credentialDefinition, // CredentialDefinition cred_def, @@ -127,7 +124,7 @@ object AnoncredLib { credentialOffer, // CredentialOffer cred_offer, credentialRequest, // CredentialRequest cred_request, attributeValues - .map(e => anoncreds.AttributeValues(e._1, e._2)) + .map(e => uniffi.anoncreds_wrapper.AttributeValues(e._1, e._2)) .asJava, // sequence cred_values, null, // RevocationRegistryId? rev_reg_id, null, // RevocationStatusList? rev_status_list, @@ -138,40 +135,67 @@ object AnoncredLib { type SchemaId = String type CredentialDefinitionId = String + // TODO FIX + // [info] uniffi.anoncreds.AnoncredsException$CreatePresentationException: Create Presentation: Error: Error: Invalid structure + // [info] Caused by: Predicate is not satisfied + def createPresentation( presentationRequest: PresentationRequest, - credentials: Seq[Credential], + credentialRequests: Seq[CredentialAndRequestedAttributesPredicates], selfAttested: Map[String, String], linkSecret: LinkSecret, schemas: Map[SchemaId, SchemaDef], credentialDefinitions: Map[CredentialDefinitionId, CredentialDefinition], - ): Presentation = { - anoncreds - .Prover() - .createPresentation( - presentationRequest, - credentials.map(e => e: uniffi.anoncreds.Credential).asJava, // sequence credentials, - selfAttested.asJava, // record? self_attested, - linkSecret, // LinkSecret link_secret, - schemas.view.mapValues(i => i: uniffi.anoncreds.Schema).toMap.asJava, // record schemas, - credentialDefinitions.view.mapValues(i => i: uniffi.anoncreds.CredentialDefinition).toMap.asJava - // record credential_definitions + ): Either[uniffi.anoncreds_wrapper.AnoncredsException.CreatePresentationException, Presentation] = { + try { + Right( + uniffi.anoncreds_wrapper + .Prover() + .createPresentation( + presentationRequest, // uniffi.anoncreds + credentialRequests + .map(i => i: uniffi.anoncreds_wrapper.CredentialRequests) + .asJava, // sequence credentials, + selfAttested.asJava, // record? self_attested, + linkSecret, // LinkSecret link_secret, + schemas.view + .mapValues(i => i: uniffi.anoncreds_wrapper.Schema) + .toMap + .asJava, // record schemas, + credentialDefinitions.view.mapValues(i => i: uniffi.anoncreds_wrapper.CredentialDefinition).toMap.asJava + // record credential_definitions + ) ) + } catch { + case ex: uniffi.anoncreds_wrapper.AnoncredsException.CreatePresentationException => Left(ex) + } } + // TODO FIX + // uniffi.anoncreds.AnoncredsException$ProcessCredentialException: Verify Presentation: Error: + // Requested restriction validation failed for "{"sex": Some("M")}" attributes [$and operator validation failed. + // [$eq operator validation failed for tag: "attr::sex::value", value: "F" [Proof rejected: "attr::sex::value" values are different: expected: "F", actual: "M"]]] + + // TODO FIX + // uniffi.anoncreds.AnoncredsException$ProcessCredentialException: Verify Presentation: Error: Requested restriction validation failed for "{"sex": Some("M")}" attributes [$and operator validation failed. [$eq operator validation failed for tag: "cred_def_id", value: "CRED_DEF_ID" [Proof rejected: "cred_def_id" values are different: expected: "CRED_DEF_ID", actual: "mock:uri3"]]] + + // FIXME its always return false .... def verifyPresentation( presentation: Presentation, presentationRequest: PresentationRequest, schemas: Map[SchemaId, SchemaDef], credentialDefinitions: Map[CredentialDefinitionId, CredentialDefinition], ): Boolean = { - anoncreds + uniffi.anoncreds_wrapper .Verifier() .verifyPresentation( presentation, // Presentation presentation, presentationRequest, // PresentationRequest presentation_request, - schemas.view.mapValues(i => i: uniffi.anoncreds.Schema).toMap.asJava, // record schemas, - credentialDefinitions.view.mapValues(i => i: uniffi.anoncreds.CredentialDefinition).toMap.asJava + schemas.view + .mapValues(i => i: uniffi.anoncreds_wrapper.Schema) + .toMap + .asJava, // record schemas, + credentialDefinitions.view.mapValues(i => i: uniffi.anoncreds_wrapper.CredentialDefinition).toMap.asJava // record credential_definitions ) } 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 ca8670c18d..0324c89601 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 @@ -1,8 +1,9 @@ package io.iohk.atala.pollux.anoncreds -import uniffi.anoncreds.{ +import uniffi.anoncreds_wrapper.{ Nonce, Credential as UniffiCredential, + CredentialRequests as UniffiCredentialRequests, CredentialDefinition as UniffiCredentialDefinition, CredentialDefinitionPrivate as UniffiCredentialDefinitionPrivate, CredentialKeyCorrectnessProof as UniffiCredentialKeyCorrectnessProof, @@ -257,6 +258,47 @@ object Credential { } } +// **************************************************************************** +case class CredentialAndRequestedAttributesPredicates( + credential: Credential, + requestedAttribute: Seq[String], + requestedPredicate: Seq[String], +) + +object CredentialAndRequestedAttributesPredicates { + given Conversion[CredentialAndRequestedAttributesPredicates, UniffiCredentialRequests] with { + import uniffi.anoncreds_wrapper.RequestedAttribute + import uniffi.anoncreds_wrapper.RequestedPredicate + def apply(credentialRequests: CredentialAndRequestedAttributesPredicates): UniffiCredentialRequests = { + val credential = Credential.given_Conversion_Credential_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, CredentialAndRequestedAttributesPredicates] with { + def apply(credentialRequests: UniffiCredentialRequests): CredentialAndRequestedAttributesPredicates = { + CredentialAndRequestedAttributesPredicates( + Credential.given_Conversion_UniffiCredential_Credential(credentialRequests.getCredential()), + credentialRequests + .getRequestedAttribute() + .asScala + .toSeq + .filter(e => e.getRevealed()) + .map(e => e.getReferent()), + credentialRequests + .getRequestedPredicate() + .asScala + .toSeq + .map(e => e.getReferent()) + ) + } + } +} + +//UniffiCredentialRequests + // **************************************************************************** case class PresentationRequest(data: String) @@ -277,12 +319,14 @@ object PresentationRequest { case class Presentation(data: String) object Presentation { given Conversion[Presentation, UniffiPresentation] with { - def apply(presentation: Presentation): UniffiPresentation = + def apply(presentation: Presentation): UniffiPresentation = { UniffiPresentation(presentation.data) + } } given Conversion[UniffiPresentation, Presentation] with { - def apply(presentation: UniffiPresentation): Presentation = + def apply(presentation: UniffiPresentation): Presentation = { Presentation(presentation.getJson()) + } } } diff --git a/pollux/lib/anoncredsTest/src/test/scala/Uniffy.scala b/pollux/lib/anoncredsTest/src/test/scala/Uniffy.scala index c3b188004c..f227fb3367 100644 --- a/pollux/lib/anoncredsTest/src/test/scala/Uniffy.scala +++ b/pollux/lib/anoncredsTest/src/test/scala/Uniffy.scala @@ -1,4 +1,4 @@ -import uniffi.anoncreds.* +import uniffi.anoncreds_wrapper.* object Uniffy extends App { val prover = new Prover() val seceret = prover.createLinkSecret(); 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 405f1592c6..7172e28ea7 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 @@ -16,11 +16,11 @@ class PoCNewLib extends AnyFlatSpec { import scala.language.implicitConversions val ls1 = LinkSecret("65965334953670062552662719679603258895632947953618378932199361160021795698890") - val ls1p = ls1: uniffi.anoncreds.LinkSecret + val ls1p = ls1: uniffi.anoncreds_wrapper.LinkSecret assert(ls1p.getValue() == "65965334953670062552662719679603258895632947953618378932199361160021795698890") val ls0 = LinkSecret() - val ls0p = ls0: uniffi.anoncreds.LinkSecret + val ls0p = ls0: uniffi.anoncreds_wrapper.LinkSecret val ls0_ = ls0p: LinkSecret assert(ls0.data == ls0_.data) } @@ -58,7 +58,8 @@ class PoCNewLib extends AnyFlatSpec { // ############## println("*** holder " + ("*" * 100)) - val linkSecret = LinkSecretWithId("ID_of_some_secret_1") + val ls1 = LinkSecret("65965334953670062552662719679603258895632947953618378932199361160021795698890") + val linkSecret = LinkSecretWithId("ID_of_some_secret_1", ls1) val credentialRequest = AnoncredLib.createCredentialRequest(linkSecret, credentialDefinition.cd, credentialOffer) println("*" * 100) @@ -75,7 +76,13 @@ class PoCNewLib extends AnyFlatSpec { ) ) - println(credential) + val processedCredential = AnoncredLib.processCredential( + credential = credential, + metadata = credentialRequest.metadata, + linkSecret = linkSecret, + credentialDefinition = credentialDefinition.cd + ) + println(processedCredential) // ############## // ### PROVER ### @@ -88,29 +95,34 @@ class PoCNewLib extends AnyFlatSpec { "name":"proof_req_1", "version":"0.1", "requested_attributes": { - "sex":{"name":"sex"} + "sex":{"name":"sex", "restrictions":{"attr::sex::value":"M","cred_def_id":"$CRED_DEF_ID"}} + }, + "requested_predicates":{ + "age":{"name":"age", "p_type":">=", "p_value":18} } }""".stripMargin // {"name":"proof_req_1","nonce":"1103253414365527824079144","requested_attributes":{"attr1_referent":{"name":"name","restrictions":{"attr::name::value":"Alex","cred_def_id":"creddef:government"}},"attr2_referent":{"name":"role","restrictions":{"cred_def_id":"creddef:employee"}},"attr3_referent":{"name":"name","restrictions":{"cred_def_id":"creddef:employee"}},"attr4_referent":{"name":"height","restrictions":{"attr::height::value":"175","cred_def_id":"creddef:government"}}},"requested_predicates":{"predicate1_referent":{"name":"age","p_type":">=","p_value":18,"restrictions":{"attr::height::value":"175","attr::name::value":"Alex","cred_def_id":"creddef:government"}}},"version":"0.1"} ) + println("*** PROVER " + ("*" * 100) + " presentation") val presentation = AnoncredLib.createPresentation( presentationRequest, // : PresentationRequest, - Seq(credential), // credentials: Seq[Credential], - Map("sex" -> "M"), // selfAttested: Map[String, String], + Seq( + CredentialAndRequestedAttributesPredicates(processedCredential, Seq("sex"), Seq("age")) + ), // credentials: Seq[Credential], + Map(), // selfAttested: Map[String, String], linkSecret.secret, // linkSecret: LinkSecret, Map(credentialOffer.schemaId -> schema), // schemas: Map[SchemaId, SchemaDef], Map( credentialOffer.credDefId -> credentialDefinition.cd ), // credentialDefinitions: Map[CredentialDefinitionId, CredentialDefinition], ) - - println("*** PROVER " + ("*" * 100) + " presentation") println(presentation) + println("*** PROVER " + ("*" * 100) + " verifyPresentation") val verifyPresentation = AnoncredLib.verifyPresentation( - presentation, // : Presentation, + presentation.getOrElse(???), // : Presentation, presentationRequest, // : PresentationRequest, Map(credentialOffer.schemaId -> schema), // schemas: Map[SchemaId, SchemaDef], Map( @@ -118,7 +130,6 @@ class PoCNewLib extends AnyFlatSpec { ), // credentialDefinitions: Map[CredentialDefinitionId, CredentialDefinition], ) - println("*** PROVER " + ("*" * 100) + " verifyPresentation") println(verifyPresentation) }