public async Task <IActionResult> CreateSchema() { var context = await _agentContextProvider.GetContextAsync(); var record = await _provisioningService.GetProvisioningAsync(context.Wallet); var schemaName = $"Rent-Credential"; var schemaVersion = "1.0"; var schemaAttrNames = new[] { "Name", "Rented" }; var schemaId = await _schemaService.CreateSchemaAsync(context, record.Endpoint.Did, schemaName, schemaVersion, schemaAttrNames); await Task.Delay(TimeSpan.FromSeconds(2)); string credId = await _schemaService.CreateCredentialDefinitionAsync(context, schemaId, record.Endpoint.Did, "Tag", false, 100, new Uri("http://mock/tails")); _logger.LogInformation("CREDDEFID ++++++++++++ {0}", credId); return(RedirectToAction("Index")); }
public static async Task <(string, string)> CreateDummySchemaAndNonRevokableCredDef(IAgentContext context, ISchemaService schemaService, string issuerDid, string[] attributeValues) { // Create a schema and credential definition for this issuer var schemaId = await schemaService.CreateSchemaAsync(context, issuerDid, $"Test-Schema-{Guid.NewGuid()}", "1.0", attributeValues); var credentialDefinitionConfiguration = new CredentialDefinitionConfiguration { SchemaId = schemaId, EnableRevocation = false, IssuerDid = issuerDid, Tag = "Tag", }; return ( await schemaService.CreateCredentialDefinitionAsync(context, credentialDefinitionConfiguration), schemaId ); }
public async Task <IActionResult> CreateSchema() { var agentContext = await _agentContextProvider.GetContextAsync(); //The fields of the future schema var schemaName = "fictional-passeport-" + $"{ Guid.NewGuid().ToString("N")}"; var schemaVersion = "1.1"; var schemaAttrNames = new[] { "type", "passportNumber", "issuerCountryCode", "firstname", "familyname", "birthdate", "citizenship", "sex", "placeOfBirth", "issuingDate", "expiryDate" }; //var schemaAttrNames = new [] { "first_name", "last_name" }; //promoting the did to TRUSTEE role await Ledger.SignAndSubmitRequestAsync(await agentContext.Pool, agentContext.Wallet, _agentOptions.IssuerDid, await Ledger.BuildNymRequestAsync(_agentOptions.IssuerDid, _agentOptions.IssuerDid, "~7TYfekw4GUagBnBVCqPjiC", null, "TRUSTEE")); //Create and register a dummy schema using previous fields await _schemaService.CreateSchemaAsync(agentContext, _agentOptions.IssuerDid, schemaName, schemaVersion, schemaAttrNames); //TODO: Need a CreateSchemaView => Not necessary for the PoC return(RedirectToAction("Index")); }
public async Task <CreateSchemaResponse> Handle ( CreateSchemaRequest aCreateSchemaRequest, CancellationToken aCancellationToken ) { IAgentContext agentContext = await AgentProvider.GetContextAsync(); ProvisioningRecord issuerProvisioningRecord = await ProvisioningService.GetProvisioningAsync(agentContext.Wallet); string schemaId = await SchemaService.CreateSchemaAsync ( agentContext, issuerDid : issuerProvisioningRecord.IssuerDid, aCreateSchemaRequest.Name, aCreateSchemaRequest.Version, aCreateSchemaRequest.AttributeNames.ToArray() ); var response = new CreateSchemaResponse(aCreateSchemaRequest.CorrelationId, schemaId); return(response); }
internal static async Task <(CredentialRecord issuerCredential, CredentialRecord holderCredential)> IssueCredentialAsync( ISchemaService schemaService, ICredentialService credentialService, IProducerConsumerCollection <IEnvelopeMessage> messages, string issuerConnectionId, Wallet issuerWallet, Wallet holderWallet, Pool pool, string proverMasterSecretId, bool revocable) { // Create an issuer DID/VK. Can also be created during provisioning var issuer = await Did.CreateAndStoreMyDidAsync(issuerWallet, new { seed = "000000000000000000000000Steward1" }.ToJson()); // Creata a schema and credential definition for this issuer var schemaId = await schemaService.CreateSchemaAsync(pool, issuerWallet, issuer.Did, $"Test-Schema-{Guid.NewGuid().ToString()}", "1.0", new[] { "first_name", "last_name" }); var definitionId = await schemaService.CreateCredentialDefinitionAsync(pool, issuerWallet, schemaId, issuer.Did, revocable, 100, new Uri("http://mock/tails")); var offerConfig = new DefaultCreateOfferConfiguration() { ConnectionId = issuerConnectionId, IssuerDid = issuer.Did, CredentialDefinitionId = definitionId }; // Send an offer to the holder using the established connection channel await credentialService.SendOfferAsync(issuerWallet, offerConfig); // Holder retrives message from their cloud agent var credentialOffer = FindContentMessage <CredentialOfferMessage>(messages); // Holder processes the credential offer by storing it var holderCredentialId = await credentialService.ProcessOfferAsync(holderWallet, credentialOffer); // Holder creates master secret. Will also be created during wallet agent provisioning await AnonCreds.ProverCreateMasterSecretAsync(holderWallet, proverMasterSecretId); // Holder accepts the credential offer and sends a credential request await credentialService.AcceptOfferAsync(holderWallet, pool, holderCredentialId, new Dictionary <string, string> { { "first_name", "Jane" }, { "last_name", "Doe" } }); // Issuer retrieves credential request from cloud agent var credentialRequest = FindContentMessage <CredentialRequestMessage>(messages); Assert.NotNull(credentialRequest); // Issuer processes the credential request by storing it var issuerCredentialId = await credentialService.ProcessCredentialRequestAsync(issuerWallet, credentialRequest); // Issuer accepts the credential requests and issues a credential await credentialService.IssueCredentialAsync(pool, issuerWallet, issuer.Did, issuerCredentialId); // Holder retrieves the credential from their cloud agent var credential = FindContentMessage <CredentialMessage>(messages); Assert.NotNull(credential); // Holder processes the credential by storing it in their wallet await credentialService.ProcessCredentialAsync(pool, holderWallet, credential); // Verify states of both credential records are set to 'Issued' var issuerCredential = await credentialService.GetAsync(issuerWallet, issuerCredentialId); var holderCredential = await credentialService.GetAsync(holderWallet, holderCredentialId); return(issuerCredential, holderCredential); }