Skip to content

Commit

Permalink
Refactoring: Rename class libzcash::Note to libzcash::SproutNote.
Browse files Browse the repository at this point in the history
  • Loading branch information
bitcartel committed Apr 25, 2018
1 parent bef33bb commit b230fe6
Show file tree
Hide file tree
Showing 21 changed files with 61 additions and 61 deletions.
18 changes: 9 additions & 9 deletions src/gtest/test_joinsplit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void test_full_api(ZCJoinSplit* js)
JSOutput() // dummy output
};

boost::array<Note, 2> output_notes;
boost::array<SproutNote, 2> output_notes;

// Perform the proof
proof = js->prove(
Expand Down Expand Up @@ -127,7 +127,7 @@ void test_full_api(ZCJoinSplit* js)
JSOutput() // dummy output
};

boost::array<Note, 2> output_notes;
boost::array<SproutNote, 2> output_notes;

// Perform the proof
proof = js->prove(
Expand Down Expand Up @@ -180,7 +180,7 @@ void invokeAPI(
boost::array<uint256, 2> commitments;
boost::array<ZCNoteEncryption::Ciphertext, 2> ciphertexts;

boost::array<Note, 2> output_notes;
boost::array<SproutNote, 2> output_notes;

ZCProof proof = js->prove(
inputs,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/gtest/test_transaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/primitives/transaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ JSDescription::JSDescription(ZCJoinSplit& params,
uint256 *esk // payment disclosure
) : vpub_old(vpub_old), vpub_new(vpub_new), anchor(anchor)
{
boost::array<libzcash::Note, ZC_NUM_JS_OUTPUTS> notes;
boost::array<libzcash::SproutNote, ZC_NUM_JS_OUTPUTS> notes;

proof = params.prove(
inputs,
Expand Down
2 changes: 1 addition & 1 deletion src/test/coins_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/test/rpc_wallet_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion src/test/transaction_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
10 changes: 5 additions & 5 deletions src/utiltest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ CWalletTx GetValidReceive(ZCJoinSplit& params,
libzcash::JSOutput(sk.address(), value)
};

boost::array<libzcash::Note, 2> output_notes;
boost::array<libzcash::SproutNote, 2> output_notes;

// Prepare JoinSplits
uint256 rt;
Expand All @@ -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()};
Expand All @@ -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;
Expand All @@ -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);
}
Expand All @@ -123,7 +123,7 @@ CWalletTx GetValidSpend(ZCJoinSplit& params,
libzcash::JSOutput() // dummy output
};

boost::array<libzcash::Note, 2> output_notes;
boost::array<libzcash::SproutNote, 2> output_notes;

// Prepare JoinSplits
uint256 rt = tree.root();
Expand Down
4 changes: 2 additions & 2 deletions src/utiltest.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
6 changes: 3 additions & 3 deletions src/wallet/asyncrpcoperation_mergetoaddress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -481,7 +481,7 @@ bool AsyncRPCOperation_mergetoaddress::main_impl()
//
// Consume spendable non-change notes
//
std::vector<Note> vInputNotes;
std::vector<SproutNote> vInputNotes;
std::vector<SpendingKey> vInputZKeys;
std::vector<JSOutPoint> vOutPoints;
std::vector<boost::optional<ZCIncrementalWitness>> vInputWitnesses;
Expand All @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions src/wallet/asyncrpcoperation_mergetoaddress.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ using namespace libzcash;
typedef std::tuple<COutPoint, CAmount> MergeToAddressInputUTXO;

// Input JSOP is a tuple of JSOutpoint, note, amount, spending key
typedef std::tuple<JSOutPoint, Note, CAmount, SpendingKey> MergeToAddressInputNote;
typedef std::tuple<JSOutPoint, SproutNote, CAmount, SpendingKey> MergeToAddressInputNote;

// A recipient is a tuple of address, memo (optional if zaddr)
typedef std::tuple<std::string, std::string> MergeToAddressRecipient;
Expand All @@ -37,7 +37,7 @@ typedef std::tuple<std::string, std::string> MergeToAddressRecipient;
struct MergeToAddressJSInfo {
std::vector<JSInput> vjsin;
std::vector<JSOutput> vjsout;
std::vector<Note> notes;
std::vector<SproutNote> notes;
std::vector<SpendingKey> zkeys;
CAmount vpub_old = 0;
CAmount vpub_new = 0;
Expand Down
6 changes: 3 additions & 3 deletions src/wallet/asyncrpcoperation_sendmany.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -597,15 +597,15 @@ bool AsyncRPCOperation_sendmany::main_impl() {
//
// Consume spendable non-change notes
//
std::vector<Note> vInputNotes;
std::vector<SproutNote> vInputNotes;
std::vector<JSOutPoint> vOutPoints;
std::vector<boost::optional<ZCIncrementalWitness>> vInputWitnesses;
uint256 inputAnchor;
int numInputsNeeded = (jsChange>0) ? 1 : 0;
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();

Expand Down
4 changes: 2 additions & 2 deletions src/wallet/asyncrpcoperation_sendmany.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ typedef std::tuple<std::string, CAmount, std::string> SendManyRecipient;
typedef std::tuple<uint256, int, CAmount, bool> SendManyInputUTXO;

// Input JSOP is a tuple of JSOutpoint, note and amount
typedef std::tuple<JSOutPoint, Note, CAmount> SendManyInputJSOP;
typedef std::tuple<JSOutPoint, SproutNote, CAmount> SendManyInputJSOP;

// Package of info which is passed to perform_joinsplit methods.
struct AsyncJoinSplitInfo
{
std::vector<JSInput> vjsin;
std::vector<JSOutput> vjsout;
std::vector<Note> notes;
std::vector<SproutNote> notes;
CAmount vpub_old = 0;
CAmount vpub_new = 0;
};
Expand Down
4 changes: 2 additions & 2 deletions src/wallet/gtest/test_wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion src/wallet/rpcdisclosure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
6 changes: 3 additions & 3 deletions src/wallet/rpcwallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<boost::optional<ZCIncrementalWitness>> witnesses;
Expand Down Expand Up @@ -2891,7 +2891,7 @@ UniValue zc_raw_joinsplit(const UniValue& params, bool fHelp)

std::vector<JSInput> vjsin;
std::vector<JSOutput> vjsout;
std::vector<Note> notes;
std::vector<SproutNote> notes;
std::vector<SpendingKey> keys;
std::vector<uint256> commitments;

Expand All @@ -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());
}
Expand Down
8 changes: 4 additions & 4 deletions src/zcash/JoinSplit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class JoinSplitCircuit : public JoinSplit<NumInputs, NumOutputs> {
ZCProof prove(
const boost::array<JSInput, NumInputs>& inputs,
const boost::array<JSOutput, NumOutputs>& outputs,
boost::array<Note, NumOutputs>& out_notes,
boost::array<SproutNote, NumOutputs>& out_notes,
boost::array<ZCNoteEncryption::Ciphertext, NumOutputs>& out_ciphertexts,
uint256& out_ephemeralKey,
const uint256& pubKeyHash,
Expand Down Expand Up @@ -364,10 +364,10 @@ uint256 JoinSplit<NumInputs, NumOutputs>::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) {
Expand All @@ -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();
Expand Down
8 changes: 4 additions & 4 deletions src/zcash/JoinSplit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -40,7 +40,7 @@ class JSOutput {
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<size_t NumInputs, size_t NumOutputs>
Expand All @@ -62,7 +62,7 @@ class JoinSplit {
virtual ZCProof prove(
const boost::array<JSInput, NumInputs>& inputs,
const boost::array<JSOutput, NumOutputs>& outputs,
boost::array<Note, NumOutputs>& out_notes,
boost::array<SproutNote, NumOutputs>& out_notes,
boost::array<ZCNoteEncryption::Ciphertext, NumOutputs>& out_ciphertexts,
uint256& out_ephemeralKey,
const uint256& pubKeyHash,
Expand Down
Loading

0 comments on commit b230fe6

Please sign in to comment.