Browse Source

More libsnark removal changes to various internals

dev-aarch64
Duke Leto 4 years ago
parent
commit
89bbd48eae
  1. 58
      src/primitives/transaction.cpp
  2. 7
      src/primitives/transaction.h
  3. 5
      src/utiltest.cpp
  4. 4
      src/wallet/asyncrpcoperation_mergetoaddress.cpp
  5. 1
      src/wallet/asyncrpcoperation_sendmany.cpp
  6. 1
      src/wallet/asyncrpcoperation_shieldcoinbase.cpp
  7. 8
      src/wallet/rpcwallet.cpp

58
src/primitives/transaction.cpp

@ -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

7
src/primitives/transaction.h

@ -48,6 +48,11 @@
extern uint32_t ASSETCHAINS_MAGIC;
extern std::string ASSETCHAINS_SELFIMPORT;
#define JOINSPLIT_SIZE GetSerializeSize(JSDescription(), SER_NETWORK, PROTOCOL_VERSION)
#define OUTPUTDESCRIPTION_SIZE GetSerializeSize(OutputDescription(), SER_NETWORK, PROTOCOL_VERSION)
#define SPENDDESCRIPTION_SIZE GetSerializeSize(SpendDescription(), SER_NETWORK, PROTOCOL_VERSION)
// Overwinter transaction version
static const int32_t OVERWINTER_TX_VERSION = 3;
static_assert(OVERWINTER_TX_VERSION >= OVERWINTER_MIN_TX_VERSION,
@ -252,7 +257,6 @@ public:
JSDescription(): vpub_old(0), vpub_new(0) { }
JSDescription(
bool makeGrothProof,
ZCJoinSplit& params,
const uint256& joinSplitPubKey,
const uint256& rt,
@ -265,7 +269,6 @@ public:
);
static JSDescription Randomized(
bool makeGrothProof,
ZCJoinSplit& params,
const uint256& joinSplitPubKey,
const uint256& rt,

5
src/utiltest.cpp

@ -1,4 +1,5 @@
// Copyright (c) 2016 The Zcash developers
// Copyright (c) 2019-2020 The Hush developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@ -43,7 +44,7 @@ CWalletTx GetValidReceive(ZCJoinSplit& params,
// Prepare JoinSplits
uint256 rt;
JSDescription jsdesc {false, params, mtx.joinSplitPubKey, rt,
JSDescription jsdesc {params, mtx.joinSplitPubKey, rt,
inputs, outputs, 2*value, 0, false};
mtx.vjoinsplit.push_back(jsdesc);
@ -132,7 +133,7 @@ CWalletTx GetValidSpend(ZCJoinSplit& params,
// Prepare JoinSplits
uint256 rt = tree.root();
JSDescription jsdesc {false, params, mtx.joinSplitPubKey, rt,
JSDescription jsdesc {params, mtx.joinSplitPubKey, rt,
inputs, outputs, 0, value, false};
mtx.vjoinsplit.push_back(jsdesc);

4
src/wallet/asyncrpcoperation_mergetoaddress.cpp

@ -1,6 +1,7 @@
// Copyright (c) 2017 The Zcash developers
// Copyright (c) 2019-2020 The Hush developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
// file COPYING or https://www.opensource.org/licenses/mit-license.php .
/******************************************************************************
* Copyright © 2014-2019 The SuperNET Developers. *
@ -927,7 +928,6 @@ UniValue AsyncRPCOperation_mergetoaddress::perform_joinsplit(
uint256 esk; // payment disclosure - secret
JSDescription jsdesc = JSDescription::Randomized(
mtx.fOverwintered && (mtx.nVersion >= SAPLING_TX_VERSION),
*pzcashParams,
joinSplitPubKey_,
anchor,

1
src/wallet/asyncrpcoperation_sendmany.cpp

@ -1258,7 +1258,6 @@ UniValue AsyncRPCOperation_sendmany::perform_joinsplit(
uint256 esk; // payment disclosure - secret
JSDescription jsdesc = JSDescription::Randomized(
mtx.fOverwintered && (mtx.nVersion >= SAPLING_TX_VERSION),
*pzcashParams,
joinSplitPubKey_,
anchor,

1
src/wallet/asyncrpcoperation_shieldcoinbase.cpp

@ -455,7 +455,6 @@ UniValue AsyncRPCOperation_shieldcoinbase::perform_joinsplit(ShieldCoinbaseJSInf
uint256 esk; // payment disclosure - secret
JSDescription jsdesc = JSDescription::Randomized(
mtx.fOverwintered && (mtx.nVersion >= SAPLING_TX_VERSION),
*pzcashParams,
joinSplitPubKey_,
anchor,

8
src/wallet/rpcwallet.cpp

@ -3245,8 +3245,7 @@ UniValue zc_sample_joinsplit(const UniValue& params, bool fHelp, const CPubKey&
uint256 joinSplitPubKey;
uint256 anchor = SproutMerkleTree().root();
JSDescription samplejoinsplit(true,
*pzcashParams,
JSDescription samplejoinsplit(*pzcashParams,
joinSplitPubKey,
anchor,
{JSInput(), JSInput()},
@ -3306,8 +3305,6 @@ UniValue zc_benchmark(const UniValue& params, bool fHelp, const CPubKey& mypk)
for (int i = 0; i < samplecount; i++) {
if (benchmarktype == "sleep") {
sample_times.push_back(benchmark_sleep());
} else if (benchmarktype == "parameterloading") {
sample_times.push_back(benchmark_parameter_loading());
} else if (benchmarktype == "createjoinsplit") {
if (params.size() < 3) {
sample_times.push_back(benchmark_create_joinsplit());
@ -3605,8 +3602,7 @@ UniValue zc_raw_joinsplit(const UniValue& params, bool fHelp, const CPubKey& myp
mtx.nVersion = 2;
mtx.joinSplitPubKey = joinSplitPubKey;
JSDescription jsdesc(false,
*pzcashParams,
JSDescription jsdesc(*pzcashParams,
joinSplitPubKey,
anchor,
{vjsin[0], vjsin[1]},

Loading…
Cancel
Save