Skip to content
This repository has been archived by the owner on Mar 15, 2024. It is now read-only.

Proposed improvement definition for the core mobile library implementation #133

Open
rauljareno opened this issue Jun 6, 2020 · 5 comments
Labels

Comments

@rauljareno
Copy link
Contributor

rauljareno commented Jun 6, 2020

// Setup identity settings (mandatory and optional as defined in documentation for integrator)
Id3IdentitySettings idSettings = new Id3IdentitySettings() {
“path” : path,
“sharedPath” : sharedPath,
“password”: password,
“web3Url”: web3Url,
“checkTicketsPeriod”: checkTicketsPeriod,
“extraGenesisClaims”: extraGenesisClaims
}

// Create Identity (IdentityFactory will manage errors for not sending correctly parameters inside idSettings
Id3Identity identity = Id3IdentityFactory.createIdentity(idSettings) { event, exception ->
Log.i("EVENT RECEIVED”)
}

// Load Identity
Id3Identity identity2 = Id3IdentityFactory.loadIdentity(idSettings)
Identity2.setEventListener(new Sender() {
override fun send(event: Event, exception: Exception) {
Log.i("EVENT RECEIVED”)
}
})

// Delete Identity
Boolean isDeleted = Id3IdentityFactory.deleteIdentity(identity2)

// Request Claim and receive ticket
Identity.requestClaim(issuerUrl) {
ticket, exception ->
Log.i(”CLAIM TICKET RECEIVED”)
}

// Get Claim from Id
String claim = Identity.getClaim(claimId)

// Get all claims of the identity
List claims = Identity.getClaims()

// Prove Claim with or without Zero Knowledge Proof
Identity.proveClaim(verifierUrl, claim, usingZK) {
success, exception ->
if (success) {
Log.i(”CLAIM PROOF RECEIVED”)
}
}

@arnaubennassar
Copy link
Contributor

arnaubennassar commented Jun 8, 2020

Like this object oriented approach. Some comments:

  • path is unique per identity and therefore should be passed to createIdentity and loadIdentity instead of Id3IdentitySettings
  • Not sure of this:
// Get Claim from ticket
String claim = Identity.getClaim(ticket)

Tickets in this context are used to inform that there is a claim request that is not resolved yet. When tickets are resolved an event is produced. You could get the claim in the event, but not before. In this case the event already includes the ID of the claim, so it's very easy to fetch the claim within the event.

In general tickets are used to track pending actions (both internally and to provide info to the user).

@arnaubennassar
Copy link
Contributor

arnaubennassar commented Jun 8, 2020

Markdown tip: when you want to add code snippets, you can do it using:

```<language-name (example: java)> (optional)
   codeSnipppet() {
        // some code
    }```

Just make sure that the accent quotes are on separated lines, here I've putted it together so it renders

@rauljareno
Copy link
Contributor Author

Id3IdentitySettings is an object to setup the identity, so each path will be specific for the identity that is going to be created with that IdentitySettings object, like this we save having an identity constructor with too many parameters.

About getting the claim with the ticket, thanks for making it more clear how it works. I'd suggest then to change the method to this:

// Get Claim from Id
String claim = Identity.getClaim(claimID)

@arnaubennassar
Copy link
Contributor

arnaubennassar commented Jun 8, 2020

Id3IdentitySettings is an object to setup the identity, so each path will be specific for the identity that is going to be created with that IdentitySettings object, like this we save having an identity constructor with too many parameters.

I think it make sense to have a method to set parameters that are common to all identities and then methods to create / load that only have the ones that are Identity specific. For instance:

Id3IdentitySettings idSettings = new Id3Settings() {
    “sharedPath” : sharedPath,
    “web3Url”: web3Url,
    “checkTicketsPeriod”: checkTicketsPeriod,
    “extraGenesisClaims”: extraGenesisClaims
}

Id3Identity identity1 = Id3IdentityFactory.createIdentity("/path/1", "pass_1", idSettings) { event, exception ->
     Log.i("EVENT RECEIVED”)
}

Id3Identity identity2 = Id3IdentityFactory.createIdentity("/path/2", "pass_2", idSettings) { event, exception ->
     Log.i("EVENT RECEIVED”)
}

Sorry that first time I read the code I misunderstood that you were creating two different identities, and since this is not the case that should work. But with that being said I think that what I'm porpoising makes sense as it would be very clean for scenarios were multiple identities are required.
A 3rd option could be to have two methods like:

Id3Settings sharedSettings = new Id3Settings() {
    “sharedPath” : sharedPath,
    “web3Url”: web3Url,
    “checkTicketsPeriod”: checkTicketsPeriod,
    “extraGenesisClaims”: extraGenesisClaims
}

Id3IdentitySettings idSettings = new Id3IdentitySettings() {
     “path” : path,
     “password”: password,
}

Id3Identity identity = Id3IdentityFactory.createIdentity(sharedSettings, idSettings) { event, exception ->
     Log.i("EVENT RECEIVED”)
}

@rauljareno
Copy link
Contributor Author

I like the third option, but passing it as a parameter of the method createIdentity seems odd. What about this?

Id3Settings sharedSettings = new Id3Settings() {
    “sharedPath” : sharedPath,
    “web3Url”: web3Url,
    “checkTicketsPeriod”: checkTicketsPeriod,
    “extraGenesisClaims”: extraGenesisClaims
}

Id3IdentitySettings idSettings = new Id3IdentitySettings() {
     “path” : path,
     “password”: password,
}

Id3IdentityFactory.init(sharedSettings) // this static method could be called also initialize or setup

Id3Identity identity = Id3IdentityFactory.createIdentity(idSettings) { event, exception ->
     Log.i("EVENT RECEIVED”)
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants