Skip to content

Commit

Permalink
Spats integration first step (#1526)
Browse files Browse the repository at this point in the history
* copy from libspark

* change name to spats

* add generators

* push testing

* add constructor coin

* fixed parameter

* add parameter com3

* implement bpplus proof

* implement bpplus proof

* update gitignore

* implement bpplus proof

* update Coin inputs in spend tx

* implement identify and test cases

* fix prepare value proof and verify

* add label transcript for balance

* implement balance proof

* fix return verify

* fix return verify

* remove unnecessary

* add balance unit test

* add label BaseAsset

* implement base asset

* add base asset unit test

* check bad statement

* add testcase base asset proof

* add type equality prove

* add test case

* add mint unit test

* improve solution

* chage type in MintedCoinData struct

* ay

* fix conditions and fix verify com

* modify

* spend test

* Update Makefile.test.include

* Update Makefile.test.include

* Update Makefile.test.include

* add iota and a in SerializationOp

* Spend transaction

* add verify spend_transaction

* update walltet backup dump

* import multiexponent

* edit the amount of the required memory

* change a, iota types to Scalar

* edit typo

* update computation using multiexponent

* edit the boolean logic

* change a, iota types to Scalar

* remove unnecessary variables

* edit variable type

* add throw exceptions

* change variable type to Scalar

* add test cases

* change variable types to Scalar

* add filenames for building

* test for pushing

* test for deleting

* test for pushing

* Spark address ownership proofs implemented.

* Missing files added

* Changes to compile with C++20 (#1505)

* switch compilation to C++20

* fixed C++20 detection code

* fixed compile errors with C++20

* further changes to support C++20 compilation

* removed temporarily added compile-time assertion

* added comments regarding dependency library upgrades for the future

* Switched compilation to C++20 for BDB too

* CI C++20 proper (#1514)

* attempt to fix C++20 CI by upgrading Docker image to Ubuntu 24.04

* more targeted #inclusion of boost_function_epilogue.hpp

* Trying to resolve Jenkins compile error by using #include "./boost_function_epilogue.hpp"

* adding boost_function_epilogue.hpp to Makefile.am to fix the CI build error

* Spats admin gui (#1497)

* Initial mock-up of the 'My Own Spats' page on the GUI

* fixed qt/myownspats build errors

* restored accidentally removed code

* My Own Spats GUI appearance fixes + added buttons

* Addressed coderabbitai comments on 'My Own Spats GUI' changes

* Libspats cleanup refacor (#1517)

* Cleanup and refactor

* More cleanup

* Reverted some changes, bug fixes

* More fixes

---------

Co-authored-by: JusAeng <[email protected]>
Co-authored-by: Naveeharn Tehmarn <[email protected]>
Co-authored-by: Nuttanan29445 <[email protected]>
Co-authored-by: Manhermak Praditpong <[email protected]>
Co-authored-by: Jus <[email protected]>
Co-authored-by: DiFve <[email protected]>
Co-authored-by: naveeharn <[email protected]>
Co-authored-by: Gevorg Voskanyan <[email protected]>
  • Loading branch information
9 people authored Feb 10, 2025
1 parent a32ec20 commit 256fba2
Show file tree
Hide file tree
Showing 75 changed files with 4,847 additions and 64 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,7 @@ firo.files
firo.includes

/guix-build-*

/diagrams
.clang-uml
compile_commands.json
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pipeline {
agent {
docker {
image 'firoorg/firo-builder-depends:latest'
image 'firoorg/firo-builder-depends24:latest'
alwaysPull true
}
}
Expand Down
64 changes: 64 additions & 0 deletions build-aux/m4/ax_cxx_compile_stdcxx.m4
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl
m4_if([$1], [11], [ax_cxx_compile_alternatives="11 0x"],
[$1], [14], [ax_cxx_compile_alternatives="14 1y"],
[$1], [17], [ax_cxx_compile_alternatives="17 1z"],
[$1], [20], [ax_cxx_compile_alternatives="20 2a"],
[m4_fatal([invalid first argument `$1' to AX_CXX_COMPILE_STDCXX])])dnl
m4_if([$2], [], [],
[$2], [ext], [],
Expand Down Expand Up @@ -154,6 +155,13 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_17],
_AX_CXX_COMPILE_STDCXX_testbody_new_in_17
)

m4_define([_AX_CXX_COMPILE_STDCXX_testbody_20],
_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
_AX_CXX_COMPILE_STDCXX_testbody_new_in_14
_AX_CXX_COMPILE_STDCXX_testbody_new_in_17
_AX_CXX_COMPILE_STDCXX_testbody_new_in_20
)

dnl Tests for new features in C++11

m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_11], [[
Expand Down Expand Up @@ -949,3 +957,59 @@ namespace cxx17
#endif // __cplusplus < 201703L
]])

dnl Tests for new features in C++20

m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_20], [[
// If the compiler admits that it is not ready for C++20, why torture it?
// Hopefully, this will speed up the test.
#ifndef __cplusplus
#error "This is not a C++ compiler"
#elif __cplusplus < 202002L
#error "This is not a C++20 compiler"
#else
#include <concepts>
#include <compare>
#include <vector>
#include <algorithm>
namespace cxx20
{
namespace test_concepts {
template<typename T>
concept Integral = std::is_integral<T>::value;
static_assert(Integral<int>, "int should be integral");
}
namespace test_ranges {
void f() {
std::vector<int> v = {5, 2, 4, 3, 1};
std::ranges::sort(v);
}
}
namespace test_spaceship {
struct A {
int value;
auto operator<=>(const A&) const = default;
};
int f() {
A a{1}, b{2};
return (a <=> b) == std::strong_ordering::less ? 0 : 1;
}
}
} // namespace cxx20
#endif // __cplusplus < 202002L
]])
4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ case $host in
lt_cv_deplibs_check_method="pass_all"
;;
esac
dnl Require C++17 compiler (no GNU extensions)
AX_CXX_COMPILE_STDCXX([17], [noext], [mandatory], [nodefault])
dnl Require C++20 compiler (no GNU extensions)
AX_CXX_COMPILE_STDCXX([20], [noext], [mandatory], [nodefault])
dnl Check if -latomic is required for <std::atomic>
CHECK_ATOMIC

Expand Down
4 changes: 2 additions & 2 deletions contrib/docker/builder/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:20.04
FROM ubuntu:24.04

# install required packages
RUN apt-get update && apt-get install -y software-properties-common
Expand All @@ -11,7 +11,7 @@ RUN apt-get update && apt-get install -y \
RUN update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix
RUN update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix

RUN pip3 install ez_setup
#RUN pip3 install ez_setup

# create user to use
RUN useradd -m -U firo-builder
Expand Down
2 changes: 1 addition & 1 deletion depends/packages/bdb.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ define $(package)_set_vars
$(package)_config_opts=--disable-shared --enable-cxx --disable-replication
$(package)_config_opts_mingw32=--enable-mingw
$(package)_config_opts_linux=--with-pic
$(package)_cxxflags=-std=c++11
$(package)_cxxflags=-std=c++20
$(package)_cc+=-Wno-error=implicit-function-declaration
endef

Expand Down
2 changes: 1 addition & 1 deletion depends/packages/boost.mk
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ else
$(package)_toolset_$(host_os)=gcc
endif
$(package)_config_libraries=chrono,filesystem,program_options,system,thread,test
$(package)_cxxflags+=-std=c++17
$(package)_cxxflags+=-std=c++20
$(package)_cxxflags_linux=-fPIC
$(package)_cxxflags_android=-fPIC
$(package)_cxxflags_x86_64_darwin=-fcf-protection=full
Expand Down
2 changes: 1 addition & 1 deletion depends/packages/qt.mk
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ $(package)_config_opts_release += -silent
$(package)_config_opts_debug = -debug
$(package)_config_opts_debug += -optimized-tools
$(package)_config_opts += -bindir $(build_prefix)/bin
$(package)_config_opts += -c++std c++17
$(package)_config_opts += -c++std c++2a
$(package)_config_opts += -confirm-license
$(package)_config_opts += -hostprefix $(build_prefix)
$(package)_config_opts += -no-compile-examples
Expand Down
2 changes: 1 addition & 1 deletion depends/packages/zeromq.mk
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ define $(package)_set_vars
$(package)_config_opts += --disable-Werror --disable-drafts --enable-option-checking
$(package)_config_opts_linux=--with-pic
$(package)_config_opts_android=--with-pic
$(package)_cxxflags=-std=c++17
$(package)_cxxflags=-std=c++20
endef

define $(package)_preprocess_cmds
Expand Down
30 changes: 29 additions & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ LIBBITCOIN_CLI=libbitcoin_cli.a
LIBBITCOIN_UTIL=libbitcoin_util.a
LIBLELANTUS=liblelantus.a
LIBSPARK=libspark.a
LIBSPATS=libspats.a
LIBBITCOIN_CRYPTO=crypto/libbitcoin_crypto.a
LIBBITCOINQT=qt/libfiroqt.a
LIBSECP256K1=secp256k1/libsecp256k1.la
Expand Down Expand Up @@ -90,7 +91,8 @@ EXTRA_LIBRARIES += \
$(LIBBITCOIN_ZMQ) \
$(LIBFIRO_SIGMA) \
$(LIBLELANTUS) \
$(LIBSPARK)
$(LIBSPARK) \
$(LIBSPATS)

lib_LTLIBRARIES = $(LIBBITCOINCONSENSUS)

Expand Down Expand Up @@ -119,6 +121,7 @@ BITCOIN_CORE_H = \
batchedlogger.h \
bloom.h \
blockencodings.h \
boost_function_epilogue.hpp \
chain.h \
chainparams.h \
chainparamsbase.h \
Expand Down Expand Up @@ -686,13 +689,37 @@ libspark_a_SOURCES = \
libspark/hash.cpp \
libspark/mint_transaction.h \
libspark/mint_transaction.cpp \
libspark/ownership_proof.h \
libspark/spend_transaction.h \
libspark/spend_transaction.cpp \
libspark/f4grumble.h \
libspark/f4grumble.cpp \
libspark/bech32.h \
libspark/bech32.cpp

libspats_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
libspats_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
libspats_a_SOURCES = \
libspats/bpplus.cpp \
libspats/bpplus.h \
libspats/bpplus_proof.h \
libspats/coin.cpp \
libspats/coin.h \
libspats/base_asset.h \
libspats/base_asset.cpp \
libspats/base_asset_proof.h \
libspats/type_proof.h \
libspats/type.cpp \
libspats/type.h \
libspats/balance.h \
libspats/balance.cpp \
libspats/balance_proof.h \
libspats/mint_transaction.cpp \
libspats/mint_transaction.h \
libspats/spend_transaction.cpp \
libspats/spend_transaction.h \
libspats/util.h

liblelantus_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
liblelantus_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
liblelantus_a_SOURCES = \
Expand Down Expand Up @@ -799,6 +826,7 @@ firod_LDADD = \
$(LIBFIRO_SIGMA) \
$(LIBLELANTUS) \
$(LIBSPARK) \
$(LIBSPATS) \
$(LIBBITCOIN_ZMQ) \
$(LIBBITCOIN_CONSENSUS) \
$(LIBBITCOIN_CRYPTO) \
Expand Down
4 changes: 4 additions & 0 deletions src/Makefile.qt.include
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ QT_FORMS_UI = \
qt/forms/editaddressdialog.ui \
qt/forms/helpmessagedialog.ui \
qt/forms/masternodelist.ui \
qt/forms/myownspats.ui \
qt/forms/intro.ui \
qt/forms/modaloverlay.ui \
qt/forms/recover.ui \
Expand Down Expand Up @@ -146,6 +147,7 @@ QT_MOC_CPP = \
qt/moc_macdockiconhandler.cpp \
qt/moc_macnotificationhandler.cpp \
qt/moc_masternodelist.cpp \
qt/moc_myownspats.cpp \
qt/moc_modaloverlay.cpp \
qt/moc_notificator.cpp \
qt/moc_openuridialog.cpp \
Expand Down Expand Up @@ -225,6 +227,7 @@ BITCOIN_QT_H = \
qt/macdockiconhandler.h \
qt/macnotificationhandler.h \
qt/masternodelist.h \
qt/myownspats.h \
qt/modaloverlay.h \
qt/networkstyle.h \
qt/notificator.h \
Expand Down Expand Up @@ -449,6 +452,7 @@ BITCOIN_QT_WALLET_CPP = \
qt/walletmodel.cpp \
qt/walletmodeltransaction.cpp \
qt/masternodelist.cpp \
qt/myownspats.cpp \
qt/walletview.cpp \
qt/lelantusmodel.cpp \
qt/lelantusdialog.cpp \
Expand Down
14 changes: 12 additions & 2 deletions src/Makefile.test.include
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ BITCOIN_TESTS = \
liblelantus/test/sigma_extended_test.cpp \
libspark/test/transcript_test.cpp \
libspark/test/schnorr_test.cpp \
libspark/test/ownership_test.cpp \
libspark/test/chaum_test.cpp \
libspark/test/bpplus_test.cpp \
libspark/test/grootle_test.cpp \
Expand Down Expand Up @@ -195,7 +196,15 @@ BITCOIN_TESTS = \
test/evo_deterministicmns_tests.cpp \
test/evo_simplifiedmns_tests.cpp \
test/progpow_tests.cpp \
test/bls_tests.cpp
test/bls_tests.cpp \
libspats/test/bpplus_test.cpp \
libspats/test/coin_test.cpp \
libspats/test/type_test.cpp \
libspats/test/base_asset_test.cpp \
libspats/test/mint_transaction_test.cpp \
libspats/test/spend_transaction_test.cpp \
libspats/test/balance_test.cpp


if ENABLE_WALLET
BITCOIN_TESTS += \
Expand All @@ -215,7 +224,7 @@ test_test_bitcoin_LDADD = $(LIBBITCOIN_SERVER) -ltor

test_test_bitcoin_SOURCES = $(BITCOIN_TESTS) $(JSON_TEST_FILES) $(RAW_TEST_FILES)
test_test_bitcoin_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) -I$(builddir)/test/ $(TESTDEFS) $(EVENT_CFLAGS)
test_test_bitcoin_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CONSENSUS) $(LIBBITCOIN_CRYPTO) $(LIBFIRO_SIGMA) $(LIBLELANTUS) $(LIBSPARK) $(LIBUNIVALUE) $(LIBLEVELDB) $(LIBMEMENV) \
test_test_bitcoin_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CONSENSUS) $(LIBBITCOIN_CRYPTO) $(LIBFIRO_SIGMA) $(LIBLELANTUS) $(LIBSPARK) $(LIBSPATS) $(LIBUNIVALUE) $(LIBLEVELDB) $(LIBMEMENV) \
$(BACKTRACE_LIB) $(BOOST_LIBS) $(BOOST_UNIT_TEST_FRAMEWORK_LIB) $(LIBSECP256K1) $(EVENT_PTHREADS_LIBS) $(ZMQ_LIBS) $(ZLIB_LIBS)
test_test_bitcoin_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
if ENABLE_WALLET
Expand Down Expand Up @@ -243,6 +252,7 @@ test_test_bitcoin_fuzzy_LDADD = \
$(LIBBITCOIN_SERVER) \
$(LIBLELANTUS) \
$(LIBSPARK) \
$(LIBSPATS) \
$(LIBBITCOIN_COMMON) \
$(LIBBITCOIN_UTIL) \
$(LIBBITCOIN_CONSENSUS) \
Expand Down
45 changes: 45 additions & 0 deletions src/boost_function_epilogue.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Boost.Function library

#ifndef BOOST_FUNCTION_EPILOGUE_HPP
#define BOOST_FUNCTION_EPILOGUE_HPP

#include <boost/function.hpp> // Added by Gevorg Voskanyan

#if BOOST_VERSION < 108200 // Added by Gevorg Voskanyan

// Copyright 2023 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt

// Resolve C++20 issue with fn == bind(...)
// https://github.com/boostorg/function/issues/45

#if !defined(BOOST_FUNCTION_NO_FUNCTION_TYPE_SYNTAX)

namespace boost
{

namespace _bi
{

template<class R, class F, class L> class bind_t;

} // namespace _bi

template<class S, class R, class F, class L> bool operator==( function<S> const& f, _bi::bind_t<R, F, L> const& b )
{
return f.contains( b );
}

template<class S, class R, class F, class L> bool operator!=( function<S> const& f, _bi::bind_t<R, F, L> const& b )
{
return !f.contains( b );
}

} // namespace boost

#endif // #if !defined(BOOST_FUNCTION_NO_FUNCTION_TYPE_SYNTAX)

#endif // BOOST_VERSION < 108200 // Added by Gevorg Voskanyan

#endif // #ifndef BOOST_FUNCTION_EPILOGUE_HPP
2 changes: 1 addition & 1 deletion src/libspark/coin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ bool Coin::validate(
// Recover a coin
RecoveredCoinData Coin::recover(const FullViewKey& full_view_key, const IdentifiedCoinData& data) {
RecoveredCoinData recovered_data;
recovered_data.s = SparkUtils::hash_ser(data.k, this->serial_context) + SparkUtils::hash_Q2(full_view_key.get_s1(), data.i) + full_view_key.get_s2();
recovered_data.s = SparkUtils::hash_ser(data.k, this->serial_context) + SparkUtils::hash_Q2(full_view_key.get_s1(), data.i) + full_view_key.get_s2();
recovered_data.T = (this->params->get_U() + full_view_key.get_D().inverse())*recovered_data.s.inverse();

return recovered_data;
Expand Down
2 changes: 1 addition & 1 deletion src/libspark/grootle.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Grootle {
const std::vector<GroupElement>& Hi,
const std::size_t n,
const std::size_t m
);
);

void prove(const std::size_t l,
const Scalar& s,
Expand Down
Loading

0 comments on commit 256fba2

Please sign in to comment.