Remove JSDescription::h_sig
This removes the zcash/JoinSplit.hpp dependency from primitives/transaction.cpp, and thus from libzcashconsensus.
This commit is contained in:
parent
911dd2655e
commit
f6a5273e5f
|
@ -5,6 +5,7 @@
|
|||
#ifndef MEMPOOLLIMIT_H
|
||||
#define MEMPOOLLIMIT_H
|
||||
|
||||
#include <deque>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
|
|
@ -9,11 +9,6 @@
|
|||
#include "tinyformat.h"
|
||||
#include "utilstrencodings.h"
|
||||
|
||||
uint256 JSDescription::h_sig(const uint256& joinSplitPubKey) const
|
||||
{
|
||||
return ZCJoinSplit::h_sig(randomSeed, nullifiers, joinSplitPubKey);
|
||||
}
|
||||
|
||||
std::string COutPoint::ToString() const
|
||||
{
|
||||
return strprintf("COutPoint(%s, %u)", hash.ToString().substr(0,10), n);
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
#include "zcash/NoteEncryption.hpp"
|
||||
#include "zcash/Zcash.h"
|
||||
#include "zcash/JoinSplit.hpp"
|
||||
#include "zcash/Proof.hpp"
|
||||
|
||||
// Overwinter transaction version
|
||||
|
@ -233,9 +232,6 @@ public:
|
|||
|
||||
JSDescription(): vpub_old(0), vpub_new(0) { }
|
||||
|
||||
// Returns the calculated h_sig
|
||||
uint256 h_sig(const uint256& joinSplitPubKey) const;
|
||||
|
||||
ADD_SERIALIZE_METHODS;
|
||||
|
||||
template <typename Stream, typename Operation>
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "undo.h"
|
||||
#include "primitives/transaction.h"
|
||||
#include "pubkey.h"
|
||||
#include "zcash/Note.hpp"
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
|
|
@ -634,7 +634,10 @@ void TransactionBuilder::CreateJSDescriptions()
|
|||
|
||||
// Decrypt the change note's ciphertext to retrieve some data we need
|
||||
ZCNoteDecryption decryptor(changeKey.receiving_key());
|
||||
auto hSig = prevJoinSplit.h_sig(mtx.joinSplitPubKey);
|
||||
auto hSig = ZCJoinSplit::h_sig(
|
||||
prevJoinSplit.randomSeed,
|
||||
prevJoinSplit.nullifiers,
|
||||
mtx.joinSplitPubKey);
|
||||
try {
|
||||
auto plaintext = libzcash::SproutNotePlaintext::decrypt(
|
||||
decryptor,
|
||||
|
|
|
@ -114,7 +114,10 @@ CWalletTx GetInvalidCommitmentSproutReceive(
|
|||
libzcash::SproutNote GetSproutNote(const libzcash::SproutSpendingKey& sk,
|
||||
const CTransaction& tx, size_t js, size_t n) {
|
||||
ZCNoteDecryption decryptor {sk.receiving_key()};
|
||||
auto hSig = tx.vJoinSplit[js].h_sig(tx.joinSplitPubKey);
|
||||
auto hSig = ZCJoinSplit::h_sig(
|
||||
tx.vJoinSplit[js].randomSeed,
|
||||
tx.vJoinSplit[js].nullifiers,
|
||||
tx.joinSplitPubKey);
|
||||
auto note_pt = libzcash::SproutNotePlaintext::decrypt(
|
||||
decryptor,
|
||||
tx.vJoinSplit[js].ciphertexts[n],
|
||||
|
|
|
@ -546,7 +546,10 @@ bool AsyncRPCOperation_mergetoaddress::main_impl()
|
|||
|
||||
// Decrypt the change note's ciphertext to retrieve some data we need
|
||||
ZCNoteDecryption decryptor(changeKey.receiving_key());
|
||||
auto hSig = prevJoinSplit.h_sig(tx_.joinSplitPubKey);
|
||||
auto hSig = ZCJoinSplit::h_sig(
|
||||
prevJoinSplit.randomSeed,
|
||||
prevJoinSplit.nullifiers,
|
||||
tx_.joinSplitPubKey);
|
||||
try {
|
||||
SproutNotePlaintext plaintext = SproutNotePlaintext::decrypt(
|
||||
decryptor,
|
||||
|
@ -846,7 +849,7 @@ UniValue AsyncRPCOperation_mergetoaddress::perform_joinsplit(
|
|||
ss2 << ((unsigned char)0x00);
|
||||
ss2 << jsdesc.ephemeralKey;
|
||||
ss2 << jsdesc.ciphertexts[0];
|
||||
ss2 << jsdesc.h_sig(joinSplitPubKey_);
|
||||
ss2 << ZCJoinSplit::h_sig(jsdesc.randomSeed, jsdesc.nullifiers, joinSplitPubKey_);
|
||||
|
||||
encryptedNote1 = HexStr(ss2.begin(), ss2.end());
|
||||
}
|
||||
|
@ -855,7 +858,7 @@ UniValue AsyncRPCOperation_mergetoaddress::perform_joinsplit(
|
|||
ss2 << ((unsigned char)0x01);
|
||||
ss2 << jsdesc.ephemeralKey;
|
||||
ss2 << jsdesc.ciphertexts[1];
|
||||
ss2 << jsdesc.h_sig(joinSplitPubKey_);
|
||||
ss2 << ZCJoinSplit::h_sig(jsdesc.randomSeed, jsdesc.nullifiers, joinSplitPubKey_);
|
||||
|
||||
encryptedNote2 = HexStr(ss2.begin(), ss2.end());
|
||||
}
|
||||
|
|
|
@ -693,7 +693,10 @@ bool AsyncRPCOperation_sendmany::main_impl() {
|
|||
|
||||
// Decrypt the change note's ciphertext to retrieve some data we need
|
||||
ZCNoteDecryption decryptor(boost::get<libzcash::SproutSpendingKey>(spendingkey_).receiving_key());
|
||||
auto hSig = prevJoinSplit.h_sig(tx_.joinSplitPubKey);
|
||||
auto hSig = ZCJoinSplit::h_sig(
|
||||
prevJoinSplit.randomSeed,
|
||||
prevJoinSplit.nullifiers,
|
||||
tx_.joinSplitPubKey);
|
||||
try {
|
||||
SproutNotePlaintext plaintext = SproutNotePlaintext::decrypt(
|
||||
decryptor,
|
||||
|
@ -1127,7 +1130,7 @@ UniValue AsyncRPCOperation_sendmany::perform_joinsplit(
|
|||
ss2 << ((unsigned char) 0x00);
|
||||
ss2 << jsdesc.ephemeralKey;
|
||||
ss2 << jsdesc.ciphertexts[0];
|
||||
ss2 << jsdesc.h_sig(joinSplitPubKey_);
|
||||
ss2 << ZCJoinSplit::h_sig(jsdesc.randomSeed, jsdesc.nullifiers, joinSplitPubKey_);
|
||||
|
||||
encryptedNote1 = HexStr(ss2.begin(), ss2.end());
|
||||
}
|
||||
|
@ -1136,7 +1139,7 @@ UniValue AsyncRPCOperation_sendmany::perform_joinsplit(
|
|||
ss2 << ((unsigned char) 0x01);
|
||||
ss2 << jsdesc.ephemeralKey;
|
||||
ss2 << jsdesc.ciphertexts[1];
|
||||
ss2 << jsdesc.h_sig(joinSplitPubKey_);
|
||||
ss2 << ZCJoinSplit::h_sig(jsdesc.randomSeed, jsdesc.nullifiers, joinSplitPubKey_);
|
||||
|
||||
encryptedNote2 = HexStr(ss2.begin(), ss2.end());
|
||||
}
|
||||
|
|
|
@ -366,7 +366,7 @@ UniValue AsyncRPCOperation_shieldcoinbase::perform_joinsplit(ShieldCoinbaseJSInf
|
|||
ss2 << ((unsigned char) 0x00);
|
||||
ss2 << jsdesc.ephemeralKey;
|
||||
ss2 << jsdesc.ciphertexts[0];
|
||||
ss2 << jsdesc.h_sig(joinSplitPubKey_);
|
||||
ss2 << ZCJoinSplit::h_sig(jsdesc.randomSeed, jsdesc.nullifiers, joinSplitPubKey_);
|
||||
|
||||
encryptedNote1 = HexStr(ss2.begin(), ss2.end());
|
||||
}
|
||||
|
@ -375,7 +375,7 @@ UniValue AsyncRPCOperation_shieldcoinbase::perform_joinsplit(ShieldCoinbaseJSInf
|
|||
ss2 << ((unsigned char) 0x01);
|
||||
ss2 << jsdesc.ephemeralKey;
|
||||
ss2 << jsdesc.ciphertexts[1];
|
||||
ss2 << jsdesc.h_sig(joinSplitPubKey_);
|
||||
ss2 << ZCJoinSplit::h_sig(jsdesc.randomSeed, jsdesc.nullifiers, joinSplitPubKey_);
|
||||
|
||||
encryptedNote2 = HexStr(ss2.begin(), ss2.end());
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "transaction_builder.h"
|
||||
#include "utiltest.h"
|
||||
#include "wallet/wallet.h"
|
||||
#include "zcash/JoinSplit.hpp"
|
||||
#include "zcash/Note.hpp"
|
||||
#include "zcash/NoteEncryption.hpp"
|
||||
|
||||
|
@ -445,7 +446,10 @@ TEST(WalletTests, CheckSproutNoteCommitmentAgainstNotePlaintext) {
|
|||
auto note = GetSproutNote(sk, wtx, 0, 1);
|
||||
auto nullifier = note.nullifier(sk);
|
||||
|
||||
auto hSig = wtx.vJoinSplit[0].h_sig(wtx.joinSplitPubKey);
|
||||
auto hSig = ZCJoinSplit::h_sig(
|
||||
wtx.vJoinSplit[0].randomSeed,
|
||||
wtx.vJoinSplit[0].nullifiers,
|
||||
wtx.joinSplitPubKey);
|
||||
|
||||
ASSERT_THROW(wallet.GetSproutNoteNullifier(
|
||||
wtx.vJoinSplit[0],
|
||||
|
@ -466,7 +470,10 @@ TEST(WalletTests, GetSproutNoteNullifier) {
|
|||
auto note = GetSproutNote(sk, wtx, 0, 1);
|
||||
auto nullifier = note.nullifier(sk);
|
||||
|
||||
auto hSig = wtx.vJoinSplit[0].h_sig(wtx.joinSplitPubKey);
|
||||
auto hSig = ZCJoinSplit::h_sig(
|
||||
wtx.vJoinSplit[0].randomSeed,
|
||||
wtx.vJoinSplit[0].nullifiers,
|
||||
wtx.joinSplitPubKey);
|
||||
|
||||
auto ret = wallet.GetSproutNoteNullifier(
|
||||
wtx.vJoinSplit[0],
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "wallet.h"
|
||||
#include "wallet/paymentdisclosure.h"
|
||||
#include "wallet/paymentdisclosuredb.h"
|
||||
#include "zcash/JoinSplit.hpp"
|
||||
|
||||
#include <fstream>
|
||||
#include <stdint.h>
|
||||
|
@ -260,7 +261,7 @@ UniValue z_validatepaymentdisclosure(const UniValue& params, bool fHelp)
|
|||
try {
|
||||
// Decrypt the note to get value and memo field
|
||||
JSDescription jsdesc = tx.vJoinSplit[pd.payload.js];
|
||||
uint256 h_sig = jsdesc.h_sig(tx.joinSplitPubKey);
|
||||
uint256 h_sig = ZCJoinSplit::h_sig(jsdesc.randomSeed, jsdesc.nullifiers, tx.joinSplitPubKey);
|
||||
|
||||
ZCPaymentDisclosureNoteDecryption decrypter;
|
||||
|
||||
|
|
|
@ -3180,7 +3180,7 @@ UniValue zc_raw_joinsplit(const UniValue& params, bool fHelp)
|
|||
ss2 << ((unsigned char) 0x00);
|
||||
ss2 << jsdesc.ephemeralKey;
|
||||
ss2 << jsdesc.ciphertexts[0];
|
||||
ss2 << jsdesc.h_sig(joinSplitPubKey);
|
||||
ss2 << ZCJoinSplit::h_sig(jsdesc.randomSeed, jsdesc.nullifiers, joinSplitPubKey);
|
||||
|
||||
encryptedNote1 = HexStr(ss2.begin(), ss2.end());
|
||||
}
|
||||
|
@ -3189,7 +3189,7 @@ UniValue zc_raw_joinsplit(const UniValue& params, bool fHelp)
|
|||
ss2 << ((unsigned char) 0x01);
|
||||
ss2 << jsdesc.ephemeralKey;
|
||||
ss2 << jsdesc.ciphertexts[1];
|
||||
ss2 << jsdesc.h_sig(joinSplitPubKey);
|
||||
ss2 << ZCJoinSplit::h_sig(jsdesc.randomSeed, jsdesc.nullifiers, joinSplitPubKey);
|
||||
|
||||
encryptedNote2 = HexStr(ss2.begin(), ss2.end());
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "script/sign.h"
|
||||
#include "timedata.h"
|
||||
#include "utilmoneystr.h"
|
||||
#include "zcash/JoinSplit.hpp"
|
||||
#include "zcash/Note.hpp"
|
||||
#include "crypter.h"
|
||||
#include "wallet/asyncrpcoperation_saplingmigration.h"
|
||||
|
@ -1446,7 +1447,10 @@ bool CWallet::UpdateNullifierNoteMap()
|
|||
if (!item.second.nullifier) {
|
||||
if (GetNoteDecryptor(item.second.address, dec)) {
|
||||
auto i = item.first.js;
|
||||
auto hSig = wtxItem.second.vJoinSplit[i].h_sig(wtxItem.second.joinSplitPubKey);
|
||||
auto hSig = ZCJoinSplit::h_sig(
|
||||
wtxItem.second.vJoinSplit[i].randomSeed,
|
||||
wtxItem.second.vJoinSplit[i].nullifiers,
|
||||
wtxItem.second.joinSplitPubKey);
|
||||
item.second.nullifier = GetSproutNoteNullifier(
|
||||
wtxItem.second.vJoinSplit[i],
|
||||
item.second.address,
|
||||
|
@ -1865,7 +1869,10 @@ mapSproutNoteData_t CWallet::FindMySproutNotes(const CTransaction &tx) const
|
|||
|
||||
mapSproutNoteData_t noteData;
|
||||
for (size_t i = 0; i < tx.vJoinSplit.size(); i++) {
|
||||
auto hSig = tx.vJoinSplit[i].h_sig(tx.joinSplitPubKey);
|
||||
auto hSig = ZCJoinSplit::h_sig(
|
||||
tx.vJoinSplit[i].randomSeed,
|
||||
tx.vJoinSplit[i].nullifiers,
|
||||
tx.joinSplitPubKey);
|
||||
for (uint8_t j = 0; j < tx.vJoinSplit[i].ciphertexts.size(); j++) {
|
||||
for (const NoteDecryptorMap::value_type& item : mapNoteDecryptors) {
|
||||
try {
|
||||
|
@ -2295,7 +2302,10 @@ std::pair<SproutNotePlaintext, SproutPaymentAddress> CWalletTx::DecryptSproutNot
|
|||
keyIO.EncodePaymentAddress(pa)));
|
||||
}
|
||||
|
||||
auto hSig = this->vJoinSplit[jsop.js].h_sig(this->joinSplitPubKey);
|
||||
auto hSig = ZCJoinSplit::h_sig(
|
||||
this->vJoinSplit[jsop.js].randomSeed,
|
||||
this->vJoinSplit[jsop.js].nullifiers,
|
||||
this->joinSplitPubKey);
|
||||
try {
|
||||
SproutNotePlaintext plaintext = SproutNotePlaintext::decrypt(
|
||||
decryptor,
|
||||
|
@ -5048,7 +5058,10 @@ void CWallet::GetFilteredNotes(
|
|||
}
|
||||
|
||||
// determine amount of funds in the note
|
||||
auto hSig = wtx.vJoinSplit[i].h_sig(wtx.joinSplitPubKey);
|
||||
auto hSig = ZCJoinSplit::h_sig(
|
||||
wtx.vJoinSplit[i].randomSeed,
|
||||
wtx.vJoinSplit[i].nullifiers,
|
||||
wtx.joinSplitPubKey);
|
||||
try {
|
||||
SproutNotePlaintext plaintext = SproutNotePlaintext::decrypt(
|
||||
decryptor,
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "wallet/walletdb.h"
|
||||
#include "wallet/rpcwallet.h"
|
||||
#include "zcash/Address.hpp"
|
||||
#include "zcash/Note.hpp"
|
||||
#include "base58.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
|
Loading…
Reference in New Issue