Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update anoncreds demo after the new getJson methods #584

Merged
merged 2 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also need a getJson for the Metadata

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"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was expecting to return
"5FCC7E4BC91B265C59E059369E5C49901AB38E50DF20C218F7B2135E165BAE3C"
instead of
5FCC7E4BC91B265C59E059369E5C49901AB38E50DF20C218F7B2135E165BAE3C

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It returns with the quotes?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah it returns without, I mean that's actually correct, maybe the naming is wrong because a linkSecret is a string not a json format


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