internal ulong GetAccountIdFromPublicKey(BinaryHexString publicKey) { var publicKeyHash = ComputeHash(publicKey.ToBytes().ToArray()); var bigInteger = new BigInteger(publicKeyHash.Take(8).ToArray()); return((ulong)(long)bigInteger); }
public BinaryHexString GetSharedKey(BinaryHexString accountPublicKey, BinaryHexString nonce, string secretPhrase) { var accountBytes = accountPublicKey.ToBytes().ToArray(); var nonceBytes = nonce.ToBytes().ToArray(); var sharedSecret = _crypto.GetSharedSecret(accountBytes, nonceBytes, secretPhrase); return(sharedSecret); }
public BinaryHexString EncryptDataTo(BinaryHexString recipientPublicKey, BinaryHexString data, BinaryHexString nonce, bool compress, string secretPhrase) { var recipientPublicKeyBytes = recipientPublicKey.ToBytes().ToArray(); var nonceBytes = nonce.ToBytes().ToArray(); var dataBytes = data.ToBytes().ToArray(); if (compress) { dataBytes = _gzipCompressor.GzipCompress(dataBytes); } return(_crypto.AesEncryptTo(recipientPublicKeyBytes, dataBytes, nonceBytes, secretPhrase)); }
public byte[] DecryptData(BinaryHexString data, BinaryHexString nonce, bool uncompress, BinaryHexString sharedKey) { var sharedKeyBytes = sharedKey.ToBytes().ToArray(); var dataBytes = data.ToBytes().ToArray(); var nonceBytes = nonce.ToBytes().ToArray(); var decrypted = _crypto.AesDecrypt(dataBytes, nonceBytes, sharedKeyBytes); if (uncompress) { decrypted = _gzipCompressor.GzipUncompress(decrypted); } return(decrypted); }
public byte[] DecryptDataFrom(BinaryHexString senderPublicKey, BinaryHexString data, BinaryHexString nonce, bool uncompress, string secretPhrase) { var senderPublicKeyBytes = senderPublicKey.ToBytes().ToArray(); var dataBytes = data.ToBytes().ToArray(); var nonceBytes = nonce.ToBytes().ToArray(); var decrypted = _crypto.AesDecryptFrom(senderPublicKeyBytes, dataBytes, nonceBytes, secretPhrase); if (uncompress) { decrypted = _gzipCompressor.GzipUncompress(decrypted); } return(decrypted); }