Add optional bool to disable computation of proof in JSDescription constructor
This commit is contained in:
@@ -15,11 +15,14 @@ JSDescription::JSDescription(ZCJoinSplit& params,
|
|||||||
const boost::array<libzcash::JSInput, ZC_NUM_JS_INPUTS>& inputs,
|
const boost::array<libzcash::JSInput, ZC_NUM_JS_INPUTS>& inputs,
|
||||||
const boost::array<libzcash::JSOutput, ZC_NUM_JS_OUTPUTS>& outputs,
|
const boost::array<libzcash::JSOutput, ZC_NUM_JS_OUTPUTS>& outputs,
|
||||||
CAmount vpub_old,
|
CAmount vpub_old,
|
||||||
CAmount vpub_new) : vpub_old(vpub_old), vpub_new(vpub_new), anchor(anchor)
|
CAmount vpub_new,
|
||||||
|
bool computeProof) : vpub_old(vpub_old), vpub_new(vpub_new), anchor(anchor)
|
||||||
{
|
{
|
||||||
boost::array<libzcash::Note, ZC_NUM_JS_OUTPUTS> notes;
|
boost::array<libzcash::Note, ZC_NUM_JS_OUTPUTS> notes;
|
||||||
|
|
||||||
params.loadProvingKey();
|
if (computeProof) {
|
||||||
|
params.loadProvingKey();
|
||||||
|
}
|
||||||
proof = params.prove(
|
proof = params.prove(
|
||||||
inputs,
|
inputs,
|
||||||
outputs,
|
outputs,
|
||||||
@@ -33,7 +36,8 @@ JSDescription::JSDescription(ZCJoinSplit& params,
|
|||||||
commitments,
|
commitments,
|
||||||
vpub_old,
|
vpub_old,
|
||||||
vpub_new,
|
vpub_new,
|
||||||
anchor
|
anchor,
|
||||||
|
computeProof
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -74,7 +74,8 @@ public:
|
|||||||
const boost::array<libzcash::JSInput, ZC_NUM_JS_INPUTS>& inputs,
|
const boost::array<libzcash::JSInput, ZC_NUM_JS_INPUTS>& inputs,
|
||||||
const boost::array<libzcash::JSOutput, ZC_NUM_JS_OUTPUTS>& outputs,
|
const boost::array<libzcash::JSOutput, ZC_NUM_JS_OUTPUTS>& outputs,
|
||||||
CAmount vpub_old,
|
CAmount vpub_old,
|
||||||
CAmount vpub_new
|
CAmount vpub_new,
|
||||||
|
bool computeProof = true // Set to false in some tests
|
||||||
);
|
);
|
||||||
|
|
||||||
// Verifies that the JoinSplit proof is correct.
|
// Verifies that the JoinSplit proof is correct.
|
||||||
|
|||||||
@@ -173,9 +173,10 @@ public:
|
|||||||
boost::array<uint256, NumOutputs>& out_commitments,
|
boost::array<uint256, NumOutputs>& out_commitments,
|
||||||
uint64_t vpub_old,
|
uint64_t vpub_old,
|
||||||
uint64_t vpub_new,
|
uint64_t vpub_new,
|
||||||
const uint256& rt
|
const uint256& rt,
|
||||||
|
bool computeProof
|
||||||
) {
|
) {
|
||||||
if (!pk) {
|
if (computeProof && !pk) {
|
||||||
throw std::runtime_error("JoinSplit proving key not loaded");
|
throw std::runtime_error("JoinSplit proving key not loaded");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,6 +232,10 @@ public:
|
|||||||
out_macs[i] = PRF_pk(inputs[i].key, i, h_sig);
|
out_macs[i] = PRF_pk(inputs[i].key, i, h_sig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!computeProof) {
|
||||||
|
return ZCProof();
|
||||||
|
}
|
||||||
|
|
||||||
protoboard<FieldT> pb;
|
protoboard<FieldT> pb;
|
||||||
{
|
{
|
||||||
joinsplit_gadget<FieldT, NumInputs, NumOutputs> g(pb);
|
joinsplit_gadget<FieldT, NumInputs, NumOutputs> g(pb);
|
||||||
|
|||||||
@@ -73,7 +73,8 @@ public:
|
|||||||
boost::array<uint256, NumOutputs>& out_commitments,
|
boost::array<uint256, NumOutputs>& out_commitments,
|
||||||
uint64_t vpub_old,
|
uint64_t vpub_old,
|
||||||
uint64_t vpub_new,
|
uint64_t vpub_new,
|
||||||
const uint256& rt
|
const uint256& rt,
|
||||||
|
bool computeProof = true
|
||||||
) = 0;
|
) = 0;
|
||||||
|
|
||||||
virtual bool verify(
|
virtual bool verify(
|
||||||
|
|||||||
Reference in New Issue
Block a user