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
b1aa9365af
commit
79ad5984b1
|
@ -5,6 +5,7 @@
|
|||
#ifndef ZCASH_MEMPOOL_LIMIT_H
|
||||
#define ZCASH_MEMPOOL_LIMIT_H
|
||||
|
||||
#include <deque>
|
||||
#include <map>
|
||||
#include <optional>
|
||||
#include <set>
|
||||
|
|
|
@ -9,11 +9,6 @@
|
|||
#include "tinyformat.h"
|
||||
#include "utilstrencodings.h"
|
||||
|
||||
uint256 JSDescription::h_sig(const Ed25519VerificationKey& 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"
|
||||
|
||||
#include <rust/ed25519/types.h>
|
||||
|
@ -235,9 +234,6 @@ public:
|
|||
|
||||
JSDescription(): vpub_old(0), vpub_new(0) { }
|
||||
|
||||
// Returns the calculated h_sig
|
||||
uint256 h_sig(const Ed25519VerificationKey& 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],
|
||||
|
|
|
@ -553,7 +553,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,
|
||||
|
@ -857,7 +860,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());
|
||||
}
|
||||
|
@ -866,7 +869,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());
|
||||
}
|
||||
|
|
|
@ -638,7 +638,10 @@ bool AsyncRPCOperation_sendmany::main_impl() {
|
|||
|
||||
// Decrypt the change note's ciphertext to retrieve some data we need
|
||||
ZCNoteDecryption decryptor(std::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,
|
||||
|
@ -1106,7 +1109,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());
|
||||
}
|
||||
|
@ -1115,7 +1118,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());
|
||||
}
|
||||
|
|
|
@ -369,7 +369,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());
|
||||
}
|
||||
|
@ -378,7 +378,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>
|
||||
|
@ -271,7 +272,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;
|
||||
|
||||
|
|
|
@ -3196,7 +3196,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());
|
||||
}
|
||||
|
@ -3205,7 +3205,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());
|
||||
}
|
||||
|
|
|
@ -25,6 +25,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"
|
||||
|
@ -1468,7 +1469,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,
|
||||
|
@ -1887,7 +1891,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 {
|
||||
|
@ -2317,7 +2324,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,
|
||||
|
@ -5101,7 +5111,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