private string CreateEncryptedCertificationConfirmationToken(Certificate[] certificates) { CertificationConfirmationToken certConfToken = new CertificationConfirmationToken() { PublicKey = _accountService.PublicKey, Encrypted = true, IssuedCertificates = certificates }; byte[] requesterPubKey = Nethereum.Hex.HexConvertors.Extensions.HexByteConvertorExtensions.HexToByteArray(SynAck.PublicKey); _tokenCryptoService.Sign(certConfToken, _accountService.GetPrivateKeyAsByteArray()); return(_tokenCryptoService.Encrypt(certConfToken, requesterPubKey, _accountService.GetPrivateKeyAsByteArray())); }
private async Task ProcessCertificationConfirmationToken(string encryptedToken) { string decryptedToken = _tokenCryptoService.Decrypt(encryptedToken, _accountService.GetPrivateKeyAsByteArray()); CertificationConfirmationTokenFactory tokenFactory = new CertificationConfirmationTokenFactory(_certificateFacade); CertificationConfirmationToken token = await tokenFactory.CreateTokenAsync(decryptedToken); if (token.PublicKey != Ack.PublicKey) { throw new TokenPublicKeyMismatch(); } if (_tokenCryptoService.VerifySignature(token)) { await AddCertificatesToTheAccessibleAttributes(token.IssuedCertificates); } else { throw new SignatureDoesntMatchException("The signature was not " + "generated by the given " + "public Key"); } }