mirror of
https://git.hush.is/hush/hush3.git
synced 2025-10-01 00:02:58 -04:00
Refactoring: Rename class libzcash::Note to libzcash::SproutNote.
This commit is contained in:
parent
bef33bbc73
commit
b230fe6836
@ -52,7 +52,7 @@ void test_full_api(ZCJoinSplit* js)
|
|||||||
JSOutput() // dummy output
|
JSOutput() // dummy output
|
||||||
};
|
};
|
||||||
|
|
||||||
boost::array<Note, 2> output_notes;
|
boost::array<SproutNote, 2> output_notes;
|
||||||
|
|
||||||
// Perform the proof
|
// Perform the proof
|
||||||
proof = js->prove(
|
proof = js->prove(
|
||||||
@ -127,7 +127,7 @@ void test_full_api(ZCJoinSplit* js)
|
|||||||
JSOutput() // dummy output
|
JSOutput() // dummy output
|
||||||
};
|
};
|
||||||
|
|
||||||
boost::array<Note, 2> output_notes;
|
boost::array<SproutNote, 2> output_notes;
|
||||||
|
|
||||||
// Perform the proof
|
// Perform the proof
|
||||||
proof = js->prove(
|
proof = js->prove(
|
||||||
@ -180,7 +180,7 @@ void invokeAPI(
|
|||||||
boost::array<uint256, 2> commitments;
|
boost::array<uint256, 2> commitments;
|
||||||
boost::array<ZCNoteEncryption::Ciphertext, 2> ciphertexts;
|
boost::array<ZCNoteEncryption::Ciphertext, 2> ciphertexts;
|
||||||
|
|
||||||
boost::array<Note, 2> output_notes;
|
boost::array<SproutNote, 2> output_notes;
|
||||||
|
|
||||||
ZCProof proof = js->prove(
|
ZCProof proof = js->prove(
|
||||||
inputs,
|
inputs,
|
||||||
@ -316,15 +316,15 @@ TEST(joinsplit, full_api_test)
|
|||||||
increment_note_witnesses(uint256(), witnesses, tree);
|
increment_note_witnesses(uint256(), witnesses, tree);
|
||||||
SpendingKey sk = SpendingKey::random();
|
SpendingKey sk = SpendingKey::random();
|
||||||
PaymentAddress addr = sk.address();
|
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);
|
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);
|
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);
|
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);
|
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);
|
increment_note_witnesses(note5.cm(), witnesses, tree);
|
||||||
|
|
||||||
// Should work
|
// Should work
|
||||||
@ -523,7 +523,7 @@ TEST(joinsplit, note_plaintexts)
|
|||||||
ZCNoteEncryption encryptor(h_sig);
|
ZCNoteEncryption encryptor(h_sig);
|
||||||
uint256 epk = encryptor.get_epk();
|
uint256 epk = encryptor.get_epk();
|
||||||
|
|
||||||
Note note(a_pk,
|
SproutNote note(a_pk,
|
||||||
1945813,
|
1945813,
|
||||||
random_uint256(),
|
random_uint256(),
|
||||||
random_uint256()
|
random_uint256()
|
||||||
|
@ -15,7 +15,7 @@ TEST(Transaction, JSDescriptionRandomized) {
|
|||||||
libzcash::SpendingKey k = libzcash::SpendingKey::random();
|
libzcash::SpendingKey k = libzcash::SpendingKey::random();
|
||||||
libzcash::PaymentAddress addr = k.address();
|
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
|
// commitment from coin
|
||||||
uint256 commitment = note.cm();
|
uint256 commitment = note.cm();
|
||||||
|
@ -20,7 +20,7 @@ JSDescription::JSDescription(ZCJoinSplit& params,
|
|||||||
uint256 *esk // payment disclosure
|
uint256 *esk // payment disclosure
|
||||||
) : vpub_old(vpub_old), vpub_new(vpub_new), anchor(anchor)
|
) : 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(
|
proof = params.prove(
|
||||||
inputs,
|
inputs,
|
||||||
|
@ -157,7 +157,7 @@ uint256 appendRandomCommitment(ZCIncrementalMerkleTree &tree)
|
|||||||
libzcash::SpendingKey k = libzcash::SpendingKey::random();
|
libzcash::SpendingKey k = libzcash::SpendingKey::random();
|
||||||
libzcash::PaymentAddress addr = k.address();
|
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();
|
auto cm = note.cm();
|
||||||
tree.append(cm);
|
tree.append(cm);
|
||||||
|
@ -1178,7 +1178,7 @@ BOOST_AUTO_TEST_CASE(rpc_z_sendmany_internals)
|
|||||||
BOOST_CHECK( string(e.what()).find("anchor is null")!= string::npos);
|
BOOST_CHECK( string(e.what()).find("anchor is null")!= string::npos);
|
||||||
}
|
}
|
||||||
|
|
||||||
info.notes.push_back(Note());
|
info.notes.push_back(SproutNote());
|
||||||
try {
|
try {
|
||||||
proxy.perform_joinsplit(info);
|
proxy.perform_joinsplit(info);
|
||||||
} catch (const std::runtime_error & e) {
|
} 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);
|
BOOST_CHECK( string(e.what()).find("anchor is null")!= string::npos);
|
||||||
}
|
}
|
||||||
|
|
||||||
info.notes.push_back(Note());
|
info.notes.push_back(SproutNote());
|
||||||
try {
|
try {
|
||||||
proxy.perform_joinsplit(info);
|
proxy.perform_joinsplit(info);
|
||||||
BOOST_FAIL("Should have caused an error");
|
BOOST_FAIL("Should have caused an error");
|
||||||
|
@ -345,7 +345,7 @@ BOOST_AUTO_TEST_CASE(test_basic_joinsplit_verification)
|
|||||||
libzcash::SpendingKey k = libzcash::SpendingKey::random();
|
libzcash::SpendingKey k = libzcash::SpendingKey::random();
|
||||||
libzcash::PaymentAddress addr = k.address();
|
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
|
// commitment from coin
|
||||||
uint256 commitment = note.cm();
|
uint256 commitment = note.cm();
|
||||||
|
@ -38,7 +38,7 @@ CWalletTx GetValidReceive(ZCJoinSplit& params,
|
|||||||
libzcash::JSOutput(sk.address(), value)
|
libzcash::JSOutput(sk.address(), value)
|
||||||
};
|
};
|
||||||
|
|
||||||
boost::array<libzcash::Note, 2> output_notes;
|
boost::array<libzcash::SproutNote, 2> output_notes;
|
||||||
|
|
||||||
// Prepare JoinSplits
|
// Prepare JoinSplits
|
||||||
uint256 rt;
|
uint256 rt;
|
||||||
@ -63,7 +63,7 @@ CWalletTx GetValidReceive(ZCJoinSplit& params,
|
|||||||
return wtx;
|
return wtx;
|
||||||
}
|
}
|
||||||
|
|
||||||
libzcash::Note GetNote(ZCJoinSplit& params,
|
libzcash::SproutNote GetNote(ZCJoinSplit& params,
|
||||||
const libzcash::SpendingKey& sk,
|
const libzcash::SpendingKey& sk,
|
||||||
const CTransaction& tx, size_t js, size_t n) {
|
const CTransaction& tx, size_t js, size_t n) {
|
||||||
ZCNoteDecryption decryptor {sk.receiving_key()};
|
ZCNoteDecryption decryptor {sk.receiving_key()};
|
||||||
@ -79,7 +79,7 @@ libzcash::Note GetNote(ZCJoinSplit& params,
|
|||||||
|
|
||||||
CWalletTx GetValidSpend(ZCJoinSplit& params,
|
CWalletTx GetValidSpend(ZCJoinSplit& params,
|
||||||
const libzcash::SpendingKey& sk,
|
const libzcash::SpendingKey& sk,
|
||||||
const libzcash::Note& note, CAmount value) {
|
const libzcash::SproutNote& note, CAmount value) {
|
||||||
CMutableTransaction mtx;
|
CMutableTransaction mtx;
|
||||||
mtx.vout.resize(2);
|
mtx.vout.resize(2);
|
||||||
mtx.vout[0].nValue = value;
|
mtx.vout[0].nValue = value;
|
||||||
@ -105,7 +105,7 @@ CWalletTx GetValidSpend(ZCJoinSplit& params,
|
|||||||
} else if (note.value < value) {
|
} else if (note.value < value) {
|
||||||
libzcash::SpendingKey dummykey = libzcash::SpendingKey::random();
|
libzcash::SpendingKey dummykey = libzcash::SpendingKey::random();
|
||||||
libzcash::PaymentAddress dummyaddr = dummykey.address();
|
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());
|
tree.append(dummynote.cm());
|
||||||
dummyin = libzcash::JSInput(tree.witness(), dummynote, dummykey);
|
dummyin = libzcash::JSInput(tree.witness(), dummynote, dummykey);
|
||||||
}
|
}
|
||||||
@ -123,7 +123,7 @@ CWalletTx GetValidSpend(ZCJoinSplit& params,
|
|||||||
libzcash::JSOutput() // dummy output
|
libzcash::JSOutput() // dummy output
|
||||||
};
|
};
|
||||||
|
|
||||||
boost::array<libzcash::Note, 2> output_notes;
|
boost::array<libzcash::SproutNote, 2> output_notes;
|
||||||
|
|
||||||
// Prepare JoinSplits
|
// Prepare JoinSplits
|
||||||
uint256 rt = tree.root();
|
uint256 rt = tree.root();
|
||||||
|
@ -10,9 +10,9 @@
|
|||||||
CWalletTx GetValidReceive(ZCJoinSplit& params,
|
CWalletTx GetValidReceive(ZCJoinSplit& params,
|
||||||
const libzcash::SpendingKey& sk, CAmount value,
|
const libzcash::SpendingKey& sk, CAmount value,
|
||||||
bool randomInputs);
|
bool randomInputs);
|
||||||
libzcash::Note GetNote(ZCJoinSplit& params,
|
libzcash::SproutNote GetNote(ZCJoinSplit& params,
|
||||||
const libzcash::SpendingKey& sk,
|
const libzcash::SpendingKey& sk,
|
||||||
const CTransaction& tx, size_t js, size_t n);
|
const CTransaction& tx, size_t js, size_t n);
|
||||||
CWalletTx GetValidSpend(ZCJoinSplit& params,
|
CWalletTx GetValidSpend(ZCJoinSplit& params,
|
||||||
const libzcash::SpendingKey& sk,
|
const libzcash::SpendingKey& sk,
|
||||||
const libzcash::Note& note, CAmount value);
|
const libzcash::SproutNote& note, CAmount value);
|
||||||
|
@ -462,7 +462,7 @@ bool AsyncRPCOperation_mergetoaddress::main_impl()
|
|||||||
hSig,
|
hSig,
|
||||||
(unsigned char)changeOutputIndex);
|
(unsigned char)changeOutputIndex);
|
||||||
|
|
||||||
Note note = plaintext.note(changeAddress);
|
SproutNote note = plaintext.note(changeAddress);
|
||||||
info.notes.push_back(note);
|
info.notes.push_back(note);
|
||||||
info.zkeys.push_back(changeKey);
|
info.zkeys.push_back(changeKey);
|
||||||
|
|
||||||
@ -481,7 +481,7 @@ bool AsyncRPCOperation_mergetoaddress::main_impl()
|
|||||||
//
|
//
|
||||||
// Consume spendable non-change notes
|
// Consume spendable non-change notes
|
||||||
//
|
//
|
||||||
std::vector<Note> vInputNotes;
|
std::vector<SproutNote> vInputNotes;
|
||||||
std::vector<SpendingKey> vInputZKeys;
|
std::vector<SpendingKey> vInputZKeys;
|
||||||
std::vector<JSOutPoint> vOutPoints;
|
std::vector<JSOutPoint> vOutPoints;
|
||||||
std::vector<boost::optional<ZCIncrementalWitness>> vInputWitnesses;
|
std::vector<boost::optional<ZCIncrementalWitness>> vInputWitnesses;
|
||||||
@ -490,7 +490,7 @@ bool AsyncRPCOperation_mergetoaddress::main_impl()
|
|||||||
while (numInputsNeeded++ < ZC_NUM_JS_INPUTS && zInputsDeque.size() > 0) {
|
while (numInputsNeeded++ < ZC_NUM_JS_INPUTS && zInputsDeque.size() > 0) {
|
||||||
MergeToAddressInputNote t = zInputsDeque.front();
|
MergeToAddressInputNote t = zInputsDeque.front();
|
||||||
JSOutPoint jso = std::get<0>(t);
|
JSOutPoint jso = std::get<0>(t);
|
||||||
Note note = std::get<1>(t);
|
SproutNote note = std::get<1>(t);
|
||||||
CAmount noteFunds = std::get<2>(t);
|
CAmount noteFunds = std::get<2>(t);
|
||||||
SpendingKey zkey = std::get<3>(t);
|
SpendingKey zkey = std::get<3>(t);
|
||||||
zInputsDeque.pop_front();
|
zInputsDeque.pop_front();
|
||||||
|
@ -28,7 +28,7 @@ using namespace libzcash;
|
|||||||
typedef std::tuple<COutPoint, CAmount> MergeToAddressInputUTXO;
|
typedef std::tuple<COutPoint, CAmount> MergeToAddressInputUTXO;
|
||||||
|
|
||||||
// Input JSOP is a tuple of JSOutpoint, note, amount, spending key
|
// 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)
|
// A recipient is a tuple of address, memo (optional if zaddr)
|
||||||
typedef std::tuple<std::string, std::string> MergeToAddressRecipient;
|
typedef std::tuple<std::string, std::string> MergeToAddressRecipient;
|
||||||
@ -37,7 +37,7 @@ typedef std::tuple<std::string, std::string> MergeToAddressRecipient;
|
|||||||
struct MergeToAddressJSInfo {
|
struct MergeToAddressJSInfo {
|
||||||
std::vector<JSInput> vjsin;
|
std::vector<JSInput> vjsin;
|
||||||
std::vector<JSOutput> vjsout;
|
std::vector<JSOutput> vjsout;
|
||||||
std::vector<Note> notes;
|
std::vector<SproutNote> notes;
|
||||||
std::vector<SpendingKey> zkeys;
|
std::vector<SpendingKey> zkeys;
|
||||||
CAmount vpub_old = 0;
|
CAmount vpub_old = 0;
|
||||||
CAmount vpub_new = 0;
|
CAmount vpub_new = 0;
|
||||||
|
@ -578,7 +578,7 @@ bool AsyncRPCOperation_sendmany::main_impl() {
|
|||||||
hSig,
|
hSig,
|
||||||
(unsigned char) changeOutputIndex);
|
(unsigned char) changeOutputIndex);
|
||||||
|
|
||||||
Note note = plaintext.note(frompaymentaddress_);
|
SproutNote note = plaintext.note(frompaymentaddress_);
|
||||||
info.notes.push_back(note);
|
info.notes.push_back(note);
|
||||||
|
|
||||||
jsInputValue += plaintext.value;
|
jsInputValue += plaintext.value;
|
||||||
@ -597,7 +597,7 @@ bool AsyncRPCOperation_sendmany::main_impl() {
|
|||||||
//
|
//
|
||||||
// Consume spendable non-change notes
|
// Consume spendable non-change notes
|
||||||
//
|
//
|
||||||
std::vector<Note> vInputNotes;
|
std::vector<SproutNote> vInputNotes;
|
||||||
std::vector<JSOutPoint> vOutPoints;
|
std::vector<JSOutPoint> vOutPoints;
|
||||||
std::vector<boost::optional<ZCIncrementalWitness>> vInputWitnesses;
|
std::vector<boost::optional<ZCIncrementalWitness>> vInputWitnesses;
|
||||||
uint256 inputAnchor;
|
uint256 inputAnchor;
|
||||||
@ -605,7 +605,7 @@ bool AsyncRPCOperation_sendmany::main_impl() {
|
|||||||
while (numInputsNeeded++ < ZC_NUM_JS_INPUTS && zInputsDeque.size() > 0) {
|
while (numInputsNeeded++ < ZC_NUM_JS_INPUTS && zInputsDeque.size() > 0) {
|
||||||
SendManyInputJSOP t = zInputsDeque.front();
|
SendManyInputJSOP t = zInputsDeque.front();
|
||||||
JSOutPoint jso = std::get<0>(t);
|
JSOutPoint jso = std::get<0>(t);
|
||||||
Note note = std::get<1>(t);
|
SproutNote note = std::get<1>(t);
|
||||||
CAmount noteFunds = std::get<2>(t);
|
CAmount noteFunds = std::get<2>(t);
|
||||||
zInputsDeque.pop_front();
|
zInputsDeque.pop_front();
|
||||||
|
|
||||||
|
@ -31,14 +31,14 @@ typedef std::tuple<std::string, CAmount, std::string> SendManyRecipient;
|
|||||||
typedef std::tuple<uint256, int, CAmount, bool> SendManyInputUTXO;
|
typedef std::tuple<uint256, int, CAmount, bool> SendManyInputUTXO;
|
||||||
|
|
||||||
// Input JSOP is a tuple of JSOutpoint, note and amount
|
// 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.
|
// Package of info which is passed to perform_joinsplit methods.
|
||||||
struct AsyncJoinSplitInfo
|
struct AsyncJoinSplitInfo
|
||||||
{
|
{
|
||||||
std::vector<JSInput> vjsin;
|
std::vector<JSInput> vjsin;
|
||||||
std::vector<JSOutput> vjsout;
|
std::vector<JSOutput> vjsout;
|
||||||
std::vector<Note> notes;
|
std::vector<SproutNote> notes;
|
||||||
CAmount vpub_old = 0;
|
CAmount vpub_old = 0;
|
||||||
CAmount vpub_new = 0;
|
CAmount vpub_new = 0;
|
||||||
};
|
};
|
||||||
|
@ -72,13 +72,13 @@ CWalletTx GetValidReceive(const libzcash::SpendingKey& sk, CAmount value, bool r
|
|||||||
return GetValidReceive(*params, sk, value, randomInputs);
|
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) {
|
const CTransaction& tx, size_t js, size_t n) {
|
||||||
return GetNote(*params, sk, tx, js, n);
|
return GetNote(*params, sk, tx, js, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
CWalletTx GetValidSpend(const libzcash::SpendingKey& sk,
|
CWalletTx GetValidSpend(const libzcash::SpendingKey& sk,
|
||||||
const libzcash::Note& note, CAmount value) {
|
const libzcash::SproutNote& note, CAmount value) {
|
||||||
return GetValidSpend(*params, sk, note, value);
|
return GetValidSpend(*params, sk, note, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -283,7 +283,7 @@ UniValue z_validatepaymentdisclosure(const UniValue& params, bool fHelp)
|
|||||||
|
|
||||||
// Check the blockchain commitment matches decrypted note commitment
|
// Check the blockchain commitment matches decrypted note commitment
|
||||||
uint256 cm_blockchain = jsdesc.commitments[pd.payload.n];
|
uint256 cm_blockchain = jsdesc.commitments[pd.payload.n];
|
||||||
Note note = npt.note(zaddr);
|
SproutNote note = npt.note(zaddr);
|
||||||
uint256 cm_decrypted = note.cm();
|
uint256 cm_decrypted = note.cm();
|
||||||
bool cm_match = (cm_decrypted == cm_blockchain);
|
bool cm_match = (cm_decrypted == cm_blockchain);
|
||||||
o.push_back(Pair("commitmentMatch", cm_match));
|
o.push_back(Pair("commitmentMatch", cm_match));
|
||||||
|
@ -2817,7 +2817,7 @@ UniValue zc_raw_receive(const UniValue& params, bool fHelp)
|
|||||||
nonce
|
nonce
|
||||||
);
|
);
|
||||||
PaymentAddress payment_addr = k.address();
|
PaymentAddress payment_addr = k.address();
|
||||||
Note decrypted_note = npt.note(payment_addr);
|
SproutNote decrypted_note = npt.note(payment_addr);
|
||||||
|
|
||||||
assert(pwalletMain != NULL);
|
assert(pwalletMain != NULL);
|
||||||
std::vector<boost::optional<ZCIncrementalWitness>> witnesses;
|
std::vector<boost::optional<ZCIncrementalWitness>> witnesses;
|
||||||
@ -2891,7 +2891,7 @@ UniValue zc_raw_joinsplit(const UniValue& params, bool fHelp)
|
|||||||
|
|
||||||
std::vector<JSInput> vjsin;
|
std::vector<JSInput> vjsin;
|
||||||
std::vector<JSOutput> vjsout;
|
std::vector<JSOutput> vjsout;
|
||||||
std::vector<Note> notes;
|
std::vector<SproutNote> notes;
|
||||||
std::vector<SpendingKey> keys;
|
std::vector<SpendingKey> keys;
|
||||||
std::vector<uint256> commitments;
|
std::vector<uint256> commitments;
|
||||||
|
|
||||||
@ -2909,7 +2909,7 @@ UniValue zc_raw_joinsplit(const UniValue& params, bool fHelp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
PaymentAddress addr = k.address();
|
PaymentAddress addr = k.address();
|
||||||
Note note = npt.note(addr);
|
SproutNote note = npt.note(addr);
|
||||||
notes.push_back(note);
|
notes.push_back(note);
|
||||||
commitments.push_back(note.cm());
|
commitments.push_back(note.cm());
|
||||||
}
|
}
|
||||||
|
@ -139,7 +139,7 @@ public:
|
|||||||
ZCProof prove(
|
ZCProof prove(
|
||||||
const boost::array<JSInput, NumInputs>& inputs,
|
const boost::array<JSInput, NumInputs>& inputs,
|
||||||
const boost::array<JSOutput, NumOutputs>& outputs,
|
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,
|
boost::array<ZCNoteEncryption::Ciphertext, NumOutputs>& out_ciphertexts,
|
||||||
uint256& out_ephemeralKey,
|
uint256& out_ephemeralKey,
|
||||||
const uint256& pubKeyHash,
|
const uint256& pubKeyHash,
|
||||||
@ -364,10 +364,10 @@ uint256 JoinSplit<NumInputs, NumOutputs>::h_sig(
|
|||||||
return output;
|
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);
|
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) {
|
JSOutput::JSOutput() : addr(uint256(), uint256()), value(0) {
|
||||||
@ -377,7 +377,7 @@ JSOutput::JSOutput() : addr(uint256(), uint256()), value(0) {
|
|||||||
|
|
||||||
JSInput::JSInput() : witness(ZCIncrementalMerkleTree().witness()),
|
JSInput::JSInput() : witness(ZCIncrementalMerkleTree().witness()),
|
||||||
key(SpendingKey::random()) {
|
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;
|
ZCIncrementalMerkleTree dummy_tree;
|
||||||
dummy_tree.append(note.cm());
|
dummy_tree.append(note.cm());
|
||||||
witness = dummy_tree.witness();
|
witness = dummy_tree.witness();
|
||||||
|
@ -18,12 +18,12 @@ namespace libzcash {
|
|||||||
class JSInput {
|
class JSInput {
|
||||||
public:
|
public:
|
||||||
ZCIncrementalWitness witness;
|
ZCIncrementalWitness witness;
|
||||||
Note note;
|
SproutNote note;
|
||||||
SpendingKey key;
|
SpendingKey key;
|
||||||
|
|
||||||
JSInput();
|
JSInput();
|
||||||
JSInput(ZCIncrementalWitness witness,
|
JSInput(ZCIncrementalWitness witness,
|
||||||
Note note,
|
SproutNote note,
|
||||||
SpendingKey key) : witness(witness), note(note), key(key) { }
|
SpendingKey key) : witness(witness), note(note), key(key) { }
|
||||||
|
|
||||||
uint256 nullifier() const {
|
uint256 nullifier() const {
|
||||||
@ -40,7 +40,7 @@ public:
|
|||||||
JSOutput();
|
JSOutput();
|
||||||
JSOutput(PaymentAddress addr, uint64_t value) : addr(addr), value(value) { }
|
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>
|
template<size_t NumInputs, size_t NumOutputs>
|
||||||
@ -62,7 +62,7 @@ public:
|
|||||||
virtual ZCProof prove(
|
virtual ZCProof prove(
|
||||||
const boost::array<JSInput, NumInputs>& inputs,
|
const boost::array<JSInput, NumInputs>& inputs,
|
||||||
const boost::array<JSOutput, NumOutputs>& outputs,
|
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,
|
boost::array<ZCNoteEncryption::Ciphertext, NumOutputs>& out_ciphertexts,
|
||||||
uint256& out_ephemeralKey,
|
uint256& out_ephemeralKey,
|
||||||
const uint256& pubKeyHash,
|
const uint256& pubKeyHash,
|
||||||
|
@ -9,14 +9,14 @@
|
|||||||
|
|
||||||
namespace libzcash {
|
namespace libzcash {
|
||||||
|
|
||||||
Note::Note() {
|
SproutNote::SproutNote() {
|
||||||
a_pk = random_uint256();
|
a_pk = random_uint256();
|
||||||
rho = random_uint256();
|
rho = random_uint256();
|
||||||
r = random_uint256();
|
r = random_uint256();
|
||||||
value = 0;
|
value = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint256 Note::cm() const {
|
uint256 SproutNote::cm() const {
|
||||||
unsigned char discriminant = 0xb0;
|
unsigned char discriminant = 0xb0;
|
||||||
|
|
||||||
CSHA256 hasher;
|
CSHA256 hasher;
|
||||||
@ -35,12 +35,12 @@ uint256 Note::cm() const {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint256 Note::nullifier(const SpendingKey& a_sk) const {
|
uint256 SproutNote::nullifier(const SpendingKey& a_sk) const {
|
||||||
return PRF_nf(a_sk, rho);
|
return PRF_nf(a_sk, rho);
|
||||||
}
|
}
|
||||||
|
|
||||||
NotePlaintext::NotePlaintext(
|
NotePlaintext::NotePlaintext(
|
||||||
const Note& note,
|
const SproutNote& note,
|
||||||
boost::array<unsigned char, ZC_MEMO_SIZE> memo) : memo(memo)
|
boost::array<unsigned char, ZC_MEMO_SIZE> memo) : memo(memo)
|
||||||
{
|
{
|
||||||
value = note.value;
|
value = note.value;
|
||||||
@ -48,9 +48,9 @@ NotePlaintext::NotePlaintext(
|
|||||||
r = note.r;
|
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,
|
NotePlaintext NotePlaintext::decrypt(const ZCNoteDecryption& decryptor,
|
||||||
|
@ -13,17 +13,17 @@ public:
|
|||||||
virtual uint256 cm() const {};
|
virtual uint256 cm() const {};
|
||||||
};
|
};
|
||||||
|
|
||||||
class Note : public BaseNote {
|
class SproutNote : public BaseNote {
|
||||||
public:
|
public:
|
||||||
uint256 a_pk;
|
uint256 a_pk;
|
||||||
uint64_t value;
|
uint64_t value;
|
||||||
uint256 rho;
|
uint256 rho;
|
||||||
uint256 r;
|
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) {}
|
: a_pk(a_pk), value(value), rho(rho), r(r) {}
|
||||||
|
|
||||||
Note();
|
SproutNote();
|
||||||
|
|
||||||
virtual uint256 cm() const override;
|
virtual uint256 cm() const override;
|
||||||
|
|
||||||
@ -39,9 +39,9 @@ public:
|
|||||||
|
|
||||||
NotePlaintext() {}
|
NotePlaintext() {}
|
||||||
|
|
||||||
NotePlaintext(const Note& note, boost::array<unsigned char, ZC_MEMO_SIZE> memo);
|
NotePlaintext(const SproutNote& note, boost::array<unsigned char, ZC_MEMO_SIZE> memo);
|
||||||
|
|
||||||
Note note(const PaymentAddress& addr) const;
|
SproutNote note(const PaymentAddress& addr) const;
|
||||||
|
|
||||||
ADD_SERIALIZE_METHODS;
|
ADD_SERIALIZE_METHODS;
|
||||||
|
|
||||||
|
@ -191,7 +191,7 @@ public:
|
|||||||
const uint256& rt,
|
const uint256& rt,
|
||||||
const uint256& h_sig,
|
const uint256& h_sig,
|
||||||
const boost::array<JSInput, NumInputs>& inputs,
|
const boost::array<JSInput, NumInputs>& inputs,
|
||||||
const boost::array<Note, NumOutputs>& outputs,
|
const boost::array<SproutNote, NumOutputs>& outputs,
|
||||||
uint64_t vpub_old,
|
uint64_t vpub_old,
|
||||||
uint64_t vpub_new
|
uint64_t vpub_new
|
||||||
) {
|
) {
|
||||||
|
@ -21,7 +21,7 @@ public:
|
|||||||
r->generate_r1cs_constraints();
|
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));
|
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));
|
value.fill_with_bits(this->pb, uint64_to_bool_vector(note.value));
|
||||||
}
|
}
|
||||||
@ -119,7 +119,7 @@ public:
|
|||||||
void generate_r1cs_witness(
|
void generate_r1cs_witness(
|
||||||
const MerklePath& path,
|
const MerklePath& path,
|
||||||
const SpendingKey& key,
|
const SpendingKey& key,
|
||||||
const Note& note
|
const SproutNote& note
|
||||||
) {
|
) {
|
||||||
note_gadget<FieldT>::generate_r1cs_witness(note);
|
note_gadget<FieldT>::generate_r1cs_witness(note);
|
||||||
|
|
||||||
@ -222,7 +222,7 @@ public:
|
|||||||
commit_to_outputs->generate_r1cs_constraints();
|
commit_to_outputs->generate_r1cs_constraints();
|
||||||
}
|
}
|
||||||
|
|
||||||
void generate_r1cs_witness(const Note& note) {
|
void generate_r1cs_witness(const SproutNote& note) {
|
||||||
note_gadget<FieldT>::generate_r1cs_witness(note);
|
note_gadget<FieldT>::generate_r1cs_witness(note);
|
||||||
|
|
||||||
prevent_faerie_gold->generate_r1cs_witness();
|
prevent_faerie_gold->generate_r1cs_witness();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user