public IActionResult ProcessRootIdentityRequest(string issuer, [FromBody] IdentityRequestDto identityRequest) { Account identityProviderAccount = _accountsService.GetByPublicKey(issuer.HexStringToByteArray()); StatePersistency statePersistency = _executionContextManager.ResolveStateExecutionServices(identityProviderAccount.AccountId); Tuple <bool, bool> proceed = VerifyFaceImage(identityRequest.FaceImageContent, identityRequest.RootAttributeContent, issuer); if (proceed.Item1) { byte[] rootAssetId = _assetsService.GenerateAssetId(AttributeType.IdCard, identityRequest.RootAttributeContent); byte[] faceImageAssetId = _assetsService.GenerateAssetId(AttributeType.PassportPhoto, identityRequest.FaceImageContent); ProcessIssuingAssociatedAttributes(identityRequest, statePersistency.TransactionsService, rootAssetId, faceImageAssetId); return(TransferAssetToUtxo(statePersistency.TransactionsService, new ConfidentialAccount { PublicSpendKey = identityRequest.RequesterPublicSpendKey.HexStringToByteArray(), PublicViewKey = identityRequest.RequesterPublicViewKey.HexStringToByteArray() }, rootAssetId)); } else { if (!proceed.Item2) { return(BadRequest(new { Message = $"Failed to find person with ID Card number {identityRequest.RootAttributeContent}" })); } return(BadRequest(new { Message = "Captured face does not match to registered one" })); } }
public IActionResult CreateIdentity([FromBody] IdentityDto identity) { ulong accountId = ulong.Parse(User.Identity.Name, CultureInfo.InvariantCulture); StatePersistency statePersistency = _executionContextManager.ResolveStateExecutionServices(accountId); Account account = _accountsService.GetById(accountId); byte[] assetId = _assetsService.GenerateAssetId((AttributeType)identity.RootAttribute.AttributeType, identity.RootAttribute.Content); statePersistency.TransactionsService.IssueBlindedAsset(assetId, 0UL.ToByteArray(32), out byte[] originatingCommitment); identity.RootAttribute.OriginatingCommitment = originatingCommitment.ToHexString(); Identity identityDb = _externalDataAccessService.CreateIdentity(accountId, identity.Description, new IdentityAttribute { AttributeType = AttributeType.IdCard, Content = identity.RootAttribute.Content, Subject = ClaimSubject.User, Commitment = originatingCommitment }); identity.Id = identityDb.IdentityId.ToString(CultureInfo.InvariantCulture); string imageContent = null; foreach (var identityAttributeDto in identity.AssociatedAttributes) { IdentityAttribute identityAttribute = new IdentityAttribute { AttributeType = (AttributeType)identityAttributeDto.AttributeType, Content = identityAttributeDto.Content, Subject = ClaimSubject.User }; _externalDataAccessService.AddAssociatedIdentityAttribute(identityDb.IdentityId, ref identityAttribute); if (((AttributeType)identityAttributeDto.AttributeType) == AttributeType.PassportPhoto) { imageContent = identityAttributeDto.Content; } } if (!string.IsNullOrEmpty(identity.RootAttribute.Content) && !string.IsNullOrEmpty(imageContent)) { $"{Request.Scheme}://{Request.Host.ToUriComponent()}/biometric/".AppendPathSegment("RegisterPerson").PostJsonAsync(new BiometricPersonDataDto { Requester = account.PublicSpendKey.ToHexString(), PersonData = identity.RootAttribute.Content, ImageString = imageContent }); } _hubContext.Clients.Group(User.Identity.Name).SendAsync("PushIdentity", identity); return(Ok()); }
public IActionResult GetById(ulong accountId) { Account account = _accountsService.GetById(accountId); if (account == null) { return(BadRequest()); } var identityProvider = new IdentityProviderInfoDto { Id = account.AccountId.ToString(CultureInfo.InvariantCulture), Description = account.AccountInfo, Target = account.PublicSpendKey.ToHexString() }; return(Ok(identityProvider)); }