More libsnark removal changes to various internals
This commit is contained in:
@@ -27,7 +27,6 @@
|
|||||||
#include "librustzcash.h"
|
#include "librustzcash.h"
|
||||||
|
|
||||||
JSDescription::JSDescription(
|
JSDescription::JSDescription(
|
||||||
bool makeGrothProof,
|
|
||||||
ZCJoinSplit& params,
|
ZCJoinSplit& params,
|
||||||
const uint256& joinSplitPubKey,
|
const uint256& joinSplitPubKey,
|
||||||
const uint256& anchor,
|
const uint256& anchor,
|
||||||
@@ -42,7 +41,6 @@ JSDescription::JSDescription(
|
|||||||
std::array<libzcash::SproutNote, ZC_NUM_JS_OUTPUTS> notes;
|
std::array<libzcash::SproutNote, ZC_NUM_JS_OUTPUTS> notes;
|
||||||
|
|
||||||
proof = params.prove(
|
proof = params.prove(
|
||||||
makeGrothProof,
|
|
||||||
inputs,
|
inputs,
|
||||||
outputs,
|
outputs,
|
||||||
notes,
|
notes,
|
||||||
@@ -62,7 +60,6 @@ JSDescription::JSDescription(
|
|||||||
}
|
}
|
||||||
|
|
||||||
JSDescription JSDescription::Randomized(
|
JSDescription JSDescription::Randomized(
|
||||||
bool makeGrothProof,
|
|
||||||
ZCJoinSplit& params,
|
ZCJoinSplit& params,
|
||||||
const uint256& joinSplitPubKey,
|
const uint256& joinSplitPubKey,
|
||||||
const uint256& anchor,
|
const uint256& anchor,
|
||||||
@@ -87,71 +84,18 @@ JSDescription JSDescription::Randomized(
|
|||||||
MappedShuffle(outputs.begin(), outputMap.begin(), ZC_NUM_JS_OUTPUTS, gen);
|
MappedShuffle(outputs.begin(), outputMap.begin(), ZC_NUM_JS_OUTPUTS, gen);
|
||||||
|
|
||||||
return JSDescription(
|
return JSDescription(
|
||||||
makeGrothProof,
|
|
||||||
params, joinSplitPubKey, anchor, inputs, outputs,
|
params, joinSplitPubKey, anchor, inputs, outputs,
|
||||||
vpub_old, vpub_new, computeProof,
|
vpub_old, vpub_new, computeProof,
|
||||||
esk // payment disclosure
|
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(
|
bool JSDescription::Verify(
|
||||||
ZCJoinSplit& params,
|
ZCJoinSplit& params,
|
||||||
libzcash::ProofVerifier& verifier,
|
libzcash::ProofVerifier& verifier,
|
||||||
const uint256& joinSplitPubKey
|
const uint256& joinSplitPubKey
|
||||||
) const {
|
) const {
|
||||||
auto pv = SproutProofVerifier(params, verifier, joinSplitPubKey, *this);
|
return false;
|
||||||
return boost::apply_visitor(pv, proof);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint256 JSDescription::h_sig(ZCJoinSplit& params, const uint256& joinSplitPubKey) const
|
uint256 JSDescription::h_sig(ZCJoinSplit& params, const uint256& joinSplitPubKey) const
|
||||||
|
|||||||
@@ -48,6 +48,11 @@
|
|||||||
extern uint32_t ASSETCHAINS_MAGIC;
|
extern uint32_t ASSETCHAINS_MAGIC;
|
||||||
extern std::string ASSETCHAINS_SELFIMPORT;
|
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
|
// Overwinter transaction version
|
||||||
static const int32_t OVERWINTER_TX_VERSION = 3;
|
static const int32_t OVERWINTER_TX_VERSION = 3;
|
||||||
static_assert(OVERWINTER_TX_VERSION >= OVERWINTER_MIN_TX_VERSION,
|
static_assert(OVERWINTER_TX_VERSION >= OVERWINTER_MIN_TX_VERSION,
|
||||||
@@ -252,7 +257,6 @@ public:
|
|||||||
JSDescription(): vpub_old(0), vpub_new(0) { }
|
JSDescription(): vpub_old(0), vpub_new(0) { }
|
||||||
|
|
||||||
JSDescription(
|
JSDescription(
|
||||||
bool makeGrothProof,
|
|
||||||
ZCJoinSplit& params,
|
ZCJoinSplit& params,
|
||||||
const uint256& joinSplitPubKey,
|
const uint256& joinSplitPubKey,
|
||||||
const uint256& rt,
|
const uint256& rt,
|
||||||
@@ -265,7 +269,6 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
static JSDescription Randomized(
|
static JSDescription Randomized(
|
||||||
bool makeGrothProof,
|
|
||||||
ZCJoinSplit& params,
|
ZCJoinSplit& params,
|
||||||
const uint256& joinSplitPubKey,
|
const uint256& joinSplitPubKey,
|
||||||
const uint256& rt,
|
const uint256& rt,
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
// Copyright (c) 2016 The Zcash developers
|
// Copyright (c) 2016 The Zcash developers
|
||||||
|
// Copyright (c) 2019-2020 The Hush developers
|
||||||
// Distributed under the MIT software license, see the accompanying
|
// Distributed under the MIT software license, see the accompanying
|
||||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
@@ -43,7 +44,7 @@ CWalletTx GetValidReceive(ZCJoinSplit& params,
|
|||||||
|
|
||||||
// Prepare JoinSplits
|
// Prepare JoinSplits
|
||||||
uint256 rt;
|
uint256 rt;
|
||||||
JSDescription jsdesc {false, params, mtx.joinSplitPubKey, rt,
|
JSDescription jsdesc {params, mtx.joinSplitPubKey, rt,
|
||||||
inputs, outputs, 2*value, 0, false};
|
inputs, outputs, 2*value, 0, false};
|
||||||
mtx.vjoinsplit.push_back(jsdesc);
|
mtx.vjoinsplit.push_back(jsdesc);
|
||||||
|
|
||||||
@@ -132,7 +133,7 @@ CWalletTx GetValidSpend(ZCJoinSplit& params,
|
|||||||
|
|
||||||
// Prepare JoinSplits
|
// Prepare JoinSplits
|
||||||
uint256 rt = tree.root();
|
uint256 rt = tree.root();
|
||||||
JSDescription jsdesc {false, params, mtx.joinSplitPubKey, rt,
|
JSDescription jsdesc {params, mtx.joinSplitPubKey, rt,
|
||||||
inputs, outputs, 0, value, false};
|
inputs, outputs, 0, value, false};
|
||||||
mtx.vjoinsplit.push_back(jsdesc);
|
mtx.vjoinsplit.push_back(jsdesc);
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) 2017 The Zcash developers
|
// Copyright (c) 2017 The Zcash developers
|
||||||
|
// Copyright (c) 2019-2020 The Hush developers
|
||||||
// Distributed under the MIT software license, see the accompanying
|
// 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. *
|
* Copyright © 2014-2019 The SuperNET Developers. *
|
||||||
@@ -927,7 +928,6 @@ UniValue AsyncRPCOperation_mergetoaddress::perform_joinsplit(
|
|||||||
uint256 esk; // payment disclosure - secret
|
uint256 esk; // payment disclosure - secret
|
||||||
|
|
||||||
JSDescription jsdesc = JSDescription::Randomized(
|
JSDescription jsdesc = JSDescription::Randomized(
|
||||||
mtx.fOverwintered && (mtx.nVersion >= SAPLING_TX_VERSION),
|
|
||||||
*pzcashParams,
|
*pzcashParams,
|
||||||
joinSplitPubKey_,
|
joinSplitPubKey_,
|
||||||
anchor,
|
anchor,
|
||||||
|
|||||||
@@ -1258,7 +1258,6 @@ UniValue AsyncRPCOperation_sendmany::perform_joinsplit(
|
|||||||
uint256 esk; // payment disclosure - secret
|
uint256 esk; // payment disclosure - secret
|
||||||
|
|
||||||
JSDescription jsdesc = JSDescription::Randomized(
|
JSDescription jsdesc = JSDescription::Randomized(
|
||||||
mtx.fOverwintered && (mtx.nVersion >= SAPLING_TX_VERSION),
|
|
||||||
*pzcashParams,
|
*pzcashParams,
|
||||||
joinSplitPubKey_,
|
joinSplitPubKey_,
|
||||||
anchor,
|
anchor,
|
||||||
|
|||||||
@@ -455,7 +455,6 @@ UniValue AsyncRPCOperation_shieldcoinbase::perform_joinsplit(ShieldCoinbaseJSInf
|
|||||||
uint256 esk; // payment disclosure - secret
|
uint256 esk; // payment disclosure - secret
|
||||||
|
|
||||||
JSDescription jsdesc = JSDescription::Randomized(
|
JSDescription jsdesc = JSDescription::Randomized(
|
||||||
mtx.fOverwintered && (mtx.nVersion >= SAPLING_TX_VERSION),
|
|
||||||
*pzcashParams,
|
*pzcashParams,
|
||||||
joinSplitPubKey_,
|
joinSplitPubKey_,
|
||||||
anchor,
|
anchor,
|
||||||
|
|||||||
@@ -3245,8 +3245,7 @@ UniValue zc_sample_joinsplit(const UniValue& params, bool fHelp, const CPubKey&
|
|||||||
|
|
||||||
uint256 joinSplitPubKey;
|
uint256 joinSplitPubKey;
|
||||||
uint256 anchor = SproutMerkleTree().root();
|
uint256 anchor = SproutMerkleTree().root();
|
||||||
JSDescription samplejoinsplit(true,
|
JSDescription samplejoinsplit(*pzcashParams,
|
||||||
*pzcashParams,
|
|
||||||
joinSplitPubKey,
|
joinSplitPubKey,
|
||||||
anchor,
|
anchor,
|
||||||
{JSInput(), JSInput()},
|
{JSInput(), JSInput()},
|
||||||
@@ -3306,8 +3305,6 @@ UniValue zc_benchmark(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
|||||||
for (int i = 0; i < samplecount; i++) {
|
for (int i = 0; i < samplecount; i++) {
|
||||||
if (benchmarktype == "sleep") {
|
if (benchmarktype == "sleep") {
|
||||||
sample_times.push_back(benchmark_sleep());
|
sample_times.push_back(benchmark_sleep());
|
||||||
} else if (benchmarktype == "parameterloading") {
|
|
||||||
sample_times.push_back(benchmark_parameter_loading());
|
|
||||||
} else if (benchmarktype == "createjoinsplit") {
|
} else if (benchmarktype == "createjoinsplit") {
|
||||||
if (params.size() < 3) {
|
if (params.size() < 3) {
|
||||||
sample_times.push_back(benchmark_create_joinsplit());
|
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.nVersion = 2;
|
||||||
mtx.joinSplitPubKey = joinSplitPubKey;
|
mtx.joinSplitPubKey = joinSplitPubKey;
|
||||||
|
|
||||||
JSDescription jsdesc(false,
|
JSDescription jsdesc(*pzcashParams,
|
||||||
*pzcashParams,
|
|
||||||
joinSplitPubKey,
|
joinSplitPubKey,
|
||||||
anchor,
|
anchor,
|
||||||
{vjsin[0], vjsin[1]},
|
{vjsin[0], vjsin[1]},
|
||||||
|
|||||||
Reference in New Issue
Block a user