예제 #1
0
        public async Task RequestIdentityProof()
        {
            var context = await _agentContextProvider.GetContextAsync();

            //var connection = await _connectionService.GetAsync(context, _connectionRecord.Id);

            if (SelectedDefinition == null || SelectedSchema == null)
            {
                return;
            }

            var identityAttributes = new ProofAttributeInfo
            {
                Names        = new string[] { "fist_name", "last_name" },
                Restrictions = new List <AttributeFilter>
                {
                    new AttributeFilter
                    {
                        SchemaId = SelectedSchema.Id,
                        CredentialDefinitionId = SelectedDefinition.Id
                    }
                }
            };


            var proofRequestObject = new ProofRequest
            {
                Name                = "Identity Proof Request",
                Version             = "3.0",
                Nonce               = new BigInteger(Guid.NewGuid().ToByteArray()).ToString(),
                RequestedAttributes = new Dictionary <string, ProofAttributeInfo>
                {
                    { $"identity_attrs_requirement", identityAttributes }
                },
                RequestedPredicates = null
            };

            var(request, _) = await _proofService.CreateRequestAsync(context, proofRequestObject, _connectionRecord.Id);

            await _messageService.SendAsync(context, request, _connectionRecord);
        }
예제 #2
0
        protected void OnCredentialDefintionSelect()
        {
            CreateProofRequestRequest.ProofRequest.RequestedAttributes.Clear();

            if (!string.IsNullOrEmpty(CredentialDefinitionId))
            {
                Console.WriteLine("Adding All Attributes");
                DefinitionRecord definitionRecord = CredentialDefinitionState.CredentialDefinitions[CredentialDefinitionId];
                string           schemaId         = definitionRecord.SchemaId;
                SchemaRecord     schemaRecord     = SchemaState.Schemas[schemaId];
                CreateProofRequestRequest.ProofRequest.Name    = schemaRecord.Name;
                CreateProofRequestRequest.ProofRequest.Version = schemaRecord.Version;
                foreach (string name in schemaRecord.AttributeNames)
                {
                    var restrictions = new List <AttributeFilter>();

                    var attributeFilter = new AttributeFilter
                    {
                        CredentialDefinitionId = definitionRecord.Id
                    };

                    restrictions.Add(attributeFilter);

                    var proofAttributeInfo = new ProofAttributeInfo()
                    {
                        Name         = name,
                        Restrictions = restrictions,
                    };

                    CreateProofRequestRequest.ProofRequest
                    .RequestedAttributes
                    .Add($"0_{name}_uuid", proofAttributeInfo);
                }

                Console.WriteLine($"Added:{CreateProofRequestRequest.ProofRequest.RequestedAttributes.Count}");
            }
        }