auto decrypted_note = note_pt.note(recipient_addr);
- ASSERT_TRUE(decrypted_note.value == 10);
+ ASSERT_TRUE(decrypted_note.value() == 10);
// Insert the commitments from the last tx into the tree
tree.append(commitments[0]);
ASSERT_TRUE(decrypted_note.a_pk == note.a_pk);
ASSERT_TRUE(decrypted_note.rho == note.rho);
ASSERT_TRUE(decrypted_note.r == note.r);
- ASSERT_TRUE(decrypted_note.value == note.value);
+ ASSERT_TRUE(decrypted_note.value() == note.value());
ASSERT_TRUE(decrypted.memo == note_pt.memo);
}
libzcash::JSInput dummyin;
{
- if (note.value > value) {
+ if (note.value() > value) {
libzcash::SpendingKey dummykey = libzcash::SpendingKey::random();
libzcash::PaymentAddress dummyaddr = dummykey.address();
- dummyout = libzcash::JSOutput(dummyaddr, note.value - value);
- } else if (note.value < value) {
+ dummyout = libzcash::JSOutput(dummyaddr, note.value() - value);
+ } else if (note.value() < value) {
libzcash::SpendingKey dummykey = libzcash::SpendingKey::random();
libzcash::PaymentAddress dummyaddr = dummykey.address();
- libzcash::SproutNote 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);
}
getId(),
tx_.vjoinsplit.size(),
FormatMoney(info.vpub_old), FormatMoney(info.vpub_new),
- FormatMoney(info.vjsin[0].note.value), FormatMoney(info.vjsin[1].note.value),
+ FormatMoney(info.vjsin[0].note.value()), FormatMoney(info.vjsin[1].note.value()),
FormatMoney(info.vjsout[0].value), FormatMoney(info.vjsout[1].value));
// Generate the proof, this can take over a minute.
getId(),
tx_.vjoinsplit.size(),
FormatMoney(info.vpub_old), FormatMoney(info.vpub_new),
- FormatMoney(info.vjsin[0].note.value), FormatMoney(info.vjsin[1].note.value),
+ FormatMoney(info.vjsin[0].note.value()), FormatMoney(info.vjsin[1].note.value()),
FormatMoney(info.vjsout[0].value), FormatMoney(info.vjsout[1].value)
);
getId(),
tx_.vjoinsplit.size(),
FormatMoney(info.vpub_old), FormatMoney(info.vpub_new),
- FormatMoney(info.vjsin[0].note.value), FormatMoney(info.vjsin[1].note.value),
+ FormatMoney(info.vjsin[0].note.value()), FormatMoney(info.vjsin[1].note.value()),
FormatMoney(info.vjsout[0].value), FormatMoney(info.vjsout[1].value)
);
ss << npt;
UniValue result(UniValue::VOBJ);
- result.push_back(Pair("amount", ValueFromAmount(decrypted_note.value)));
+ result.push_back(Pair("amount", ValueFromAmount(decrypted_note.value())));
result.push_back(Pair("note", HexStr(ss.begin(), ss.end())));
result.push_back(Pair("exists", (bool) witnesses[0]));
return result;
// Sanity checks of input
{
// If note has nonzero value
- if (inputs[i].note.value != 0) {
+ if (inputs[i].note.value() != 0) {
// The witness root must equal the input root.
if (inputs[i].witness.root() != rt) {
throw std::invalid_argument("joinsplit not anchored to the correct root");
}
// Balance must be sensical
- if (inputs[i].note.value > MAX_MONEY) {
+ if (inputs[i].note.value() > MAX_MONEY) {
throw std::invalid_argument("nonsensical input note value");
}
- lhs_value += inputs[i].note.value;
+ lhs_value += inputs[i].note.value();
if (lhs_value > MAX_MONEY) {
throw std::invalid_argument("nonsensical left hand size of joinsplit balance");
a_pk = random_uint256();
rho = random_uint256();
r = random_uint256();
- value = 0;
}
uint256 SproutNote::cm() const {
hasher.Write(&discriminant, 1);
hasher.Write(a_pk.begin(), 32);
- auto value_vec = convertIntToVectorLE(value);
+ auto value_vec = convertIntToVectorLE(value_);
hasher.Write(&value_vec[0], value_vec.size());
hasher.Write(rho.begin(), 32);
const SproutNote& note,
boost::array<unsigned char, ZC_MEMO_SIZE> memo) : memo(memo)
{
- value = note.value;
+ value = note.value();
rho = note.rho;
r = note.r;
}
namespace libzcash {
class BaseNote {
+protected:
+ uint64_t value_ = 0;
public:
+ BaseNote() {}
+ BaseNote(uint64_t value) : value_(value) {};
virtual uint256 cm() const {};
+ inline uint64_t value() const { return value_; };
};
class SproutNote : public BaseNote {
public:
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) {}
+ : BaseNote(value), a_pk(a_pk), rho(rho), r(r) {}
SproutNote();
// Witness total_uint64 bits
uint64_t left_side_acc = vpub_old;
for (size_t i = 0; i < NumInputs; i++) {
- left_side_acc += inputs[i].note.value;
+ left_side_acc += inputs[i].note.value();
}
zk_total_uint64.fill_with_bits(
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));
+ value.fill_with_bits(this->pb, uint64_to_bool_vector(note.value()));
}
};
);
// Set enforce flag for nonzero input value
- this->pb.val(value_enforce) = (note.value != 0) ? FieldT::one() : FieldT::zero();
+ this->pb.val(value_enforce) = (note.value() != 0) ? FieldT::one() : FieldT::zero();
// Witness merkle tree authentication path
witness_input->generate_r1cs_witness(path);