Skip to content

Commit

Permalink
feat: update anoncreds demo after the new getJson methods (#584)
Browse files Browse the repository at this point in the history
  • Loading branch information
FabioPinheiro authored Aug 2, 2023
1 parent faa869a commit d8258ee
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 24 deletions.
13 changes: 13 additions & 0 deletions pollux/lib/anoncreds/README_anoncreds.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,19 @@ https://github.com/hyperledger/anoncreds-rs/releases/tag/v0.1.0-dev.15
The file `anoncreds.udl` describes the warp interface generated with Uniffi.
The file can be found in the IOHK's anoncreds-rs repository [https://github.com/input-output-hk/anoncreds-rs/blob/main/uniffi/src/anoncreds.udl](https://github.com/input-output-hk/anoncreds-rs/blob/main/uniffi/src/anoncreds.udl)


## Build Jar lib

Build the NATIVE anoncred lib from IOHK's fork of the anoncreds-rs [https://github.com/input-output-hk/anoncreds-rs](https://github.com/input-output-hk/anoncreds-rs)

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 '@')`

Replace the `anoncreds.kt` file in the UniffiPOC project (`UniffiPOC/src/main/uniffi/anoncreds/anoncreds.kt`)

Generate the Jar with `./gradlew jar` in the UniffiPOC project

## Build the NATIVE lib

Build the NATIVE anoncred lib from IOHK's fork of the anoncreds-rs [https://github.com/input-output-hk/anoncreds-rs](https://github.com/input-output-hk/anoncreds-rs)
Expand Down
Binary file modified pollux/lib/anoncreds/UniffiPOC-1.0-SNAPSHOT.jar
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class PoCNewLib extends AnyFlatSpec {

println(credentialDefinition)

println(credentialDefinition.getCredentialDefinition())
println(credentialDefinition.getCredentialDefinition().getJson())
println(credentialDefinition.getCredentialDefinitionPrivate().getJson())
println(credentialDefinition.getCredentialKeyCorrectnessProof().getJson())

Expand All @@ -71,8 +71,7 @@ class PoCNewLib extends AnyFlatSpec {
)

println("CreateOffer")
println(tmp)
// println(AnonCredsAPI.getJson(tmp.ref.getValue()))
println(tmp.getJson())
tmp
}

Expand All @@ -82,30 +81,19 @@ class PoCNewLib extends AnyFlatSpec {
credentialOffer: CredentialOffer
) = {

// string? entropy,
// string? prover_did,
// CredentialDefinition cred_def,
// LinkSecret link_secret,
// string link_secret_id,
// CredentialOffer credential_offer

val credentialRequest = Prover().createCredentialRequest(
"entropy",
null,
credentialDefinition,
linkSecret,
"linkSecretId",
credentialOffer,
"entropy", // string? entropy,
null, // string? prover_did,
credentialDefinition, // CredentialDefinition cred_def,
linkSecret, // LinkSecret link_secret,
"linkSecretId", // string link_secret_id,
credentialOffer, // CredentialOffer credential_offer
)

print("Request: ")
println("Request: ")
println(credentialRequest.getRequest().getJson())
print("Metadata: ")
println(credentialRequest.getMetadata())
// println(AnonCredsAPI.getJson(credentialRequest.ref.getValue()))
// print("cred_req_meta_p: ")
// println(credentialRequest.meta_ref)
// println(AnonCredsAPI.getJson(credentialRequest.meta_ref.getValue()))
println("Metadata: ")
println(credentialRequest.getMetadata()) // FIXME Do we also need a getJson method?
credentialRequest
}

Expand Down Expand Up @@ -139,6 +127,7 @@ class PoCNewLib extends AnyFlatSpec {
null,
)

println("issuer_createCredential:")
println(cred.getJson())
cred
}
Expand All @@ -154,7 +143,10 @@ class PoCNewLib extends AnyFlatSpec {
println("*** holder " + ("*" * 100))

val linkSecret = LinkSecret()
println(linkSecret.getBigNumber())
println(linkSecret.getBigNumber()) // TODO REMOVE
println(
linkSecret.getJson()
) // FIXME this printing 5FCC7E4BC91B265C59E059369E5C49901AB38E50DF20C218F7B2135E165BAE3C and should have '"' like: "5FCC7E4BC91B265C59E059369E5C49901AB38E50DF20C218F7B2135E165BAE3C"

val credentialRequest =
holder_createCredentialRequest(linkSecret, credentialDefinition.getCredentialDefinition(), credentialOffer)
Expand Down

0 comments on commit d8258ee

Please sign in to comment.