Exemplo n.º 1
0
std::vector<unsigned char> RippleAddress::accountPrivateEncrypt(const RippleAddress& naPublicTo, const std::vector<unsigned char>& vucPlainText) const
{
	CKey						ckPrivate;
	CKey						ckPublic;
	std::vector<unsigned char>	vucCipherText;

	if (!ckPublic.SetPubKey(naPublicTo.getAccountPublic()))
	{
		// Bad public key.
		cLog(lsWARNING) << "accountPrivateEncrypt: Bad public key.";
	}
	else if (!ckPrivate.SetPrivateKeyU(getAccountPrivate()))
	{
		// Bad private key.
		cLog(lsWARNING) << "accountPrivateEncrypt: Bad private key.";
	}
	else
	{
		try
		{
			vucCipherText = ckPrivate.encryptECIES(ckPublic, vucPlainText);
		}
		catch (...)
		{
			nothing();
		}
	}

	return vucCipherText;
}
Exemplo n.º 2
0
Blob RippleAddress::accountPrivateEncrypt (const RippleAddress& naPublicTo, Blob const& vucPlainText) const
{
    CKey                        ckPrivate;
    CKey                        ckPublic;
    Blob    vucCipherText;

    if (!ckPublic.SetPubKey (naPublicTo.getAccountPublic ()))
    {
        // Bad public key.
        WriteLog (lsWARNING, RippleAddress) << "accountPrivateEncrypt: Bad public key.";
    }
    else if (!ckPrivate.SetPrivateKeyU (getAccountPrivate ()))
    {
        // Bad private key.
        WriteLog (lsWARNING, RippleAddress) << "accountPrivateEncrypt: Bad private key.";
    }
    else
    {
        try
        {
            vucCipherText = ckPrivate.encryptECIES (ckPublic, vucPlainText);
        }
        catch (...)
        {
            nothing ();
        }
    }

    return vucCipherText;
}