Skip to content

Commit

Permalink
Merge remote-tracking branch 'navcoin/master' into btc-master
Browse files Browse the repository at this point in the history
 Conflicts:
	src/blsct/building_block/imp_inner_prod_arg.cpp
	src/blsct/wallet/keyman.cpp
	src/init.cpp
	src/kernel/chainparams.cpp
	src/node/miner.cpp
	src/primitives/transaction.h
	src/test/fuzz/rpc.cpp
	src/test/hash_tests.cpp
	src/validation.cpp
	src/wallet/rpc/wallet.cpp
	src/wallet/spend.cpp
	src/wallet/test/util.cpp
	src/wallet/transaction.h
	src/wallet/walletdb.cpp
	test/functional/rpc_dumptxoutset.py
	test/functional/wallet_bumpfee.py
	test/functional/wallet_fundrawtransaction.py
  • Loading branch information
mxaddict committed Jan 3, 2024
2 parents b3b9266 + de5b69d commit a361fd7
Show file tree
Hide file tree
Showing 107 changed files with 3,194 additions and 998 deletions.
3 changes: 3 additions & 0 deletions contrib/devtools/gen-bitcoin-conf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,7 @@ cat >> "${EXAMPLE_CONF_FILE}" << 'EOF'
# Options for regtest
[regtest]
# Options for blsctregtest
[blsctregtest]
EOF
102 changes: 101 additions & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ BITCOIN_CORE_H = \
blsct/wallet/hdchain.h \
blsct/wallet/keyman.h \
blsct/wallet/keyring.h \
blsct/wallet/txfactory.h \
blsct/wallet/txfactory_global.h \
blsct/wallet/verification.h \
dandelion.h \
chain.h \
chainparams.h \
Expand Down Expand Up @@ -496,6 +499,7 @@ libbitcoin_node_a_SOURCES = \
blsct/set_mem_proof/set_mem_proof.cpp \
blsct/set_mem_proof/set_mem_proof_setup.cpp \
blsct/set_mem_proof/set_mem_proof_prover.cpp \
blsct/wallet/verification.cpp \
blsct/signature.cpp \
chain.cpp \
chainparams.cpp \
Expand Down Expand Up @@ -609,12 +613,46 @@ endif
libbitcoin_wallet_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(BOOST_CPPFLAGS) $(BDB_CPPFLAGS) $(SQLITE_CFLAGS)
libbitcoin_wallet_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
libbitcoin_wallet_a_SOURCES = \
blsct/arith/mcl/mcl_g1point.cpp \
blsct/arith/mcl/mcl_scalar.cpp \
blsct/arith/elements.cpp \
blsct/building_block/generator_deriver.cpp \
blsct/building_block/g_h_gi_hi_zero_verifier.cpp \
blsct/building_block/imp_inner_prod_arg.cpp \
blsct/building_block/lazy_point.cpp \
blsct/building_block/lazy_points.cpp \
blsct/building_block/weighted_inner_prod_arg.cpp \
blsct/common.cpp \
blsct/double_public_key.cpp \
blsct/eip_2333/bls12_381_keygen.cpp \
blsct/private_key.cpp \
blsct/public_key.cpp \
blsct/public_keys.cpp \
blsct/range_proof/bulletproofs/amount_recovery_request.cpp \
blsct/range_proof/bulletproofs/amount_recovery_result.cpp \
blsct/range_proof/bulletproofs/range_proof_logic.cpp \
blsct/range_proof/bulletproofs/range_proof.cpp \
blsct/range_proof/bulletproofs/range_proof_with_transcript.cpp \
blsct/range_proof/bulletproofs_plus/amount_recovery_request.cpp \
blsct/range_proof/bulletproofs_plus/amount_recovery_result.cpp \
blsct/range_proof/bulletproofs_plus/range_proof_logic.cpp \
blsct/range_proof/bulletproofs_plus/range_proof.cpp \
blsct/range_proof/bulletproofs_plus/range_proof_with_transcript.cpp \
blsct/range_proof/bulletproofs_plus/util.cpp \
blsct/range_proof/common.cpp \
blsct/range_proof/generators.cpp \
blsct/range_proof/msg_amt_cipher.cpp \
blsct/range_proof/proof_base.cpp \
blsct/set_mem_proof/set_mem_proof.cpp \
blsct/set_mem_proof/set_mem_proof_setup.cpp \
blsct/set_mem_proof/set_mem_proof_prover.cpp \
blsct/signature.cpp \
blsct/wallet/address.cpp \
blsct/wallet/keyman.cpp \
blsct/wallet/keyring.cpp \
blsct/wallet/txfactory.cpp \
blsct/wallet/txfactory_global.cpp \
blsct/wallet/verification.cpp \
wallet/coincontrol.cpp \
wallet/context.cpp \
wallet/crypter.cpp \
Expand Down Expand Up @@ -789,6 +827,7 @@ libbitcoin_consensus_a_SOURCES = \
tinyformat.h \
uint256.cpp \
uint256.h \
util/moneystr.cpp \
util/strencodings.cpp \
util/strencodings.h
#
Expand All @@ -800,10 +839,45 @@ libbitcoin_common_a_SOURCES = \
addresstype.cpp \
base58.cpp \
bech32.cpp \
blsct/arith/mcl/mcl_g1point.cpp \
blsct/arith/mcl/mcl_scalar.cpp \
bech32_mod.cpp \
blsct/arith/elements.cpp \
blsct/building_block/generator_deriver.cpp \
blsct/building_block/g_h_gi_hi_zero_verifier.cpp \
blsct/building_block/imp_inner_prod_arg.cpp \
blsct/building_block/lazy_point.cpp \
blsct/building_block/lazy_points.cpp \
blsct/building_block/weighted_inner_prod_arg.cpp \
blsct/common.cpp \
blsct/double_public_key.cpp \
blsct/private_key.cpp \
blsct/public_key.cpp \
blsct/public_keys.cpp \
blsct/range_proof/bulletproofs/range_proof.cpp \
blsct/range_proof/bulletproofs/range_proof_logic.cpp \
blsct/range_proof/bulletproofs_plus/range_proof.cpp \
blsct/range_proof/bulletproofs/amount_recovery_request.cpp \
blsct/range_proof/bulletproofs/amount_recovery_result.cpp \
blsct/range_proof/bulletproofs/range_proof_logic.cpp \
blsct/range_proof/bulletproofs/range_proof.cpp \
blsct/range_proof/bulletproofs/range_proof_with_transcript.cpp \
blsct/range_proof/bulletproofs_plus/amount_recovery_request.cpp \
blsct/range_proof/bulletproofs_plus/amount_recovery_result.cpp \
blsct/range_proof/bulletproofs_plus/range_proof_logic.cpp \
blsct/range_proof/bulletproofs_plus/range_proof.cpp \
blsct/range_proof/bulletproofs_plus/range_proof_with_transcript.cpp \
blsct/range_proof/bulletproofs_plus/util.cpp \
blsct/range_proof/common.cpp \
blsct/range_proof/generators.cpp \
blsct/range_proof/msg_amt_cipher.cpp \
blsct/range_proof/proof_base.cpp \
blsct/set_mem_proof/set_mem_proof.cpp \
blsct/set_mem_proof/set_mem_proof_setup.cpp \
blsct/set_mem_proof/set_mem_proof_prover.cpp \
blsct/signature.cpp \
blsct/wallet/address.cpp \
blsct/wallet/txfactory_global.cpp \
chainparams.cpp \
coins.cpp \
common/args.cpp \
Expand Down Expand Up @@ -1074,15 +1148,41 @@ libbitcoinkernel_la_SOURCES = \
blsct/arith/mcl/mcl_g1point.cpp \
blsct/arith/mcl/mcl_scalar.cpp \
blsct/arith/elements.cpp \
blsct/building_block/generator_deriver.cpp \
blsct/building_block/g_h_gi_hi_zero_verifier.cpp \
blsct/building_block/imp_inner_prod_arg.cpp \
blsct/building_block/lazy_point.cpp \
blsct/building_block/lazy_points.cpp \
blsct/building_block/weighted_inner_prod_arg.cpp \
blsct/common.cpp \
blsct/double_public_key.cpp \
blsct/private_key.cpp \
blsct/public_key.cpp \
blsct/public_keys.cpp \
blsct/range_proof/common.cpp \
blsct/range_proof/bulletproofs/range_proof.cpp \
blsct/range_proof/bulletproofs/range_proof_logic.cpp \
blsct/range_proof/bulletproofs_plus/range_proof.cpp \
blsct/range_proof/bulletproofs/amount_recovery_request.cpp \
blsct/range_proof/bulletproofs/amount_recovery_result.cpp \
blsct/range_proof/bulletproofs/range_proof_logic.cpp \
blsct/range_proof/bulletproofs/range_proof.cpp \
blsct/range_proof/bulletproofs/range_proof_with_transcript.cpp \
blsct/range_proof/bulletproofs_plus/amount_recovery_request.cpp \
blsct/range_proof/bulletproofs_plus/amount_recovery_result.cpp \
blsct/range_proof/bulletproofs_plus/range_proof_logic.cpp \
blsct/range_proof/bulletproofs_plus/range_proof.cpp \
blsct/range_proof/bulletproofs_plus/range_proof_with_transcript.cpp \
blsct/range_proof/bulletproofs_plus/util.cpp \
blsct/range_proof/common.cpp \
blsct/range_proof/generators.cpp \
blsct/range_proof/msg_amt_cipher.cpp \
blsct/range_proof/proof_base.cpp \
blsct/set_mem_proof/set_mem_proof.cpp \
blsct/set_mem_proof/set_mem_proof_setup.cpp \
blsct/set_mem_proof/set_mem_proof_prover.cpp \
blsct/signature.cpp \
blsct/wallet/txfactory_global.cpp \
blsct/wallet/verification.cpp \
chain.cpp \
clientversion.cpp \
coins.cpp \
Expand Down
7 changes: 6 additions & 1 deletion src/Makefile.test.include
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,12 @@ BITCOIN_TESTS =\

if ENABLE_WALLET
BITCOIN_TESTS += \
test/blsct/wallet/address_tests.cpp \
test/blsct/wallet/chain_tests.cpp \
test/blsct/wallet/keyman_tests.cpp \
test/blsct/wallet/txfactory_global_tests.cpp \
test/blsct/wallet/txfactory_tests.cpp \
test/blsct/wallet/validation_tests.cpp \
wallet/test/feebumper_tests.cpp \
wallet/test/psbt_wallet_tests.cpp \
wallet/test/spend_tests.cpp \
Expand Down Expand Up @@ -377,7 +383,6 @@ test_fuzz_fuzz_SOURCES = \
test/fuzz/transaction.cpp \
test/fuzz/tx_in.cpp \
test/fuzz/tx_out.cpp \
test/fuzz/tx_pool.cpp \
test/fuzz/txorphan.cpp \
test/fuzz/txrequest.cpp \
test/fuzz/utxo_snapshot.cpp \
Expand Down
1 change: 1 addition & 0 deletions src/Makefile.test_util.include
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ libtest_util_a_SOURCES = \
blsct/public_key.cpp \
blsct/public_keys.cpp \
blsct/signature.h \
blsct/wallet/txfactory_global.cpp \
test/util/blockfilter.cpp \
test/util/coins.cpp \
test/util/index.cpp \
Expand Down
5 changes: 4 additions & 1 deletion src/bitcoin-cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ static void SetupCliArgs(ArgsManager& argsman)
const auto testnetBaseParams = CreateBaseChainParams(ChainType::TESTNET);
const auto signetBaseParams = CreateBaseChainParams(ChainType::SIGNET);
const auto regtestBaseParams = CreateBaseChainParams(ChainType::REGTEST);
const auto blsctRegtestBaseParams = CreateBaseChainParams(ChainType::BLSCTREGTEST);

argsman.AddArg("-version", "Print version and exit", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
argsman.AddArg("-conf=<file>", strprintf("Specify configuration file. Relative paths will be prefixed by datadir location. (default: %s)", BITCOIN_CONF_FILENAME), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
Expand All @@ -99,7 +100,7 @@ static void SetupCliArgs(ArgsManager& argsman)
argsman.AddArg("-rpcconnect=<ip>", strprintf("Send commands to node running on <ip> (default: %s)", DEFAULT_RPCCONNECT), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
argsman.AddArg("-rpccookiefile=<loc>", "Location of the auth cookie. Relative paths will be prefixed by a net-specific datadir location. (default: data dir)", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
argsman.AddArg("-rpcpassword=<pw>", "Password for JSON-RPC connections", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
argsman.AddArg("-rpcport=<port>", strprintf("Connect to JSON-RPC on <port> (default: %u, testnet: %u, signet: %u, regtest: %u)", defaultBaseParams->RPCPort(), testnetBaseParams->RPCPort(), signetBaseParams->RPCPort(), regtestBaseParams->RPCPort()), ArgsManager::ALLOW_ANY | ArgsManager::NETWORK_ONLY, OptionsCategory::OPTIONS);
argsman.AddArg("-rpcport=<port>", strprintf("Connect to JSON-RPC on <port> (default: %u, testnet: %u, signet: %u, regtest: %u, blsctregtest: %u)", defaultBaseParams->RPCPort(), testnetBaseParams->RPCPort(), signetBaseParams->RPCPort(), regtestBaseParams->RPCPort(), blsctRegtestBaseParams->RPCPort()), ArgsManager::ALLOW_ANY | ArgsManager::NETWORK_ONLY, OptionsCategory::OPTIONS);
argsman.AddArg("-rpcuser=<user>", "Username for JSON-RPC connections", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
argsman.AddArg("-rpcwait", "Wait for RPC server to start", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
argsman.AddArg("-rpcwaittimeout=<n>", strprintf("Timeout in seconds to wait for the RPC server to start, or 0 for no timeout. (default: %d)", DEFAULT_WAIT_CLIENT_TIMEOUT), ArgsManager::ALLOW_ANY | ArgsManager::DISALLOW_NEGATION, OptionsCategory::OPTIONS);
Expand Down Expand Up @@ -434,6 +435,8 @@ class NetinfoRequestHandler : public BaseRequestHandler
return " signet";
case ChainType::REGTEST:
return " regtest";
case ChainType::BLSCTREGTEST:
return " blsctregtest";
case ChainType::MAIN:
return "";
}
Expand Down
2 changes: 1 addition & 1 deletion src/bitcoin-wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ static std::optional<int> WalletAppInit(ArgsManager& args, int argc, char* argv[
strUsage += "\n"
"bitcoin-wallet is an offline tool for creating and interacting with " PACKAGE_NAME " wallet files.\n"
"By default navcoin-wallet will act on wallets in the default mainnet wallet directory in the datadir.\n"
"To change the target wallet, use the -datadir, -wallet and -regtest/-signet/-testnet arguments.\n\n"
"To change the target wallet, use the -datadir, -wallet and -regtest/-blsctregtest/-signet/-testnet arguments.\n\n"
"Usage:\n"
" navcoin-wallet [options] <command>\n";
strUsage += "\n" + args.GetHelpMessage();
Expand Down
16 changes: 7 additions & 9 deletions src/blsct/building_block/imp_inner_prod_arg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,30 +142,28 @@ void ImpInnerProdArg::LoopWithYPows<Mcl>(

template <typename T>
std::optional<Elements<typename T::Scalar>> ImpInnerProdArg::GenAllRoundXs(
const size_t& num_rounds,
const Elements<typename T::Point>& Ls,
const Elements<typename T::Point>& Rs,
HashWriter& fiat_shamir
) {
HashWriter& fiat_shamir)
{
using Scalar = typename T::Scalar;
using Scalars = Elements<Scalar>;

Scalars xs;
for (size_t i = 0; i < num_rounds; ++i) {

for (size_t i = 0; i < Ls.Size(); ++i) {
fiat_shamir << Ls[i];
fiat_shamir << Rs[i];
GEN_FIAT_SHAMIR_VAR(x, fiat_shamir, retry);
xs.Add(x);
}

return xs;

retry:
return std::nullopt;
}
template
std::optional<Elements<Mcl::Scalar>> ImpInnerProdArg::GenAllRoundXs<Mcl>(
const size_t& num_rounds,
template std::optional<Elements<Mcl::Scalar>> ImpInnerProdArg::GenAllRoundXs<Mcl>(
const Elements<Mcl::Point>& Ls,
const Elements<Mcl::Point>& Rs,
HashWriter& fiat_shamir
);
HashWriter& fiat_shamir);
1 change: 0 additions & 1 deletion src/blsct/building_block/imp_inner_prod_arg.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ struct ImpInnerProdArg {
// inner product argument from a given hasher
template <typename T>
static std::optional<Elements<typename T::Scalar>> GenAllRoundXs(
const size_t& num_rounds,
const Elements<typename T::Point>& Ls,
const Elements<typename T::Point>& Rs,
HashWriter& fiat_shamir
Expand Down
9 changes: 7 additions & 2 deletions src/blsct/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,13 @@ class Common
{
public:
inline static const std::vector<uint8_t> BLSCTBALANCE = {
'B', 'L', 'S', 'C', 'T', 'B', 'A', 'L', 'A', 'N', 'C', 'E'
};
'0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
'0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
'0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
'0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
'B', 'L', 'S', 'C', 'T', 'B', 'A', 'L', 'A', 'N', 'C', 'E',
'0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
'0', '0', '0', '0', '0', '0', '0', '0'};

static std::vector<uint8_t> DataStreamToVector(const DataStream& st);

Expand Down
2 changes: 1 addition & 1 deletion src/blsct/double_public_key.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ DoublePublicKey::DoublePublicKey(const std::vector<unsigned char>& keys)

CKeyID DoublePublicKey::GetID() const
{
return CKeyID(Hash160(GetVch()));
return sk.GetID();
}

bool DoublePublicKey::GetViewKey(PublicKey& ret) const
Expand Down
10 changes: 8 additions & 2 deletions src/blsct/private_key.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ Signature PrivateKey::SignBalance() const
return CoreSign(Common::BLSCTBALANCE);
}

Signature PrivateKey::Sign(const uint256& msg) const
{
return Sign(Message(msg.begin(), msg.end()));
}

Signature PrivateKey::Sign(const Message& msg) const
{
auto pk = GetPublicKey();
Expand All @@ -77,8 +82,9 @@ Signature PrivateKey::Sign(const Message& msg) const
return sig;
}

bool PrivateKey::VerifyPubKey(const PublicKey& pk) const {
bool PrivateKey::VerifyPubKey(const PublicKey& pk) const
{
return GetPublicKey() == pk;
}

} // namespace blsct
} // namespace blsct
1 change: 1 addition & 0 deletions src/blsct/private_key.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class PrivateKey
Signature SignBalance() const;

// Message augmentation scheme
Signature Sign(const uint256& msg) const;
Signature Sign(const Message& msg) const;

// Core operations
Expand Down
8 changes: 6 additions & 2 deletions src/blsct/public_keys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ bool PublicKeys::CoreAggregateVerify(const std::vector<PublicKey::Message>& msgs
return res == 1;
}

bool PublicKeys::VerifyBatch(const std::vector<PublicKey::Message>& msgs, const Signature& sig) const
bool PublicKeys::VerifyBatch(const std::vector<PublicKey::Message>& msgs, const Signature& sig, const bool& fVerifyTx) const
{
if (m_pks.size() != msgs.size() || m_pks.size() == 0) {
throw std::runtime_error(std::string(__func__) + strprintf(
Expand All @@ -78,7 +78,11 @@ bool PublicKeys::VerifyBatch(const std::vector<PublicKey::Message>& msgs, const
std::vector<std::vector<uint8_t>> aug_msgs;
auto msg = msgs.begin();
for (auto pk = m_pks.begin(), end = m_pks.end(); pk != end; ++pk, ++msg) {
aug_msgs.push_back(pk->AugmentMessage(*msg));
if (*msg == blsct::Common::BLSCTBALANCE && fVerifyTx) {
aug_msgs.push_back(*msg);
} else {
aug_msgs.push_back(pk->AugmentMessage(*msg));
}
}
return CoreAggregateVerify(aug_msgs, sig);
}
Expand Down
2 changes: 1 addition & 1 deletion src/blsct/public_keys.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class PublicKeys
bool VerifyBalanceBatch(const Signature& sig) const;

// Message augmentation scheme
bool VerifyBatch(const std::vector<PublicKey::Message>& msgs, const Signature& sig) const;
bool VerifyBatch(const std::vector<PublicKey::Message>& msgs, const Signature& sig, const bool& fVerifyTx = false) const;

private:
// Core operations
Expand Down
Loading

0 comments on commit a361fd7

Please sign in to comment.