|
|
@ -27,7 +27,6 @@ |
|
|
|
#include "librustzcash.h" |
|
|
|
|
|
|
|
JSDescription::JSDescription( |
|
|
|
bool makeGrothProof, |
|
|
|
ZCJoinSplit& params, |
|
|
|
const uint256& joinSplitPubKey, |
|
|
|
const uint256& anchor, |
|
|
@ -42,7 +41,6 @@ JSDescription::JSDescription( |
|
|
|
std::array<libzcash::SproutNote, ZC_NUM_JS_OUTPUTS> notes; |
|
|
|
|
|
|
|
proof = params.prove( |
|
|
|
makeGrothProof, |
|
|
|
inputs, |
|
|
|
outputs, |
|
|
|
notes, |
|
|
@ -62,7 +60,6 @@ JSDescription::JSDescription( |
|
|
|
} |
|
|
|
|
|
|
|
JSDescription JSDescription::Randomized( |
|
|
|
bool makeGrothProof, |
|
|
|
ZCJoinSplit& params, |
|
|
|
const uint256& joinSplitPubKey, |
|
|
|
const uint256& anchor, |
|
|
@ -87,71 +84,18 @@ JSDescription JSDescription::Randomized( |
|
|
|
MappedShuffle(outputs.begin(), outputMap.begin(), ZC_NUM_JS_OUTPUTS, gen); |
|
|
|
|
|
|
|
return JSDescription( |
|
|
|
makeGrothProof, |
|
|
|
params, joinSplitPubKey, anchor, inputs, outputs, |
|
|
|
vpub_old, vpub_new, computeProof, |
|
|
|
esk // payment disclosure
|
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
class SproutProofVerifier : public boost::static_visitor<bool> |
|
|
|
{ |
|
|
|
ZCJoinSplit& params; |
|
|
|
libzcash::ProofVerifier& verifier; |
|
|
|
const uint256& joinSplitPubKey; |
|
|
|
const JSDescription& jsdesc; |
|
|
|
|
|
|
|
public: |
|
|
|
SproutProofVerifier( |
|
|
|
ZCJoinSplit& params, |
|
|
|
libzcash::ProofVerifier& verifier, |
|
|
|
const uint256& joinSplitPubKey, |
|
|
|
const JSDescription& jsdesc |
|
|
|
) : params(params), jsdesc(jsdesc), verifier(verifier), joinSplitPubKey(joinSplitPubKey) {} |
|
|
|
|
|
|
|
bool operator()(const libzcash::PHGRProof& proof) const |
|
|
|
{ |
|
|
|
return params.verify( |
|
|
|
proof, |
|
|
|
verifier, |
|
|
|
joinSplitPubKey, |
|
|
|
jsdesc.randomSeed, |
|
|
|
jsdesc.macs, |
|
|
|
jsdesc.nullifiers, |
|
|
|
jsdesc.commitments, |
|
|
|
jsdesc.vpub_old, |
|
|
|
jsdesc.vpub_new, |
|
|
|
jsdesc.anchor |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
bool operator()(const libzcash::GrothProof& proof) const |
|
|
|
{ |
|
|
|
uint256 h_sig = params.h_sig(jsdesc.randomSeed, jsdesc.nullifiers, joinSplitPubKey); |
|
|
|
|
|
|
|
return librustzcash_sprout_verify( |
|
|
|
proof.begin(), |
|
|
|
jsdesc.anchor.begin(), |
|
|
|
h_sig.begin(), |
|
|
|
jsdesc.macs[0].begin(), |
|
|
|
jsdesc.macs[1].begin(), |
|
|
|
jsdesc.nullifiers[0].begin(), |
|
|
|
jsdesc.nullifiers[1].begin(), |
|
|
|
jsdesc.commitments[0].begin(), |
|
|
|
jsdesc.commitments[1].begin(), |
|
|
|
jsdesc.vpub_old, |
|
|
|
jsdesc.vpub_new |
|
|
|
); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
bool JSDescription::Verify( |
|
|
|
ZCJoinSplit& params, |
|
|
|
libzcash::ProofVerifier& verifier, |
|
|
|
const uint256& joinSplitPubKey |
|
|
|
) const { |
|
|
|
auto pv = SproutProofVerifier(params, verifier, joinSplitPubKey, *this); |
|
|
|
return boost::apply_visitor(pv, proof); |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
uint256 JSDescription::h_sig(ZCJoinSplit& params, const uint256& joinSplitPubKey) const |
|
|
|