Skip to content

Commit

Permalink
Bucket -> note.
Browse files Browse the repository at this point in the history
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
  • Loading branch information
daira authored and ebfull committed Jul 18, 2016
1 parent cc01120 commit 4bc00dc
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 34 deletions.
6 changes: 3 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

BOOST_FOREACH(const JSDescription &joinsplit, tx.vjoinsplit) {
BOOST_FOREACH(const uint256 &bucket_commitment, joinsplit.commitments) {
// Insert the bucket commitments into our temporary tree.
BOOST_FOREACH(const uint256 &note_commitment, joinsplit.commitments) {
// Insert the note commitments into our temporary tree.

tree.append(bucket_commitment);
tree.append(note_commitment);
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/primitives/transaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,22 @@ class JSDescription
CAmount vpub_old;
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
// history or in the history of the current
// transaction.
uint256 anchor;

// 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
// spender.
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
// destinations involved in the JoinSplit. The presence of a
// commitment in the bucket commitment tree is required
// destinations involved in the JoinSplit. The presence of
// a commitment in the note commitment tree is required
// to spend it.
boost::array<uint256, ZC_NUM_JS_OUTPUTS> commitments;

Expand Down
36 changes: 18 additions & 18 deletions src/wallet/rpcwallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2448,14 +2448,14 @@ Value zc_raw_receive(const json_spirit::Array& params, bool fHelp)

if (fHelp || params.size() != 2) {
throw runtime_error(
"zcrawreceive zcsecretkey encryptedbucket\n"
"zcrawreceive zcsecretkey encryptednote\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"
"\n"
"Output: {\n"
" \"amount\": value,\n"
" \"bucket\": cleartextbucket,\n"
" \"note\": noteplaintext,\n"
" \"exists\": exists\n"
"}\n"
);
Expand All @@ -2474,15 +2474,15 @@ Value zc_raw_receive(const json_spirit::Array& params, bool fHelp)
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 {
ssData >> nonce;
ssData >> epk;
ssData >> ct;
ssData >> h_sig;
} catch(const std::exception &) {
throw runtime_error(
"encrypted_bucket could not be decoded"
"encrypted_note could not be decoded"
);
}
}
Expand All @@ -2503,7 +2503,7 @@ Value zc_raw_receive(const json_spirit::Array& params, bool fHelp)
std::vector<boost::optional<ZCIncrementalWitness>> witnesses;
uint256 anchor;
uint256 commitment = decrypted_note.cm();
pwalletMain->WitnessBucketCommitment(
pwalletMain->WitnessNoteCommitment(
{commitment},
witnesses,
anchor
Expand All @@ -2514,7 +2514,7 @@ Value zc_raw_receive(const json_spirit::Array& params, bool fHelp)

Object result;
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]));
return result;
}
Expand All @@ -2530,7 +2530,7 @@ Value zc_raw_joinsplit(const json_spirit::Array& params, bool fHelp)
if (fHelp || params.size() != 5) {
throw runtime_error(
"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"
"\n"
"Splices a joinsplit into rawtx. Inputs are unilaterally confidential.\n"
Expand All @@ -2544,8 +2544,8 @@ Value zc_raw_joinsplit(const json_spirit::Array& params, bool fHelp)
"payments in-band on the blockchain.)\n"
"\n"
"Output: {\n"
" \"encryptedbucket1\": enc1,\n"
" \"encryptedbucket2\": enc2,\n"
" \"encryptednote1\": enc1,\n"
" \"encryptednote2\": enc2,\n"
" \"rawtxn\": rawtxout\n"
"}\n"
);
Expand Down Expand Up @@ -2585,7 +2585,7 @@ Value zc_raw_joinsplit(const json_spirit::Array& params, bool fHelp)
NotePlaintext npt;

{
CDataStream ssData(ParseHexV(s.name_, "bucket"), SER_NETWORK, PROTOCOL_VERSION);
CDataStream ssData(ParseHexV(s.name_, "note"), SER_NETWORK, PROTOCOL_VERSION);
ssData >> npt;
}

Expand All @@ -2597,7 +2597,7 @@ Value zc_raw_joinsplit(const json_spirit::Array& params, bool fHelp)

uint256 anchor;
std::vector<boost::optional<ZCIncrementalWitness>> witnesses;
pwalletMain->WitnessBucketCommitment(commitments, witnesses, anchor);
pwalletMain->WitnessNoteCommitment(commitments, witnesses, anchor);

assert(witnesses.size() == notes.size());
assert(notes.size() == keys.size());
Expand Down Expand Up @@ -2683,16 +2683,16 @@ Value zc_raw_joinsplit(const json_spirit::Array& params, bool fHelp)
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
ss << rawTx;

std::string encryptedBucket1;
std::string encryptedBucket2;
std::string encryptedNote1;
std::string encryptedNote2;
{
CDataStream ss2(SER_NETWORK, PROTOCOL_VERSION);
ss2 << ((unsigned char) 0x00);
ss2 << jsdescription.ephemeralKey;
ss2 << jsdescription.ciphertexts[0];
ss2 << jsdescription.h_sig(*pzcashParams, joinSplitPubKey);

encryptedBucket1 = HexStr(ss2.begin(), ss2.end());
encryptedNote1 = HexStr(ss2.begin(), ss2.end());
}
{
CDataStream ss2(SER_NETWORK, PROTOCOL_VERSION);
Expand All @@ -2701,12 +2701,12 @@ Value zc_raw_joinsplit(const json_spirit::Array& params, bool fHelp)
ss2 << jsdescription.ciphertexts[1];
ss2 << jsdescription.h_sig(*pzcashParams, joinSplitPubKey);

encryptedBucket2 = HexStr(ss2.begin(), ss2.end());
encryptedNote2 = HexStr(ss2.begin(), ss2.end());
}

Object result;
result.push_back(Pair("encryptedbucket1", encryptedBucket1));
result.push_back(Pair("encryptedbucket2", encryptedBucket2));
result.push_back(Pair("encryptednote1", encryptedNote1));
result.push_back(Pair("encryptednote2", encryptedNote2));
result.push_back(Pair("rawtxn", HexStr(ss.begin(), ss.end())));
return result;
}
Expand Down
14 changes: 7 additions & 7 deletions src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1051,9 +1051,9 @@ bool CWalletTx::WriteToDisk(CWalletDB *pwalletdb)
return pwalletdb->WriteTx(GetHash(), *this);
}

void CWallet::WitnessBucketCommitment(std::vector<uint256> commitments,
std::vector<boost::optional<ZCIncrementalWitness>>& witnesses,
uint256 &final_anchor)
void CWallet::WitnessNoteCommitment(std::vector<uint256> commitments,
std::vector<boost::optional<ZCIncrementalWitness>>& witnesses,
uint256 &final_anchor)
{
witnesses.resize(commitments.size());
CBlockIndex* pindex = chainActive.Genesis();
Expand All @@ -1067,19 +1067,19 @@ void CWallet::WitnessBucketCommitment(std::vector<uint256> commitments,
{
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) {
if (wit) {
wit->append(bucket_commitment);
wit->append(note_commitment);
}
}

size_t i = 0;
BOOST_FOREACH(uint256& commitment, commitments) {
if (bucket_commitment == commitment) {
if (note_commitment == commitment) {
witnesses.at(i) = tree.witness();
}
i++;
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface
void SyncTransaction(const CTransaction& tx, const CBlock* pblock);
bool AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate);
void EraseFromWallet(const uint256 &hash);
void WitnessBucketCommitment(
void WitnessNoteCommitment(
std::vector<uint256> commitments,
std::vector<boost::optional<ZCIncrementalWitness>>& witnesses,
uint256 &final_anchor);
Expand Down

0 comments on commit 4bc00dc

Please sign in to comment.