You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One of the things we're building into AFJ is the ability to talk to multiple ledgers. In the architecture we're building (as depicted in the image below), we separate the credential format-related logic (orange box) from the logic that deals with communication to the ledgers (red box). Connection management and ledger communication are handled by implementations of the AnonCredsRegistry interface. In order to support multiple ledgers, we need to create an AnonCredsService that manages these AnonCredsRegistrys.
Knowing which ledger to use
With support for multiple ledgers, the AnonCredsService will need to figure out what AnonCredsRegistry instance it should use when a call is being made. This can be derived from the identifiers that are passed via the method parameters. The AnonCredsService needs a regex-like mechanism to match this identifier to the corresponding registry.
Identifiers
Indy networks can be identified in two ways: did:indy identifiers and legacy identifiers. More information on did:indy identifiers can be found here.
The other network that we will add support for is cheqd. This network uses the did:cheqd identifier. More info here.
There are two possible approaches to implementing this.
Using AnonCredsService as a bridge
Here the AnonCredsService fetches the right AnonCredsRegistry and calls it.
classAnonCredsService{holder: AnonCredsHolder;issuer: AnonCredsIssuer;verifier: AnonCredsVerifier;registries: AnonCredsRegistry[];privategetRegistryForIdentifier(identifier: string): AnonCredsRegistry{/** not important **/}publicasynccreateCredentialDefinition(options: CreateCredentialOptions){constregistry=getRegistryForIdentifier(options.schemaId);constcredentialDefinition=awaitthis.issuer.createCredentialDefinition(options);// Here AnonCredsService is responsible for calling the registryawaitregistry.writeCredentialDefinition(credentialDefinition);returncredentialDefinition}}
Using AnonCredsApi as a bridge
Another option is to move the responsibility of calling the AnonCredsRegistry one level up, and let it be handled by the AnonCredsApi.
classAnonCredsService{holder: AnonCredsHolder;issuer: AnonCredsIssuer;verifier: AnonCredsVerifier;registries: AnonCredsRegistry[];publicgetRegistryForIdentifier(identifier: string): AnonCredsRegistry{/** not important **/}publicasynccreateCredentialDefinition(options: CreateCredentialOptions){// We don't bother dealing with the registry hereconstcredentialDefinition=awaitthis.issuer.createCredentialDefinition(options);returncredentialDefinition}}classAnonCredsApi{service: AnonCredsServiceprivategetRegistryForIdentifier(identifier: string): AnonCredsRegistry{/** not important **/}publicasynccreateCredentialDefinition(options: CreateCredentialOptions){constregistry=service.getRegistryForIdentifier(options.schemaId);constcredentialDefinition=awaitservice.createCredentialDefinition(options);// Here AnonCredsApi is responsible for calling the registryawaitregistry.writeCredentialDefinition(credentialDefinition);returncredentialDefinition}}
Todo
Decide on the approach
Create a mechanism to resolve the right registry based on the identifiers in the parameters
Implement all methods, calling the AnonCredsHolder, AnonCredsIssuerorAnonCredsVerifierand appropriateAnonCredsRegistry` instance.
DOD: There is an AnonCredsRegistryService that can be called to find the registry instance for a specific anoncreds model identifier (schema id, credential definition id, revocation registry id)
The text was updated successfully, but these errors were encountered:
I think for the second approach we could move it up even more by making the AnonCreds service more an AnonCredsRegistryService (like we have the IndyPoolService) and only let it manage the registires. The code in the API will then look something like:
classAnonCredsRegistryService{registries: AnonCredsRegistry[];publicgetRegistryForIdentifier(identifier: string): AnonCredsRegistry{/** not important **/}}classAnonCredsApi{registryService: AnonCredsRegistryServiceissuer: AnonCredsIssuerServiceprivategetRegistryForIdentifier(identifier: string): AnonCredsRegistry{/** not important **/}publicasynccreateCredentialDefinition(options: CreateCredentialOptions){constregistry=registryService.getRegistryForIdentifier(options.schemaId);constcredentialDefinition=awaitissuer.createCredentialDefinition(options);// Here AnonCredsApi is responsible for calling the registryawaitregistry.writeCredentialDefinition(credentialDefinition);returncredentialDefinition}}
Just posting it here for comparison. I don't have strong preferences. But we should probably look at what the purpose of each service is. If we need to expose all methods from the issuer / holder /verifier services on the AnonCreds service that will be quite some. Or will it only add methods related to reading / writing to/from the registry?
Description
One of the things we're building into AFJ is the ability to talk to multiple ledgers. In the architecture we're building (as depicted in the image below), we separate the credential format-related logic (orange box) from the logic that deals with communication to the ledgers (red box). Connection management and ledger communication are handled by implementations of the
AnonCredsRegistry
interface. In order to support multiple ledgers, we need to create anAnonCredsService
that manages theseAnonCredsRegistry
s.Knowing which ledger to use
With support for multiple ledgers, the
AnonCredsService
will need to figure out whatAnonCredsRegistry
instance it should use when a call is being made. This can be derived from the identifiers that are passed via the method parameters. TheAnonCredsService
needs a regex-like mechanism to match this identifier to the corresponding registry.Identifiers
Indy networks can be identified in two ways:
did:indy
identifiers and legacy identifiers. More information ondid:indy
identifiers can be found here.The other network that we will add support for is cheqd. This network uses the
did:cheqd
identifier. More info here.Approaches
There are two possible approaches to implementing this.
Using
AnonCredsService
as a bridgeHere the
AnonCredsService
fetches the rightAnonCredsRegistry
and calls it.Using
AnonCredsApi
as a bridgeAnother option is to move the responsibility of calling the
AnonCredsRegistry
one level up, and let it be handled by theAnonCredsApi
.Todo
AnonCredsHolder
, AnonCredsIssueror
AnonCredsVerifierand appropriate
AnonCredsRegistry` instance.DOD: There is an AnonCredsRegistryService that can be called to find the registry instance for a specific anoncreds model identifier (schema id, credential definition id, revocation registry id)
The text was updated successfully, but these errors were encountered: