Decryption and tests of note/outgoing encryption.
This commit is contained in:
@@ -154,12 +154,59 @@ boost::optional<SaplingNote> SaplingNotePlaintext::note(const SaplingIncomingVie
|
||||
{
|
||||
auto addr = ivk.address( d );
|
||||
if (addr) {
|
||||
return SaplingNote(addr.get(), value_);
|
||||
return SaplingNote(d, addr.get().pk_d, value_, rcm);
|
||||
} else {
|
||||
return boost::none;
|
||||
}
|
||||
}
|
||||
|
||||
boost::optional<SaplingOutgoingPlaintext> SaplingOutgoingPlaintext::decrypt(
|
||||
const SaplingOutCiphertext &ciphertext,
|
||||
const uint256& ovk,
|
||||
const uint256& cv,
|
||||
const uint256& cm,
|
||||
const uint256& epk
|
||||
)
|
||||
{
|
||||
auto pt = AttemptSaplingOutDecryption(ciphertext, ovk, cv, cm, epk);
|
||||
if (!pt) {
|
||||
return boost::none;
|
||||
}
|
||||
|
||||
// Deserialize from the plaintext
|
||||
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
|
||||
ss << pt.get();
|
||||
|
||||
SaplingOutgoingPlaintext ret;
|
||||
ss >> ret;
|
||||
|
||||
assert(ss.size() == 0);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
boost::optional<SaplingNotePlaintext> SaplingNotePlaintext::decrypt(
|
||||
const SaplingEncCiphertext &ciphertext,
|
||||
const uint256 &ivk,
|
||||
const uint256 &epk
|
||||
)
|
||||
{
|
||||
auto pt = AttemptSaplingEncDecryption(ciphertext, ivk, epk);
|
||||
if (!pt) {
|
||||
return boost::none;
|
||||
}
|
||||
|
||||
// Deserialize from the plaintext
|
||||
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
|
||||
ss << pt.get();
|
||||
|
||||
SaplingNotePlaintext ret;
|
||||
ss >> ret;
|
||||
|
||||
assert(ss.size() == 0);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
boost::optional<SaplingNotePlaintextEncryptionResult> SaplingNotePlaintext::encrypt(const uint256& pk_d) const
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user