Exemplo n.º 1
0
        public async Task <IActionResult> GetDocumentSignatures(long spId)
        {
            AccountDescriptor         account   = _accountsService.GetById(spId);
            IEnumerable <DocumentDto> documents = await Task.WhenAll(_dataAccessService.GetSpDocuments(spId)
                                                                     .Select(async d =>
                                                                             new DocumentDto
            {
                DocumentId     = d.SpDocumentId,
                DocumentName   = d.DocumentName,
                Hash           = d.Hash,
                AllowedSigners = (d.AllowedSigners?.Select(s => new AllowedSignerDto
                {
                    AllowedSignerId = s.SpDocumentAllowedSignerId,
                    GroupName = s.GroupName,
                    GroupOwner = s.GroupIssuer
                }) ?? Array.Empty <AllowedSignerDto>()).ToList(),
                Signatures = ((await Task.WhenAll(d.DocumentSignatures?.Select(async s => new DocumentSignatureDto
                {
                    DocumentId = d.SpDocumentId,
                    DocumentHash = d.Hash,
                    SignatureId = s.SpDocumentSignatureId,
                    DocumentRecordHeight = s.DocumentRecordHeight,
                    SignatureRecordHeight = s.SignatureRecordHeight,
                    SignatureVerification = await _documentSignatureVerifier.Verify(account.PublicSpendKey, d.Hash.HexStringToByteArray(), s.DocumentRecordHeight, s.SignatureRecordHeight).ConfigureAwait(false)
                })).ConfigureAwait(false)) ?? Array.Empty <DocumentSignatureDto>()).ToList()
            })).ConfigureAwait(false);

            return(Ok(documents));
        }
Exemplo n.º 2
0
        public IActionResult GetDocumentSignatureVerification([FromQuery] string documentCreator, [FromQuery] string documentHash, [FromQuery] ulong documentRecordHeight, [FromQuery] ulong signatureRecordBlockHeight)
        {
            DocumentSignatureVerification signatureVerification = _documentSignatureVerifier.Verify(documentCreator.HexStringToByteArray(), documentHash.HexStringToByteArray(), documentRecordHeight, signatureRecordBlockHeight);

            return(Ok(signatureVerification));
        }