Esempio n. 1
0
        public IActionResult SendAuthenticationRequest([FromBody] UserAttributeTransferDto userAttributeTransfer)
        {
            bool  res       = false;
            ulong accountId = ulong.Parse(User.Identity.Name, CultureInfo.InvariantCulture);

            UtxoPersistency utxoPersistency = _executionContextManager.ResolveUtxoExecutionServices(accountId);

            byte[] target  = userAttributeTransfer.Target.HexStringToByteArray();
            byte[] issuer  = userAttributeTransfer.Source.HexStringToByteArray();
            byte[] payload = userAttributeTransfer.Payload.HexStringToByteArray();
            byte[] assetId = userAttributeTransfer.AssetId.HexStringToByteArray();
            byte[] originalBlindingFactor = userAttributeTransfer.OriginalBlindingFactor.HexStringToByteArray();
            byte[] originalCommitment     = userAttributeTransfer.OriginalCommitment.HexStringToByteArray();
            byte[] lastTransactionKey     = userAttributeTransfer.LastTransactionKey.HexStringToByteArray();
            byte[] lastBlindingFactor     = userAttributeTransfer.LastBlindingFactor.HexStringToByteArray();
            byte[] lastCommitment         = userAttributeTransfer.LastCommitment.HexStringToByteArray();
            byte[] lastDestinationKey     = userAttributeTransfer.LastDestinationKey.HexStringToByteArray();


            RequestInput requestInput = new RequestInput {
                AssetId = assetId, EligibilityBlindingFactor = originalBlindingFactor, EligibilityCommitment = originalCommitment, Issuer = issuer, PrevAssetCommitment = lastCommitment, PrevBlindingFactor = lastBlindingFactor, PrevDestinationKey = lastDestinationKey, PrevTransactionKey = lastTransactionKey, Target = target, Payload = payload
            };

            OutputModel[] outputModels        = _gatewayService.GetOutputs(_portalConfiguration.RingSize + 1);
            byte[][]      issuanceCommitments = _gatewayService.GetIssuanceCommitments(issuer, _portalConfiguration.RingSize + 1);
            RequestResult requestResult       = utxoPersistency.TransactionsService.SendAuthenticationRequest(requestInput, outputModels, issuanceCommitments).Result;

            res = true;
            return(Ok(res));
        }
Esempio n. 2
0
        private void SendOnboardingRequest(UserAttributeTransferDto userAttributeTransfer, IUtxoTransactionsService transactionsService, AssociatedProofPreparation[] associatedProofPreparations = null)
        {
            byte[] target  = userAttributeTransfer.Target.HexStringToByteArray();
            byte[] issuer  = userAttributeTransfer.Source.HexStringToByteArray();
            byte[] payload = userAttributeTransfer.Payload.HexStringToByteArray();
            byte[] assetId = userAttributeTransfer.AssetId.HexStringToByteArray();
            byte[] originalBlindingFactor = userAttributeTransfer.OriginalBlindingFactor.HexStringToByteArray();
            byte[] originalCommitment     = userAttributeTransfer.OriginalCommitment.HexStringToByteArray();
            byte[] lastTransactionKey     = userAttributeTransfer.LastTransactionKey.HexStringToByteArray();
            byte[] lastBlindingFactor     = userAttributeTransfer.LastBlindingFactor.HexStringToByteArray();
            byte[] lastCommitment         = userAttributeTransfer.LastCommitment.HexStringToByteArray();
            byte[] lastDestinationKey     = userAttributeTransfer.LastDestinationKey.HexStringToByteArray();

            RequestInput requestInput = new RequestInput
            {
                AssetId = assetId,
                EligibilityBlindingFactor = originalBlindingFactor,
                EligibilityCommitment     = originalCommitment,
                Issuer = issuer,
                PrevAssetCommitment = lastCommitment,
                PrevBlindingFactor  = lastBlindingFactor,
                PrevDestinationKey  = lastDestinationKey,
                PrevTransactionKey  = lastTransactionKey,
                Target  = target,
                Payload = payload
            };

            OutputModel[] outputModels        = _gatewayService.GetOutputs(_portalConfiguration.RingSize + 1);
            byte[][]      issuanceCommitments = _gatewayService.GetIssuanceCommitments(issuer, _portalConfiguration.RingSize + 1);
            RequestResult requestResult       = transactionsService.SendOnboardingRequest(requestInput, associatedProofPreparations, outputModels, issuanceCommitments).Result;
        }
Esempio n. 3
0
        private void SendEmployeeRequest(UserAttributeTransferDto userAttributeTransfer, IUtxoTransactionsService transactionsService, AssociatedProofPreparation[] associatedProofPreparations = null)
        {
            byte[] target  = userAttributeTransfer.Target.HexStringToByteArray();
            byte[] issuer  = userAttributeTransfer.Source.HexStringToByteArray();
            byte[] payload = userAttributeTransfer.Payload.HexStringToByteArray();
            byte[] assetId = userAttributeTransfer.AssetId.HexStringToByteArray();
            byte[] originalBlindingFactor = userAttributeTransfer.OriginalBlindingFactor.HexStringToByteArray();
            byte[] originalCommitment     = userAttributeTransfer.OriginalCommitment.HexStringToByteArray();
            byte[] lastTransactionKey     = userAttributeTransfer.LastTransactionKey.HexStringToByteArray();
            byte[] lastBlindingFactor     = userAttributeTransfer.LastBlindingFactor.HexStringToByteArray();
            byte[] lastCommitment         = userAttributeTransfer.LastCommitment.HexStringToByteArray();
            byte[] lastDestinationKey     = userAttributeTransfer.LastDestinationKey.HexStringToByteArray();

            string[] categoryEntries = userAttributeTransfer.ExtraInfo.Split("/");
            foreach (string categoryEntry in categoryEntries)
            {
                string groupName    = categoryEntry.Split("|")[1];
                bool   isRegistered = "true".Equals(categoryEntry.Split("|")[2], StringComparison.InvariantCultureIgnoreCase);

                if (!isRegistered)
                {
                    byte[] groupAssetId = _assetsService.GenerateAssetId(AttributeType.EmployeeGroup, userAttributeTransfer.Target + groupName);
                    EmployeeRequestInput requestInput = new EmployeeRequestInput
                    {
                        AssetId = assetId,
                        EligibilityBlindingFactor = originalBlindingFactor,
                        EligibilityCommitment     = originalCommitment,
                        Issuer = issuer,
                        PrevAssetCommitment = lastCommitment,
                        PrevBlindingFactor  = lastBlindingFactor,
                        PrevDestinationKey  = lastDestinationKey,
                        PrevTransactionKey  = lastTransactionKey,
                        Target       = target,
                        Payload      = payload,
                        GroupAssetId = groupAssetId
                    };

                    OutputModel[] outputModels        = _gatewayService.GetOutputs(_portalConfiguration.RingSize + 1);
                    byte[][]      issuanceCommitments = _gatewayService.GetIssuanceCommitments(issuer, _portalConfiguration.RingSize + 1);
                    RequestResult requestResult       = transactionsService.SendEmployeeRegistrationRequest(requestInput, associatedProofPreparations, outputModels, issuanceCommitments).Result;
                }
            }
        }
Esempio n. 4
0
        private void SendDocumentSignRequest(UserAttributeTransferDto userAttributeTransfer, IUtxoTransactionsService transactionsService, AssociatedProofPreparation[] associatedProofPreparations = null)
        {
            byte[]   target  = userAttributeTransfer.Target.HexStringToByteArray();
            byte[]   issuer  = userAttributeTransfer.Source.HexStringToByteArray();
            byte[]   payload = userAttributeTransfer.Payload.HexStringToByteArray();
            byte[]   assetId = userAttributeTransfer.AssetId.HexStringToByteArray();
            byte[]   originalBlindingFactor = userAttributeTransfer.OriginalBlindingFactor.HexStringToByteArray();
            byte[]   originalCommitment     = userAttributeTransfer.OriginalCommitment.HexStringToByteArray();
            byte[]   lastTransactionKey     = userAttributeTransfer.LastTransactionKey.HexStringToByteArray();
            byte[]   lastBlindingFactor     = userAttributeTransfer.LastBlindingFactor.HexStringToByteArray();
            byte[]   lastCommitment         = userAttributeTransfer.LastCommitment.HexStringToByteArray();
            byte[]   lastDestinationKey     = userAttributeTransfer.LastDestinationKey.HexStringToByteArray();
            string[] extraInfo            = userAttributeTransfer.ExtraInfo.Split('|');
            byte[]   groupIssuer          = extraInfo[0].HexStringToByteArray();
            byte[]   groupAssetId         = _assetsService.GenerateAssetId(AttributeType.EmployeeGroup, extraInfo[0] + extraInfo[1]);
            byte[]   documentHash         = extraInfo[2].HexStringToByteArray();
            ulong    documentRecordHeight = ulong.Parse(extraInfo[3]);

            DocumentSignRequestInput requestInput = new DocumentSignRequestInput
            {
                AssetId = assetId,
                EligibilityBlindingFactor = originalBlindingFactor,
                EligibilityCommitment     = originalCommitment,
                Issuer = issuer,
                PrevAssetCommitment = lastCommitment,
                PrevBlindingFactor  = lastBlindingFactor,
                PrevDestinationKey  = lastDestinationKey,
                PrevTransactionKey  = lastTransactionKey,
                Target               = target,
                Payload              = payload,
                GroupIssuer          = groupIssuer,
                GroupAssetId         = groupAssetId,
                DocumentHash         = documentHash,
                DocumentRecordHeight = documentRecordHeight
            };

            OutputModel[] outputModels        = _gatewayService.GetOutputs(_portalConfiguration.RingSize + 1);
            byte[][]      issuanceCommitments = _gatewayService.GetIssuanceCommitments(issuer, _portalConfiguration.RingSize + 1);
            RequestResult requestResult       = transactionsService.SendDocumentSignRequest(requestInput, associatedProofPreparations, outputModels, issuanceCommitments).Result;
        }
Esempio n. 5
0
        public IActionResult SendOnboardingRequest([FromBody] UserAttributeTransferDto userAttributeTransfer)
        {
            ulong           accountId       = ulong.Parse(User.Identity.Name, CultureInfo.InvariantCulture);
            UtxoPersistency utxoPersistency = _executionContextManager.ResolveUtxoExecutionServices(accountId);

            bool proceed = true;

            if (!string.IsNullOrEmpty(userAttributeTransfer.ImageContent) && !string.IsNullOrEmpty(userAttributeTransfer.Content))
            {
                string sourceImage = _dataAccessService.GetUserAssociatedAttributes(accountId).FirstOrDefault(t => t.Item1 == AttributeType.PassportPhoto)?.Item2;
                BiometricPersonDataForSignatureDto biometricPersonDataForSignature = new BiometricPersonDataForSignatureDto
                {
                    ImageSource = sourceImage,
                    ImageTarget = userAttributeTransfer.ImageContent
                };

                try
                {
                    BiometricSignedVerificationDto biometricSignedVerification = $"{Request.Scheme}://{Request.Host.ToUriComponent()}/biometric/".AppendPathSegment("SignPersonFaceVerification").PostJsonAsync(biometricPersonDataForSignature).ReceiveJson <BiometricSignedVerificationDto>().Result;
                }
                catch (FlurlHttpException)
                {
                    proceed = false;
                }
                //Tuple<bool, bool> faceRes = VerifyFaceImage(userAttributeTransfer.ImageContent, userAttributeTransfer.Content);

                proceed = true;                 // faceRes.Item1;
            }

            if (proceed)
            {
                SendOnboardingRequest(userAttributeTransfer, utxoPersistency.TransactionsService);

                return(Ok(true));
            }

            return(Ok(false));
        }
Esempio n. 6
0
        public IActionResult SendEmployeeRequest([FromBody] UserAttributeTransferDto userAttributeTransfer)
        {
            ulong           accountId       = ulong.Parse(User.Identity.Name, CultureInfo.InvariantCulture);
            UtxoPersistency utxoPersistency = _executionContextManager.ResolveUtxoExecutionServices(accountId);

            bool proceed = true;

            if (!string.IsNullOrEmpty(userAttributeTransfer.ImageContent) && !string.IsNullOrEmpty(userAttributeTransfer.Content))
            {
                string sourceImage = _dataAccessService.GetUserAssociatedAttributes(accountId).FirstOrDefault(t => t.Item1 == AttributeType.PassportPhoto)?.Item2;
                BiometricPersonDataForSignatureDto biometricPersonDataForSignature = new BiometricPersonDataForSignatureDto
                {
                    ImageSource = sourceImage,
                    ImageTarget = userAttributeTransfer.ImageContent
                };

                try
                {
                    BiometricSignedVerificationDto biometricSignedVerification = $"{Request.Scheme}://{Request.Host.ToUriComponent()}/biometric/".AppendPathSegment("SignPersonFaceVerification").PostJsonAsync(biometricPersonDataForSignature).ReceiveJson <BiometricSignedVerificationDto>().Result;
                }
                catch (FlurlHttpException)
                {
                    proceed = false;
                }
                //Tuple<bool, bool> faceRes = VerifyFaceImage(userAttributeTransfer.ImageContent, userAttributeTransfer.Content);

                proceed = true; // faceRes.Item1;
            }

            if (proceed)
            {
                SendEmployeeRequest(userAttributeTransfer, utxoPersistency.TransactionsService);

                string[] categoryEntries = userAttributeTransfer.ExtraInfo.Split("/");

                foreach (string categoryEntry in categoryEntries)
                {
                    string groupOwnerName = categoryEntry.Split("|")[0];
                    string groupName      = categoryEntry.Split("|")[1];

                    ulong groupRelationId = _dataAccessService.AddUserGroupRelation(accountId, groupOwnerName, userAttributeTransfer.Target, groupName);

                    if (groupRelationId > 0)
                    {
                        GroupRelationDto groupRelationDto = new GroupRelationDto
                        {
                            GroupRelationId = groupRelationId,
                            GroupOwnerName  = groupOwnerName,
                            GroupOwnerKey   = userAttributeTransfer.Target,
                            GroupName       = groupName
                        };

                        _idenitiesHubContext.Clients.Group(accountId.ToString(CultureInfo.InvariantCulture)).SendAsync("PushGroupRelation", groupRelationDto);
                    }
                }


                return(Ok(true));
            }

            return(Ok(false));
        }