diff --git a/src/gtest/test_joinsplit.cpp b/src/gtest/test_joinsplit.cpp index 979d0d518..a9814e4ab 100644 --- a/src/gtest/test_joinsplit.cpp +++ b/src/gtest/test_joinsplit.cpp @@ -52,7 +52,7 @@ void test_full_api(ZCJoinSplit* js) JSOutput() // dummy output }; - boost::array output_notes; + boost::array output_notes; // Perform the proof proof = js->prove( @@ -127,7 +127,7 @@ void test_full_api(ZCJoinSplit* js) JSOutput() // dummy output }; - boost::array output_notes; + boost::array output_notes; // Perform the proof proof = js->prove( @@ -180,7 +180,7 @@ void invokeAPI( boost::array commitments; boost::array ciphertexts; - boost::array output_notes; + boost::array output_notes; ZCProof proof = js->prove( inputs, @@ -316,15 +316,15 @@ TEST(joinsplit, full_api_test) increment_note_witnesses(uint256(), witnesses, tree); SpendingKey sk = SpendingKey::random(); PaymentAddress addr = sk.address(); - Note note1(addr.a_pk, 100, random_uint256(), random_uint256()); + SproutNote note1(addr.a_pk, 100, random_uint256(), random_uint256()); increment_note_witnesses(note1.cm(), witnesses, tree); - Note note2(addr.a_pk, 100, random_uint256(), random_uint256()); + SproutNote note2(addr.a_pk, 100, random_uint256(), random_uint256()); increment_note_witnesses(note2.cm(), witnesses, tree); - Note note3(addr.a_pk, 2100000000000001, random_uint256(), random_uint256()); + SproutNote note3(addr.a_pk, 2100000000000001, random_uint256(), random_uint256()); increment_note_witnesses(note3.cm(), witnesses, tree); - Note note4(addr.a_pk, 1900000000000000, random_uint256(), random_uint256()); + SproutNote note4(addr.a_pk, 1900000000000000, random_uint256(), random_uint256()); increment_note_witnesses(note4.cm(), witnesses, tree); - Note note5(addr.a_pk, 1900000000000000, random_uint256(), random_uint256()); + SproutNote note5(addr.a_pk, 1900000000000000, random_uint256(), random_uint256()); increment_note_witnesses(note5.cm(), witnesses, tree); // Should work @@ -523,7 +523,7 @@ TEST(joinsplit, note_plaintexts) ZCNoteEncryption encryptor(h_sig); uint256 epk = encryptor.get_epk(); - Note note(a_pk, + SproutNote note(a_pk, 1945813, random_uint256(), random_uint256() diff --git a/src/gtest/test_transaction.cpp b/src/gtest/test_transaction.cpp index fb68fd35c..0f78fcb39 100644 --- a/src/gtest/test_transaction.cpp +++ b/src/gtest/test_transaction.cpp @@ -15,7 +15,7 @@ TEST(Transaction, JSDescriptionRandomized) { libzcash::SpendingKey k = libzcash::SpendingKey::random(); libzcash::PaymentAddress addr = k.address(); - libzcash::Note note(addr.a_pk, 100, uint256(), uint256()); + libzcash::SproutNote note(addr.a_pk, 100, uint256(), uint256()); // commitment from coin uint256 commitment = note.cm(); diff --git a/src/primitives/transaction.cpp b/src/primitives/transaction.cpp index 4f61b24ea..87b5600e5 100644 --- a/src/primitives/transaction.cpp +++ b/src/primitives/transaction.cpp @@ -20,7 +20,7 @@ JSDescription::JSDescription(ZCJoinSplit& params, uint256 *esk // payment disclosure ) : vpub_old(vpub_old), vpub_new(vpub_new), anchor(anchor) { - boost::array notes; + boost::array notes; proof = params.prove( inputs, diff --git a/src/test/coins_tests.cpp b/src/test/coins_tests.cpp index 383616ae0..125a2b03e 100644 --- a/src/test/coins_tests.cpp +++ b/src/test/coins_tests.cpp @@ -157,7 +157,7 @@ uint256 appendRandomCommitment(ZCIncrementalMerkleTree &tree) libzcash::SpendingKey k = libzcash::SpendingKey::random(); libzcash::PaymentAddress addr = k.address(); - libzcash::Note note(addr.a_pk, 0, uint256(), uint256()); + libzcash::SproutNote note(addr.a_pk, 0, uint256(), uint256()); auto cm = note.cm(); tree.append(cm); diff --git a/src/test/rpc_wallet_tests.cpp b/src/test/rpc_wallet_tests.cpp index ce2da60c1..d09764908 100644 --- a/src/test/rpc_wallet_tests.cpp +++ b/src/test/rpc_wallet_tests.cpp @@ -1178,7 +1178,7 @@ BOOST_AUTO_TEST_CASE(rpc_z_sendmany_internals) BOOST_CHECK( string(e.what()).find("anchor is null")!= string::npos); } - info.notes.push_back(Note()); + info.notes.push_back(SproutNote()); try { proxy.perform_joinsplit(info); } catch (const std::runtime_error & e) { @@ -1716,7 +1716,7 @@ BOOST_AUTO_TEST_CASE(rpc_z_mergetoaddress_internals) BOOST_CHECK( string(e.what()).find("anchor is null")!= string::npos); } - info.notes.push_back(Note()); + info.notes.push_back(SproutNote()); try { proxy.perform_joinsplit(info); BOOST_FAIL("Should have caused an error"); diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp index 1b0b26ee7..af15adcce 100644 --- a/src/test/transaction_tests.cpp +++ b/src/test/transaction_tests.cpp @@ -345,7 +345,7 @@ BOOST_AUTO_TEST_CASE(test_basic_joinsplit_verification) libzcash::SpendingKey k = libzcash::SpendingKey::random(); libzcash::PaymentAddress addr = k.address(); - libzcash::Note note(addr.a_pk, 100, uint256(), uint256()); + libzcash::SproutNote note(addr.a_pk, 100, uint256(), uint256()); // commitment from coin uint256 commitment = note.cm(); diff --git a/src/utiltest.cpp b/src/utiltest.cpp index 4599cec3c..8245adf8e 100644 --- a/src/utiltest.cpp +++ b/src/utiltest.cpp @@ -38,7 +38,7 @@ CWalletTx GetValidReceive(ZCJoinSplit& params, libzcash::JSOutput(sk.address(), value) }; - boost::array output_notes; + boost::array output_notes; // Prepare JoinSplits uint256 rt; @@ -63,7 +63,7 @@ CWalletTx GetValidReceive(ZCJoinSplit& params, return wtx; } -libzcash::Note GetNote(ZCJoinSplit& params, +libzcash::SproutNote GetNote(ZCJoinSplit& params, const libzcash::SpendingKey& sk, const CTransaction& tx, size_t js, size_t n) { ZCNoteDecryption decryptor {sk.receiving_key()}; @@ -79,7 +79,7 @@ libzcash::Note GetNote(ZCJoinSplit& params, CWalletTx GetValidSpend(ZCJoinSplit& params, const libzcash::SpendingKey& sk, - const libzcash::Note& note, CAmount value) { + const libzcash::SproutNote& note, CAmount value) { CMutableTransaction mtx; mtx.vout.resize(2); mtx.vout[0].nValue = value; @@ -105,7 +105,7 @@ CWalletTx GetValidSpend(ZCJoinSplit& params, } else if (note.value < value) { libzcash::SpendingKey dummykey = libzcash::SpendingKey::random(); libzcash::PaymentAddress dummyaddr = dummykey.address(); - libzcash::Note dummynote(dummyaddr.a_pk, (value - note.value), uint256(), uint256()); + libzcash::SproutNote dummynote(dummyaddr.a_pk, (value - note.value), uint256(), uint256()); tree.append(dummynote.cm()); dummyin = libzcash::JSInput(tree.witness(), dummynote, dummykey); } @@ -123,7 +123,7 @@ CWalletTx GetValidSpend(ZCJoinSplit& params, libzcash::JSOutput() // dummy output }; - boost::array output_notes; + boost::array output_notes; // Prepare JoinSplits uint256 rt = tree.root(); diff --git a/src/utiltest.h b/src/utiltest.h index 8cfa60d06..d9da2a1de 100644 --- a/src/utiltest.h +++ b/src/utiltest.h @@ -10,9 +10,9 @@ CWalletTx GetValidReceive(ZCJoinSplit& params, const libzcash::SpendingKey& sk, CAmount value, bool randomInputs); -libzcash::Note GetNote(ZCJoinSplit& params, +libzcash::SproutNote GetNote(ZCJoinSplit& params, const libzcash::SpendingKey& sk, const CTransaction& tx, size_t js, size_t n); CWalletTx GetValidSpend(ZCJoinSplit& params, const libzcash::SpendingKey& sk, - const libzcash::Note& note, CAmount value); + const libzcash::SproutNote& note, CAmount value); diff --git a/src/wallet/asyncrpcoperation_mergetoaddress.cpp b/src/wallet/asyncrpcoperation_mergetoaddress.cpp index d029c79c5..6e6d3c7d0 100644 --- a/src/wallet/asyncrpcoperation_mergetoaddress.cpp +++ b/src/wallet/asyncrpcoperation_mergetoaddress.cpp @@ -462,7 +462,7 @@ bool AsyncRPCOperation_mergetoaddress::main_impl() hSig, (unsigned char)changeOutputIndex); - Note note = plaintext.note(changeAddress); + SproutNote note = plaintext.note(changeAddress); info.notes.push_back(note); info.zkeys.push_back(changeKey); @@ -481,7 +481,7 @@ bool AsyncRPCOperation_mergetoaddress::main_impl() // // Consume spendable non-change notes // - std::vector vInputNotes; + std::vector vInputNotes; std::vector vInputZKeys; std::vector vOutPoints; std::vector> vInputWitnesses; @@ -490,7 +490,7 @@ bool AsyncRPCOperation_mergetoaddress::main_impl() while (numInputsNeeded++ < ZC_NUM_JS_INPUTS && zInputsDeque.size() > 0) { MergeToAddressInputNote t = zInputsDeque.front(); JSOutPoint jso = std::get<0>(t); - Note note = std::get<1>(t); + SproutNote note = std::get<1>(t); CAmount noteFunds = std::get<2>(t); SpendingKey zkey = std::get<3>(t); zInputsDeque.pop_front(); diff --git a/src/wallet/asyncrpcoperation_mergetoaddress.h b/src/wallet/asyncrpcoperation_mergetoaddress.h index 34548a5ba..9b291cdf6 100644 --- a/src/wallet/asyncrpcoperation_mergetoaddress.h +++ b/src/wallet/asyncrpcoperation_mergetoaddress.h @@ -28,7 +28,7 @@ using namespace libzcash; typedef std::tuple MergeToAddressInputUTXO; // Input JSOP is a tuple of JSOutpoint, note, amount, spending key -typedef std::tuple MergeToAddressInputNote; +typedef std::tuple MergeToAddressInputNote; // A recipient is a tuple of address, memo (optional if zaddr) typedef std::tuple MergeToAddressRecipient; @@ -37,7 +37,7 @@ typedef std::tuple MergeToAddressRecipient; struct MergeToAddressJSInfo { std::vector vjsin; std::vector vjsout; - std::vector notes; + std::vector notes; std::vector zkeys; CAmount vpub_old = 0; CAmount vpub_new = 0; diff --git a/src/wallet/asyncrpcoperation_sendmany.cpp b/src/wallet/asyncrpcoperation_sendmany.cpp index 35c5fcfcb..de6da102f 100644 --- a/src/wallet/asyncrpcoperation_sendmany.cpp +++ b/src/wallet/asyncrpcoperation_sendmany.cpp @@ -578,7 +578,7 @@ bool AsyncRPCOperation_sendmany::main_impl() { hSig, (unsigned char) changeOutputIndex); - Note note = plaintext.note(frompaymentaddress_); + SproutNote note = plaintext.note(frompaymentaddress_); info.notes.push_back(note); jsInputValue += plaintext.value; @@ -597,7 +597,7 @@ bool AsyncRPCOperation_sendmany::main_impl() { // // Consume spendable non-change notes // - std::vector vInputNotes; + std::vector vInputNotes; std::vector vOutPoints; std::vector> vInputWitnesses; uint256 inputAnchor; @@ -605,7 +605,7 @@ bool AsyncRPCOperation_sendmany::main_impl() { while (numInputsNeeded++ < ZC_NUM_JS_INPUTS && zInputsDeque.size() > 0) { SendManyInputJSOP t = zInputsDeque.front(); JSOutPoint jso = std::get<0>(t); - Note note = std::get<1>(t); + SproutNote note = std::get<1>(t); CAmount noteFunds = std::get<2>(t); zInputsDeque.pop_front(); diff --git a/src/wallet/asyncrpcoperation_sendmany.h b/src/wallet/asyncrpcoperation_sendmany.h index 113f11f49..97c4533f1 100644 --- a/src/wallet/asyncrpcoperation_sendmany.h +++ b/src/wallet/asyncrpcoperation_sendmany.h @@ -31,14 +31,14 @@ typedef std::tuple SendManyRecipient; typedef std::tuple SendManyInputUTXO; // Input JSOP is a tuple of JSOutpoint, note and amount -typedef std::tuple SendManyInputJSOP; +typedef std::tuple SendManyInputJSOP; // Package of info which is passed to perform_joinsplit methods. struct AsyncJoinSplitInfo { std::vector vjsin; std::vector vjsout; - std::vector notes; + std::vector notes; CAmount vpub_old = 0; CAmount vpub_new = 0; }; diff --git a/src/wallet/gtest/test_wallet.cpp b/src/wallet/gtest/test_wallet.cpp index e976e4ae4..78984abed 100644 --- a/src/wallet/gtest/test_wallet.cpp +++ b/src/wallet/gtest/test_wallet.cpp @@ -72,13 +72,13 @@ CWalletTx GetValidReceive(const libzcash::SpendingKey& sk, CAmount value, bool r return GetValidReceive(*params, sk, value, randomInputs); } -libzcash::Note GetNote(const libzcash::SpendingKey& sk, +libzcash::SproutNote GetNote(const libzcash::SpendingKey& sk, const CTransaction& tx, size_t js, size_t n) { return GetNote(*params, sk, tx, js, n); } CWalletTx GetValidSpend(const libzcash::SpendingKey& sk, - const libzcash::Note& note, CAmount value) { + const libzcash::SproutNote& note, CAmount value) { return GetValidSpend(*params, sk, note, value); } diff --git a/src/wallet/rpcdisclosure.cpp b/src/wallet/rpcdisclosure.cpp index 539cf4b2a..e1c20ab0b 100644 --- a/src/wallet/rpcdisclosure.cpp +++ b/src/wallet/rpcdisclosure.cpp @@ -283,7 +283,7 @@ UniValue z_validatepaymentdisclosure(const UniValue& params, bool fHelp) // Check the blockchain commitment matches decrypted note commitment uint256 cm_blockchain = jsdesc.commitments[pd.payload.n]; - Note note = npt.note(zaddr); + SproutNote note = npt.note(zaddr); uint256 cm_decrypted = note.cm(); bool cm_match = (cm_decrypted == cm_blockchain); o.push_back(Pair("commitmentMatch", cm_match)); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index e86f0e2de..3b237a7ce 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -2817,7 +2817,7 @@ UniValue zc_raw_receive(const UniValue& params, bool fHelp) nonce ); PaymentAddress payment_addr = k.address(); - Note decrypted_note = npt.note(payment_addr); + SproutNote decrypted_note = npt.note(payment_addr); assert(pwalletMain != NULL); std::vector> witnesses; @@ -2891,7 +2891,7 @@ UniValue zc_raw_joinsplit(const UniValue& params, bool fHelp) std::vector vjsin; std::vector vjsout; - std::vector notes; + std::vector notes; std::vector keys; std::vector commitments; @@ -2909,7 +2909,7 @@ UniValue zc_raw_joinsplit(const UniValue& params, bool fHelp) } PaymentAddress addr = k.address(); - Note note = npt.note(addr); + SproutNote note = npt.note(addr); notes.push_back(note); commitments.push_back(note.cm()); } diff --git a/src/zcash/JoinSplit.cpp b/src/zcash/JoinSplit.cpp index 2685569d3..2d7ed1153 100644 --- a/src/zcash/JoinSplit.cpp +++ b/src/zcash/JoinSplit.cpp @@ -139,7 +139,7 @@ public: ZCProof prove( const boost::array& inputs, const boost::array& outputs, - boost::array& out_notes, + boost::array& out_notes, boost::array& out_ciphertexts, uint256& out_ephemeralKey, const uint256& pubKeyHash, @@ -364,10 +364,10 @@ uint256 JoinSplit::h_sig( return output; } -Note JSOutput::note(const uint252& phi, const uint256& r, size_t i, const uint256& h_sig) const { +SproutNote JSOutput::note(const uint252& phi, const uint256& r, size_t i, const uint256& h_sig) const { uint256 rho = PRF_rho(phi, i, h_sig); - return Note(addr.a_pk, value, rho, r); + return SproutNote(addr.a_pk, value, rho, r); } JSOutput::JSOutput() : addr(uint256(), uint256()), value(0) { @@ -377,7 +377,7 @@ JSOutput::JSOutput() : addr(uint256(), uint256()), value(0) { JSInput::JSInput() : witness(ZCIncrementalMerkleTree().witness()), key(SpendingKey::random()) { - note = Note(key.address().a_pk, 0, random_uint256(), random_uint256()); + note = SproutNote(key.address().a_pk, 0, random_uint256(), random_uint256()); ZCIncrementalMerkleTree dummy_tree; dummy_tree.append(note.cm()); witness = dummy_tree.witness(); diff --git a/src/zcash/JoinSplit.hpp b/src/zcash/JoinSplit.hpp index 6a2d4e1f2..28ca98e97 100644 --- a/src/zcash/JoinSplit.hpp +++ b/src/zcash/JoinSplit.hpp @@ -18,12 +18,12 @@ namespace libzcash { class JSInput { public: ZCIncrementalWitness witness; - Note note; + SproutNote note; SpendingKey key; JSInput(); JSInput(ZCIncrementalWitness witness, - Note note, + SproutNote note, SpendingKey key) : witness(witness), note(note), key(key) { } uint256 nullifier() const { @@ -40,7 +40,7 @@ public: JSOutput(); JSOutput(PaymentAddress addr, uint64_t value) : addr(addr), value(value) { } - Note note(const uint252& phi, const uint256& r, size_t i, const uint256& h_sig) const; + SproutNote note(const uint252& phi, const uint256& r, size_t i, const uint256& h_sig) const; }; template @@ -62,7 +62,7 @@ public: virtual ZCProof prove( const boost::array& inputs, const boost::array& outputs, - boost::array& out_notes, + boost::array& out_notes, boost::array& out_ciphertexts, uint256& out_ephemeralKey, const uint256& pubKeyHash, diff --git a/src/zcash/Note.cpp b/src/zcash/Note.cpp index afef81458..c16a225ff 100644 --- a/src/zcash/Note.cpp +++ b/src/zcash/Note.cpp @@ -9,14 +9,14 @@ namespace libzcash { -Note::Note() { +SproutNote::SproutNote() { a_pk = random_uint256(); rho = random_uint256(); r = random_uint256(); value = 0; } -uint256 Note::cm() const { +uint256 SproutNote::cm() const { unsigned char discriminant = 0xb0; CSHA256 hasher; @@ -35,12 +35,12 @@ uint256 Note::cm() const { return result; } -uint256 Note::nullifier(const SpendingKey& a_sk) const { +uint256 SproutNote::nullifier(const SpendingKey& a_sk) const { return PRF_nf(a_sk, rho); } NotePlaintext::NotePlaintext( - const Note& note, + const SproutNote& note, boost::array memo) : memo(memo) { value = note.value; @@ -48,9 +48,9 @@ NotePlaintext::NotePlaintext( r = note.r; } -Note NotePlaintext::note(const PaymentAddress& addr) const +SproutNote NotePlaintext::note(const PaymentAddress& addr) const { - return Note(addr.a_pk, value, rho, r); + return SproutNote(addr.a_pk, value, rho, r); } NotePlaintext NotePlaintext::decrypt(const ZCNoteDecryption& decryptor, diff --git a/src/zcash/Note.hpp b/src/zcash/Note.hpp index 6261937d2..623fdbb6c 100644 --- a/src/zcash/Note.hpp +++ b/src/zcash/Note.hpp @@ -13,17 +13,17 @@ public: virtual uint256 cm() const {}; }; -class Note : public BaseNote { +class SproutNote : public BaseNote { public: uint256 a_pk; uint64_t value; uint256 rho; uint256 r; - Note(uint256 a_pk, uint64_t value, uint256 rho, uint256 r) + SproutNote(uint256 a_pk, uint64_t value, uint256 rho, uint256 r) : a_pk(a_pk), value(value), rho(rho), r(r) {} - Note(); + SproutNote(); virtual uint256 cm() const override; @@ -39,9 +39,9 @@ public: NotePlaintext() {} - NotePlaintext(const Note& note, boost::array memo); + NotePlaintext(const SproutNote& note, boost::array memo); - Note note(const PaymentAddress& addr) const; + SproutNote note(const PaymentAddress& addr) const; ADD_SERIALIZE_METHODS; diff --git a/src/zcash/circuit/gadget.tcc b/src/zcash/circuit/gadget.tcc index 141ec834e..d13c05962 100644 --- a/src/zcash/circuit/gadget.tcc +++ b/src/zcash/circuit/gadget.tcc @@ -191,7 +191,7 @@ public: const uint256& rt, const uint256& h_sig, const boost::array& inputs, - const boost::array& outputs, + const boost::array& outputs, uint64_t vpub_old, uint64_t vpub_new ) { diff --git a/src/zcash/circuit/note.tcc b/src/zcash/circuit/note.tcc index f472cb151..69526ec71 100644 --- a/src/zcash/circuit/note.tcc +++ b/src/zcash/circuit/note.tcc @@ -21,7 +21,7 @@ public: r->generate_r1cs_constraints(); } - void generate_r1cs_witness(const Note& note) { + void generate_r1cs_witness(const SproutNote& note) { r->bits.fill_with_bits(this->pb, uint256_to_bool_vector(note.r)); value.fill_with_bits(this->pb, uint64_to_bool_vector(note.value)); } @@ -119,7 +119,7 @@ public: void generate_r1cs_witness( const MerklePath& path, const SpendingKey& key, - const Note& note + const SproutNote& note ) { note_gadget::generate_r1cs_witness(note); @@ -222,7 +222,7 @@ public: commit_to_outputs->generate_r1cs_constraints(); } - void generate_r1cs_witness(const Note& note) { + void generate_r1cs_witness(const SproutNote& note) { note_gadget::generate_r1cs_witness(note); prevent_faerie_gold->generate_r1cs_witness();