Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
Implements methods
  • Loading branch information
MarGaaya committed Jun 18, 2024
1 parent e1ba60e commit 4f22849
Show file tree
Hide file tree
Showing 18 changed files with 102 additions and 326 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using System;
using anoncreds_rs_dotnet.Models;
using System.Threading.Tasks;
using System.Collections.Generic;
using anoncreds_rs_dotnet.Anoncreds;
using Hyperledger.Aries.Features.IssueCredential;
using Hyperledger.Aries.Agents;
using Hyperledger.Aries.Contracts;
using Newtonsoft.Json.Linq;

namespace Hyperledger.Aries.Anoncreds.Presentation
{
public class DefaultPresentationService : IPresentationService
{
ISchemaService schemaService;
ILedgerService ledgerService;

public async Task<bool> VerifyPresentationAsync(IAgentContext context, string presReqJson, string presentationJson)
{
var presentation = PresentationApi.CreatePresentationFromJsonAsync(presentationJson);
var presentationRequest = PresentationRequestApi.CreatePresReqFromJsonAsync(presReqJson);

List<string> schemaIds = new List<string>(), credentialDefinitionIds = new List<string>(), revocationRegistryDefinitionIds = new List<string>();
var schemas = new List<Schema>();
var credentialDefinitions = new List<CredentialDefinition>();
var revocationRegistryDefinitions = new List<RevocationRegistryDefinition>();
var revocationStatusList = new List<RevocationStatusList>();

foreach (var identifier in presentation.Result.Identifiers)
{
schemaIds.Add(identifier.SchemaId.ToString());
credentialDefinitionIds.Add(identifier.CredentialDefinitionId.ToString());
revocationRegistryDefinitionIds.Add(identifier.RevocationRegistryId.ToString());

var schema = await schemaService.LookupSchemaAsync(context, identifier.SchemaId.ToString());
schemas.Add(new Schema { JsonString = schema }) ;

var credentialDef = await schemaService.LookupCredentialDefinitionAsync(context, identifier.CredentialDefinitionId.ToString());
credentialDefinitions.Add(new CredentialDefinition { JsonString = credentialDef });

var revRegDefinition = await ledgerService.LookupRevocationRegistryDefinitionAsync(context, identifier.RevocationRegistryId.ToString());
revocationRegistryDefinitions.Add(new RevocationRegistryDefinition { JsonString = revRegDefinition.ObjectJson });

var revocationStatus = await ledgerService.LookupRevocationRegistryAsync(context, identifier.RevocationRegistryId.ToString(), identifier.Timestamp);
revocationStatusList.Add(new RevocationStatusList { JsonString = revocationStatus.ObjectJson });
}
return await PresentationApi.VerifyPresentationAsync(presentation.Result, presentationRequest.Result, schemas, schemaIds, credentialDefinitions, credentialDefinitionIds, revocationRegistryDefinitions, revocationRegistryDefinitionIds, revocationStatusList);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using anoncreds_rs_dotnet.Models;
using Hyperledger.Aries.Agents;
using System.Threading.Tasks;

namespace Hyperledger.Aries.Anoncreds.Presentation
{
public interface IPresentationService
{
Task<bool> VerifyPresentationAsync(IAgentContext context, string presReqJson, string presentationJson);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,22 @@
using Hyperledger.Aries.Agents;
using Hyperledger.Aries.Configuration;
using Hyperledger.Aries.Contracts;
using Hyperledger.Aries.Extensions;
using Hyperledger.Aries.Models.Records;
using Hyperledger.Aries.Revocation.Abstractions;
using Hyperledger.Aries.Revocation.Models;
using Hyperledger.Aries.Revocation.Utils;
using Hyperledger.Indy.AnonCredsApi;
using indy_vdr_dotnet.libindy_vdr;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static Hyperledger.Aries.Revocation.Models.RevRegDefinitionState;

namespace Hyperledger.Aries.Revocation

namespace Hyperledger.Aries.Anoncreds.Revocation
{
public class DefaultRevocationService : IRevocationService
{
public readonly ILedgerService LedgerService;
private readonly IProvisioningService ProvisioningService;

public Regex SupportedIdentifiersRegex => throw new NotImplementedException();

public async Task CreateAndRegisterRevocationRegistryDefinitionAsync(IAgentContext context, string originDid, CredentialDefinition credDefObject, string credDefId, string tag, RegistryType revRegType, long maxCredNumber, string tailsDirPath)
{
var req = await RevocationApi.CreateRevocationRegistryDefinitionAsync(originDid, credDefObject, credDefId, tag, revRegType, maxCredNumber, tailsDirPath);
Expand All @@ -33,16 +28,11 @@ public async Task CreateAndRegisterRevocationRegistryDefinitionAsync(IAgentConte
var provisioning = await ProvisioningService.GetProvisioningAsync(context.Wallet);
revRegDef.IssuerId ??= provisioning.IssuerDid;

var definitionRecord = new DefinitionRecord();
definitionRecord.IssuerDid = revRegDef.IssuerId;

await LedgerService.RegisterRevocationRegistryDefinitionAsync(
context: context,
submitterDid: revRegDef.IssuerId,
data: revRegDef.JsonString,
paymentInfo: null);


}
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
using anoncreds_rs_dotnet.Models;
using Hyperledger.Aries.Agents;
using Hyperledger.Aries.Revocation.Models;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace Hyperledger.Aries.Revocation.Abstractions
namespace Hyperledger.Aries.Anoncreds.Revocation
{
public interface IRevocationService
{
Expand Down
22 changes: 22 additions & 0 deletions src/Hyperledger.Aries/Anoncreds/Schema/DefaultSchemaService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using anoncreds_rs_dotnet.Anoncreds;
using anoncreds_rs_dotnet.Models;
using Hyperledger.Aries.Agents;
using Hyperledger.Aries.Contracts;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace Hyperledger.Aries.Anoncreds.AnoncredsSchema
{
public class DefaultSchemaService : ISchemaService
{
public readonly ILedgerService LedgerService;
public async Task CreateAndRegisterSchemaAsync(IAgentContext context, string issuerDid, string schemaName, string schemaVersion, List<string> attrNames)
{
var schemaJson = await SchemaApi.CreateSchemaJsonAsync(issuerDid, schemaName, schemaVersion, attrNames);

await LedgerService.RegisterSchemaAsync(context, issuerDid, schemaJson);
}
}
}
12 changes: 12 additions & 0 deletions src/Hyperledger.Aries/Anoncreds/Schema/ISchemaService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using anoncreds_rs_dotnet.Models;
using Hyperledger.Aries.Agents;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Hyperledger.Aries.Anoncreds.AnoncredsSchema
{
public interface ISchemaService
{
Task CreateAndRegisterSchemaAsync(IAgentContext context, string issuerDid, string schemaName, string schemaVersion, List<string> attrNames);
}
}
47 changes: 0 additions & 47 deletions src/Hyperledger.Aries/Revocation/DefaultRegistryService.cs

This file was deleted.

10 changes: 0 additions & 10 deletions src/Hyperledger.Aries/Revocation/Enum/Enum.cs

This file was deleted.

30 changes: 0 additions & 30 deletions src/Hyperledger.Aries/Revocation/Models/BaseAnonCredsRegistrar.cs

This file was deleted.

33 changes: 0 additions & 33 deletions src/Hyperledger.Aries/Revocation/Models/Event.cs

This file was deleted.

15 changes: 0 additions & 15 deletions src/Hyperledger.Aries/Revocation/Models/RevRegDef.cs

This file was deleted.

24 changes: 0 additions & 24 deletions src/Hyperledger.Aries/Revocation/Models/RevRegDefResult.cs

This file was deleted.

15 changes: 0 additions & 15 deletions src/Hyperledger.Aries/Revocation/Models/RevRegDefValue.cs

This file was deleted.

31 changes: 0 additions & 31 deletions src/Hyperledger.Aries/Revocation/Models/RevRegDefinitionState.cs

This file was deleted.

This file was deleted.

Loading

0 comments on commit 4f22849

Please sign in to comment.