Merge pull request #94 from MyHush/sapcon_sietch
Untested sapling consolidation plus sietch outputs to reduce metadata leakage
This commit is contained in:
@@ -24,6 +24,7 @@
|
|||||||
#include "komodo_defs.h"
|
#include "komodo_defs.h"
|
||||||
#include "script/standard.h"
|
#include "script/standard.h"
|
||||||
#include "cc/CCinclude.h"
|
#include "cc/CCinclude.h"
|
||||||
|
#include "sietch.h"
|
||||||
|
|
||||||
int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp);
|
int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp);
|
||||||
int32_t komodo_electednotary(int32_t *numnotariesp,uint8_t *pubkey33,int32_t height,uint32_t timestamp);
|
int32_t komodo_electednotary(int32_t *numnotariesp,uint8_t *pubkey33,int32_t height,uint32_t timestamp);
|
||||||
|
|||||||
@@ -1,3 +1,8 @@
|
|||||||
|
// Copyright (c) 2020 The Hush developers
|
||||||
|
// TODO: Forge should add his preferred copyright line here
|
||||||
|
// Distributed under the MIT software license, see the accompanying
|
||||||
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
#include "assert.h"
|
#include "assert.h"
|
||||||
#include "boost/variant/static_visitor.hpp"
|
#include "boost/variant/static_visitor.hpp"
|
||||||
#include "asyncrpcoperation_saplingconsolidation.h"
|
#include "asyncrpcoperation_saplingconsolidation.h"
|
||||||
@@ -16,6 +21,7 @@ CAmount fConsolidationTxFee = DEFAULT_CONSOLIDATION_FEE;
|
|||||||
bool fConsolidationMapUsed = false;
|
bool fConsolidationMapUsed = false;
|
||||||
const int CONSOLIDATION_EXPIRY_DELTA = 15;
|
const int CONSOLIDATION_EXPIRY_DELTA = 15;
|
||||||
|
|
||||||
|
extern string randomSietchZaddr();
|
||||||
|
|
||||||
AsyncRPCOperation_saplingconsolidation::AsyncRPCOperation_saplingconsolidation(int targetHeight) : targetHeight_(targetHeight) {}
|
AsyncRPCOperation_saplingconsolidation::AsyncRPCOperation_saplingconsolidation(int targetHeight) : targetHeight_(targetHeight) {}
|
||||||
|
|
||||||
@@ -113,7 +119,10 @@ bool AsyncRPCOperation_saplingconsolidation::main_impl() {
|
|||||||
|
|
||||||
std::vector<SaplingNoteEntry> fromNotes;
|
std::vector<SaplingNoteEntry> fromNotes;
|
||||||
CAmount amountToSend = 0;
|
CAmount amountToSend = 0;
|
||||||
int maxQuantity = rand() % 35 + 10;
|
// max of 8 zins means the tx cannot reduce the anonset,
|
||||||
|
// since there will be 8 zins and 8 zouts at worst case
|
||||||
|
// This also helps reduce ztx creation time
|
||||||
|
int maxQuantity = rand() % 8 + 1;
|
||||||
for (const SaplingNoteEntry& saplingEntry : saplingEntries) {
|
for (const SaplingNoteEntry& saplingEntry : saplingEntries) {
|
||||||
|
|
||||||
libzcash::SaplingIncomingViewingKey ivk;
|
libzcash::SaplingIncomingViewingKey ivk;
|
||||||
@@ -125,14 +134,16 @@ bool AsyncRPCOperation_saplingconsolidation::main_impl() {
|
|||||||
fromNotes.push_back(saplingEntry);
|
fromNotes.push_back(saplingEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Only use a randomly determined number of notes between 10 and 45
|
//Only use a randomly determined number of notes
|
||||||
if (fromNotes.size() >= maxQuantity)
|
if (fromNotes.size() >= maxQuantity)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//random minimum 2 - 12 required
|
// minimum required
|
||||||
int minQuantity = rand() % 10 + 2;
|
// We use 3 so that addresses can spent one zutxo and still have another zutxo to use while that
|
||||||
|
// tx is confirming
|
||||||
|
int minQuantity = 3;
|
||||||
if (fromNotes.size() < minQuantity)
|
if (fromNotes.size() < minQuantity)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -168,10 +179,22 @@ bool AsyncRPCOperation_saplingconsolidation::main_impl() {
|
|||||||
|
|
||||||
builder.SetFee(fConsolidationTxFee);
|
builder.SetFee(fConsolidationTxFee);
|
||||||
|
|
||||||
//TODO: we want at least 2 zouts and potentially Sietch
|
// Add the actual consolidation tx
|
||||||
// We could split funds into 2 parts and send as 2 zouts
|
|
||||||
// or add amount=0 sietch zaddrs
|
|
||||||
builder.AddSaplingOutput(extsk.expsk.ovk, addr, amountToSend - fConsolidationTxFee);
|
builder.AddSaplingOutput(extsk.expsk.ovk, addr, amountToSend - fConsolidationTxFee);
|
||||||
|
|
||||||
|
// Add sietch zouts
|
||||||
|
int MIN_ZOUTS = 7;
|
||||||
|
for(size_t i = 0; i < MIN_ZOUTS; i++) {
|
||||||
|
// In Privacy Zdust We Trust -- Duke
|
||||||
|
string zdust = randomSietchZaddr();
|
||||||
|
LogPrint("zrpcunsafe", "%s: Adding sietch output", getId(), zdust);
|
||||||
|
auto zaddr = DecodePaymentAddress(zdust);
|
||||||
|
if (IsValidPaymentAddress(zaddr)) {
|
||||||
|
auto sietchZoutput = boost::get<libzcash::SaplingPaymentAddress>(zaddr);
|
||||||
|
int amount=0;
|
||||||
|
builder.AddSaplingOutput(extsk.expsk.ovk, sietchZoutput, amount);
|
||||||
|
}
|
||||||
|
}
|
||||||
//CTransaction tx = builder.Build();
|
//CTransaction tx = builder.Build();
|
||||||
|
|
||||||
auto maybe_tx = builder.Build();
|
auto maybe_tx = builder.Build();
|
||||||
|
|||||||
@@ -1,11 +1,16 @@
|
|||||||
|
// Copyright (c) 2020 The Hush developers
|
||||||
|
// TODO: Forge should add his preferred copyright line here
|
||||||
|
// Distributed under the MIT software license, see the accompanying
|
||||||
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
#include "amount.h"
|
#include "amount.h"
|
||||||
#include "asyncrpcoperation.h"
|
#include "asyncrpcoperation.h"
|
||||||
#include "univalue.h"
|
#include "univalue.h"
|
||||||
#include "zcash/Address.hpp"
|
#include "zcash/Address.hpp"
|
||||||
#include "zcash/zip32.h"
|
#include "zcash/zip32.h"
|
||||||
|
|
||||||
//Default fee used for consolidation transactions
|
//Default fee used for consolidation transactions, in puposhis
|
||||||
static const CAmount DEFAULT_CONSOLIDATION_FEE = 0;
|
static const CAmount DEFAULT_CONSOLIDATION_FEE = 10000;
|
||||||
extern CAmount fConsolidationTxFee;
|
extern CAmount fConsolidationTxFee;
|
||||||
extern bool fConsolidationMapUsed;
|
extern bool fConsolidationMapUsed;
|
||||||
|
|
||||||
@@ -34,4 +39,4 @@ private:
|
|||||||
|
|
||||||
void setConsolidationResult(int numTxCreated, const CAmount& amountConsolidated, const std::vector<std::string>& consolidationTxIds);
|
void setConsolidationResult(int numTxCreated, const CAmount& amountConsolidated, const std::vector<std::string>& consolidationTxIds);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -62,7 +62,6 @@
|
|||||||
|
|
||||||
#include "komodo_defs.h"
|
#include "komodo_defs.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "sietch.h"
|
|
||||||
#include "rpchushwallet.h"
|
#include "rpchushwallet.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@@ -79,6 +78,7 @@ uint32_t komodo_segid32(char *coinaddr);
|
|||||||
int32_t komodo_dpowconfs(int32_t height,int32_t numconfs);
|
int32_t komodo_dpowconfs(int32_t height,int32_t numconfs);
|
||||||
int32_t komodo_isnotaryvout(char *coinaddr,uint32_t tiptime); // from ac_private chains only
|
int32_t komodo_isnotaryvout(char *coinaddr,uint32_t tiptime); // from ac_private chains only
|
||||||
CBlockIndex *komodo_getblockindex(uint256 hash);
|
CBlockIndex *komodo_getblockindex(uint256 hash);
|
||||||
|
extern string randomSietchZaddr();
|
||||||
|
|
||||||
int64_t nWalletUnlockTime;
|
int64_t nWalletUnlockTime;
|
||||||
static CCriticalSection cs_nWalletUnlockTime;
|
static CCriticalSection cs_nWalletUnlockTime;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||||
// Copyright (c) 2019 The Hush 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.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user