JSOutput() // dummy output
};
- boost::array<Note, 2> output_notes;
+ boost::array<SproutNote, 2> output_notes;
// Perform the proof
proof = js->prove(
JSOutput() // dummy output
};
- boost::array<Note, 2> output_notes;
+ boost::array<SproutNote, 2> output_notes;
// Perform the proof
proof = js->prove(
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,
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
ZCNoteEncryption encryptor(h_sig);
uint256 epk = encryptor.get_epk();
- Note note(a_pk,
+ SproutNote note(a_pk,
1945813,
random_uint256(),
random_uint256()
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();
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,
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);
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) {
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");
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();
libzcash::JSOutput(sk.address(), value)
};
- boost::array<libzcash::Note, 2> output_notes;
+ boost::array<libzcash::SproutNote, 2> output_notes;
// Prepare JoinSplits
uint256 rt;
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()};
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;
} 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);
}
libzcash::JSOutput() // dummy output
};
- boost::array<libzcash::Note, 2> output_notes;
+ boost::array<libzcash::SproutNote, 2> output_notes;
// Prepare JoinSplits
uint256 rt = tree.root();
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);
hSig,
(unsigned char)changeOutputIndex);
- Note note = plaintext.note(changeAddress);
+ SproutNote note = plaintext.note(changeAddress);
info.notes.push_back(note);
info.zkeys.push_back(changeKey);
//
// 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;
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();
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;
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;
hSig,
(unsigned char) changeOutputIndex);
- Note note = plaintext.note(frompaymentaddress_);
+ SproutNote note = plaintext.note(frompaymentaddress_);
info.notes.push_back(note);
jsInputValue += plaintext.value;
//
// 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;
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();
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;
};
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);
}
// 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));
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;
std::vector<JSInput> vjsin;
std::vector<JSOutput> vjsout;
- std::vector<Note> notes;
+ std::vector<SproutNote> notes;
std::vector<SpendingKey> keys;
std::vector<uint256> commitments;
}
PaymentAddress addr = k.address();
- Note note = npt.note(addr);
+ SproutNote note = npt.note(addr);
notes.push_back(note);
commitments.push_back(note.cm());
}
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,
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) {
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();
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 {
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>
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,
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;
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<unsigned char, ZC_MEMO_SIZE> memo) : memo(memo)
{
value = note.value;
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,
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;
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;
const uint256& rt,
const uint256& h_sig,
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_new
) {
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));
}
void generate_r1cs_witness(
const MerklePath& path,
const SpendingKey& key,
- const Note& note
+ const SproutNote& note
) {
note_gadget<FieldT>::generate_r1cs_witness(note);
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);
prevent_faerie_gold->generate_r1cs_witness();