Bucket -> note.

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
Daira Hopwood
2016-07-14 23:22:27 +01:00
committed by Sean Bowe
parent cc01120a17
commit 4bc00dc141
5 changed files with 34 additions and 34 deletions

View File

@@ -2158,10 +2158,10 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
UpdateCoins(tx, state, view, i == 0 ? undoDummy : blockundo.vtxundo.back(), pindex->nHeight); UpdateCoins(tx, state, view, i == 0 ? undoDummy : blockundo.vtxundo.back(), pindex->nHeight);
BOOST_FOREACH(const JSDescription &joinsplit, tx.vjoinsplit) { BOOST_FOREACH(const JSDescription &joinsplit, tx.vjoinsplit) {
BOOST_FOREACH(const uint256 &bucket_commitment, joinsplit.commitments) { BOOST_FOREACH(const uint256 &note_commitment, joinsplit.commitments) {
// Insert the bucket commitments into our temporary tree. // Insert the note commitments into our temporary tree.
tree.append(bucket_commitment); tree.append(note_commitment);
} }
} }

View File

@@ -25,22 +25,22 @@ public:
CAmount vpub_old; CAmount vpub_old;
CAmount vpub_new; CAmount vpub_new;
// JoinSplits are always anchored to a root in the bucket // JoinSplits are always anchored to a root in the note
// commitment tree at some point in the blockchain // commitment tree at some point in the blockchain
// history or in the history of the current // history or in the history of the current
// transaction. // transaction.
uint256 anchor; uint256 anchor;
// Nullifiers are used to prevent double-spends. They // Nullifiers are used to prevent double-spends. They
// are derived from the secrets placed in the bucket // are derived from the secrets placed in the note
// and the secret spend-authority key known by the // and the secret spend-authority key known by the
// spender. // spender.
boost::array<uint256, ZC_NUM_JS_INPUTS> nullifiers; boost::array<uint256, ZC_NUM_JS_INPUTS> nullifiers;
// Bucket commitments are introduced into the commitment // Note commitments are introduced into the commitment
// tree, blinding the public about the values and // tree, blinding the public about the values and
// destinations involved in the JoinSplit. The presence of a // destinations involved in the JoinSplit. The presence of
// commitment in the bucket commitment tree is required // a commitment in the note commitment tree is required
// to spend it. // to spend it.
boost::array<uint256, ZC_NUM_JS_OUTPUTS> commitments; boost::array<uint256, ZC_NUM_JS_OUTPUTS> commitments;

View File

@@ -2448,14 +2448,14 @@ Value zc_raw_receive(const json_spirit::Array& params, bool fHelp)
if (fHelp || params.size() != 2) { if (fHelp || params.size() != 2) {
throw runtime_error( throw runtime_error(
"zcrawreceive zcsecretkey encryptedbucket\n" "zcrawreceive zcsecretkey encryptednote\n"
"\n" "\n"
"Decrypts encryptedbucket and checks if the coin commitments\n" "Decrypts encryptednote and checks if the coin commitments\n"
"are in the blockchain as indicated by the \"exists\" result.\n" "are in the blockchain as indicated by the \"exists\" result.\n"
"\n" "\n"
"Output: {\n" "Output: {\n"
" \"amount\": value,\n" " \"amount\": value,\n"
" \"bucket\": cleartextbucket,\n" " \"note\": noteplaintext,\n"
" \"exists\": exists\n" " \"exists\": exists\n"
"}\n" "}\n"
); );
@@ -2474,7 +2474,7 @@ Value zc_raw_receive(const json_spirit::Array& params, bool fHelp)
uint256 h_sig; uint256 h_sig;
{ {
CDataStream ssData(ParseHexV(params[1], "encrypted_bucket"), SER_NETWORK, PROTOCOL_VERSION); CDataStream ssData(ParseHexV(params[1], "encrypted_note"), SER_NETWORK, PROTOCOL_VERSION);
try { try {
ssData >> nonce; ssData >> nonce;
ssData >> epk; ssData >> epk;
@@ -2482,7 +2482,7 @@ Value zc_raw_receive(const json_spirit::Array& params, bool fHelp)
ssData >> h_sig; ssData >> h_sig;
} catch(const std::exception &) { } catch(const std::exception &) {
throw runtime_error( throw runtime_error(
"encrypted_bucket could not be decoded" "encrypted_note could not be decoded"
); );
} }
} }
@@ -2503,7 +2503,7 @@ Value zc_raw_receive(const json_spirit::Array& params, bool fHelp)
std::vector<boost::optional<ZCIncrementalWitness>> witnesses; std::vector<boost::optional<ZCIncrementalWitness>> witnesses;
uint256 anchor; uint256 anchor;
uint256 commitment = decrypted_note.cm(); uint256 commitment = decrypted_note.cm();
pwalletMain->WitnessBucketCommitment( pwalletMain->WitnessNoteCommitment(
{commitment}, {commitment},
witnesses, witnesses,
anchor anchor
@@ -2514,7 +2514,7 @@ Value zc_raw_receive(const json_spirit::Array& params, bool fHelp)
Object result; Object result;
result.push_back(Pair("amount", ValueFromAmount(decrypted_note.value))); result.push_back(Pair("amount", ValueFromAmount(decrypted_note.value)));
result.push_back(Pair("bucket", HexStr(ss.begin(), ss.end()))); result.push_back(Pair("note", HexStr(ss.begin(), ss.end())));
result.push_back(Pair("exists", (bool) witnesses[0])); result.push_back(Pair("exists", (bool) witnesses[0]));
return result; return result;
} }
@@ -2530,7 +2530,7 @@ Value zc_raw_joinsplit(const json_spirit::Array& params, bool fHelp)
if (fHelp || params.size() != 5) { if (fHelp || params.size() != 5) {
throw runtime_error( throw runtime_error(
"zcrawjoinsplit rawtx inputs outputs vpub_old vpub_new\n" "zcrawjoinsplit rawtx inputs outputs vpub_old vpub_new\n"
" inputs: a JSON object mapping {bucket: zcsecretkey, ...}\n" " inputs: a JSON object mapping {note: zcsecretkey, ...}\n"
" outputs: a JSON object mapping {zcaddr: value, ...}\n" " outputs: a JSON object mapping {zcaddr: value, ...}\n"
"\n" "\n"
"Splices a joinsplit into rawtx. Inputs are unilaterally confidential.\n" "Splices a joinsplit into rawtx. Inputs are unilaterally confidential.\n"
@@ -2544,8 +2544,8 @@ Value zc_raw_joinsplit(const json_spirit::Array& params, bool fHelp)
"payments in-band on the blockchain.)\n" "payments in-band on the blockchain.)\n"
"\n" "\n"
"Output: {\n" "Output: {\n"
" \"encryptedbucket1\": enc1,\n" " \"encryptednote1\": enc1,\n"
" \"encryptedbucket2\": enc2,\n" " \"encryptednote2\": enc2,\n"
" \"rawtxn\": rawtxout\n" " \"rawtxn\": rawtxout\n"
"}\n" "}\n"
); );
@@ -2585,7 +2585,7 @@ Value zc_raw_joinsplit(const json_spirit::Array& params, bool fHelp)
NotePlaintext npt; NotePlaintext npt;
{ {
CDataStream ssData(ParseHexV(s.name_, "bucket"), SER_NETWORK, PROTOCOL_VERSION); CDataStream ssData(ParseHexV(s.name_, "note"), SER_NETWORK, PROTOCOL_VERSION);
ssData >> npt; ssData >> npt;
} }
@@ -2597,7 +2597,7 @@ Value zc_raw_joinsplit(const json_spirit::Array& params, bool fHelp)
uint256 anchor; uint256 anchor;
std::vector<boost::optional<ZCIncrementalWitness>> witnesses; std::vector<boost::optional<ZCIncrementalWitness>> witnesses;
pwalletMain->WitnessBucketCommitment(commitments, witnesses, anchor); pwalletMain->WitnessNoteCommitment(commitments, witnesses, anchor);
assert(witnesses.size() == notes.size()); assert(witnesses.size() == notes.size());
assert(notes.size() == keys.size()); assert(notes.size() == keys.size());
@@ -2683,8 +2683,8 @@ Value zc_raw_joinsplit(const json_spirit::Array& params, bool fHelp)
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
ss << rawTx; ss << rawTx;
std::string encryptedBucket1; std::string encryptedNote1;
std::string encryptedBucket2; std::string encryptedNote2;
{ {
CDataStream ss2(SER_NETWORK, PROTOCOL_VERSION); CDataStream ss2(SER_NETWORK, PROTOCOL_VERSION);
ss2 << ((unsigned char) 0x00); ss2 << ((unsigned char) 0x00);
@@ -2692,7 +2692,7 @@ Value zc_raw_joinsplit(const json_spirit::Array& params, bool fHelp)
ss2 << jsdescription.ciphertexts[0]; ss2 << jsdescription.ciphertexts[0];
ss2 << jsdescription.h_sig(*pzcashParams, joinSplitPubKey); ss2 << jsdescription.h_sig(*pzcashParams, joinSplitPubKey);
encryptedBucket1 = HexStr(ss2.begin(), ss2.end()); encryptedNote1 = HexStr(ss2.begin(), ss2.end());
} }
{ {
CDataStream ss2(SER_NETWORK, PROTOCOL_VERSION); CDataStream ss2(SER_NETWORK, PROTOCOL_VERSION);
@@ -2701,12 +2701,12 @@ Value zc_raw_joinsplit(const json_spirit::Array& params, bool fHelp)
ss2 << jsdescription.ciphertexts[1]; ss2 << jsdescription.ciphertexts[1];
ss2 << jsdescription.h_sig(*pzcashParams, joinSplitPubKey); ss2 << jsdescription.h_sig(*pzcashParams, joinSplitPubKey);
encryptedBucket2 = HexStr(ss2.begin(), ss2.end()); encryptedNote2 = HexStr(ss2.begin(), ss2.end());
} }
Object result; Object result;
result.push_back(Pair("encryptedbucket1", encryptedBucket1)); result.push_back(Pair("encryptednote1", encryptedNote1));
result.push_back(Pair("encryptedbucket2", encryptedBucket2)); result.push_back(Pair("encryptednote2", encryptedNote2));
result.push_back(Pair("rawtxn", HexStr(ss.begin(), ss.end()))); result.push_back(Pair("rawtxn", HexStr(ss.begin(), ss.end())));
return result; return result;
} }

View File

@@ -1051,9 +1051,9 @@ bool CWalletTx::WriteToDisk(CWalletDB *pwalletdb)
return pwalletdb->WriteTx(GetHash(), *this); return pwalletdb->WriteTx(GetHash(), *this);
} }
void CWallet::WitnessBucketCommitment(std::vector<uint256> commitments, void CWallet::WitnessNoteCommitment(std::vector<uint256> commitments,
std::vector<boost::optional<ZCIncrementalWitness>>& witnesses, std::vector<boost::optional<ZCIncrementalWitness>>& witnesses,
uint256 &final_anchor) uint256 &final_anchor)
{ {
witnesses.resize(commitments.size()); witnesses.resize(commitments.size());
CBlockIndex* pindex = chainActive.Genesis(); CBlockIndex* pindex = chainActive.Genesis();
@@ -1067,19 +1067,19 @@ void CWallet::WitnessBucketCommitment(std::vector<uint256> commitments,
{ {
BOOST_FOREACH(const JSDescription& pour, tx.vjoinsplit) BOOST_FOREACH(const JSDescription& pour, tx.vjoinsplit)
{ {
BOOST_FOREACH(const uint256 &bucket_commitment, pour.commitments) BOOST_FOREACH(const uint256 &note_commitment, pour.commitments)
{ {
tree.append(bucket_commitment); tree.append(note_commitment);
BOOST_FOREACH(boost::optional<ZCIncrementalWitness>& wit, witnesses) { BOOST_FOREACH(boost::optional<ZCIncrementalWitness>& wit, witnesses) {
if (wit) { if (wit) {
wit->append(bucket_commitment); wit->append(note_commitment);
} }
} }
size_t i = 0; size_t i = 0;
BOOST_FOREACH(uint256& commitment, commitments) { BOOST_FOREACH(uint256& commitment, commitments) {
if (bucket_commitment == commitment) { if (note_commitment == commitment) {
witnesses.at(i) = tree.witness(); witnesses.at(i) = tree.witness();
} }
i++; i++;

View File

@@ -616,7 +616,7 @@ public:
void SyncTransaction(const CTransaction& tx, const CBlock* pblock); void SyncTransaction(const CTransaction& tx, const CBlock* pblock);
bool AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate); bool AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate);
void EraseFromWallet(const uint256 &hash); void EraseFromWallet(const uint256 &hash);
void WitnessBucketCommitment( void WitnessNoteCommitment(
std::vector<uint256> commitments, std::vector<uint256> commitments,
std::vector<boost::optional<ZCIncrementalWitness>>& witnesses, std::vector<boost::optional<ZCIncrementalWitness>>& witnesses,
uint256 &final_anchor); uint256 &final_anchor);