Skip to content

Commit

Permalink
Merge pull request #168 from gogoex/add-blsct-api
Browse files Browse the repository at this point in the history
Add blsct api
  • Loading branch information
aguycalled authored Oct 20, 2024
2 parents 5d905a3 + 339df7c commit 5a1cb60
Show file tree
Hide file tree
Showing 22 changed files with 2,282 additions and 323 deletions.
7 changes: 3 additions & 4 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,9 @@ compute_credits_template: &CREDITS_TEMPLATE
task:
name: 'lint'
<< : *BASE_TEMPLATE
container:
image: debian:bookworm
cpu: 1
memory: 1G
persistent_worker:
labels:
type: small
# For faster CI feedback, immediately schedule the linters
<< : *CREDITS_TEMPLATE
test_runner_cache:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,4 @@ compile_commands.json

# others
null.d
libnavioconsensus.pc
2 changes: 1 addition & 1 deletion doc/bech32-mod-gen-poly.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ We made modification to bech32 implementation of Bitcoin so that it worked with

To accomplish that, we replaced the 6-degree generator polynomial originally used by bech32 by an 8-degree one as [Bitcoin Cash's cashaddr implementation](https://github.com/bitcoin-cash-node/bitcoin-cash-node/blob/master/src/cashaddr.cpp) and [Jamtis](https://gist.github.com/tevador/50160d160d24cfc6c52ae02eb3d17024) of Monero have done.

In order to find an 8-degree polynomial for our need, we followed the Jamtis polynomial search procedure which is explained in detail in [this document](https://gist.github.com/tevador/5b3fbbd0877a3412ede07263c6b2663d) with a little modificaiton to meet our requirements.
In order to find an 8-degree polynomial for our need, we followed the Jamtis polynomial search procedure which is explained in detail in [this document](https://gist.github.com/tevador/5b3fbbd0877a3412ede07263c6b2663d) with a little modification to meet our requirements.

Here are the requirements we had:

Expand Down
71 changes: 66 additions & 5 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ BENCHMARKS =

BLS_INCLUDES=-I$(srcdir)/bls/include -I$(srcdir)/bls/mcl/include -I$(srcdir)/bls/mcl/src

BITCOIN_INCLUDES=-I$(builddir) -I$(srcdir)/$(MINISKETCH_INCLUDE_DIR_INT) -I$(srcdir)/secp256k1/include $(BLS_INCLUDES) -I$(srcdir)/$(UNIVALUE_INCLUDE_DIR_INT)
BITCOIN_INCLUDES=-I$(builddir) -I$(srcdir)/$(MINISKETCH_INCLUDE_DIR_INT) -I$(srcdir)/secp256k1/include $(BLS_INCLUDES) -I$(srcdir)/$(UNIVALUE_INCLUDE_DIR_INT) -I$(srcdir)/blsct/external_api

LIBBITCOIN_NODE=libbitcoin_node.a
LIBBITCOIN_COMMON=libbitcoin_common.a
Expand Down Expand Up @@ -169,6 +169,7 @@ BLSCT_H = \
blsct/double_public_key.h \
blsct/eip_2333/bls12_381_keygen.h \
blsct/external_api/blsct.h \
blsct/key_io.h \
blsct/private_key.h \
blsct/public_key.h \
blsct/public_keys.h \
Expand Down Expand Up @@ -204,13 +205,15 @@ BLSCT_H = \
blsct/wallet/keyman.h \
blsct/wallet/keyring.h \
blsct/wallet/txfactory.h \
blsct/wallet/txfactory_base.h \
blsct/wallet/txfactory_global.h \
blsct/wallet/verification.h

BLSCT_CPP = \
blsct/arith/elements.cpp \
blsct/arith/mcl/mcl_g1point.cpp \
blsct/arith/mcl/mcl_scalar.cpp \
blsct/bech32_mod.cpp \
blsct/building_block/g_h_gi_hi_zero_verifier.cpp \
blsct/building_block/generator_deriver.cpp \
blsct/building_block/imp_inner_prod_arg.cpp \
Expand All @@ -221,6 +224,7 @@ BLSCT_CPP = \
blsct/double_public_key.cpp \
blsct/eip_2333/bls12_381_keygen.cpp \
blsct/external_api/blsct.cpp \
blsct/key_io.cpp \
blsct/pos/helpers.cpp \
blsct/pos/pos.cpp \
blsct/pos/proof_logic.cpp \
Expand All @@ -247,9 +251,15 @@ BLSCT_CPP = \
blsct/set_mem_proof/set_mem_proof_prover.cpp \
blsct/set_mem_proof/set_mem_proof_setup.cpp \
blsct/signature.cpp \
blsct/wallet/address.cpp \
blsct/wallet/helpers.cpp \
blsct/wallet/keyman.cpp \
blsct/wallet/keyring.cpp \
blsct/wallet/txfactory.cpp \
blsct/wallet/txfactory_base.cpp \
blsct/wallet/txfactory_global.cpp \
blsct/wallet/verification.cpp


.PHONY: FORCE check-symbols check-security
# navio core #
BITCOIN_CORE_H = \
Expand Down Expand Up @@ -717,6 +727,7 @@ libbitcoin_wallet_a_SOURCES = \
blsct/wallet/keyman.cpp \
blsct/wallet/keyring.cpp \
blsct/wallet/txfactory.cpp \
blsct/wallet/txfactory_base.cpp \
blsct/wallet/txfactory_global.cpp \
blsct/wallet/verification.cpp \
wallet/coincontrol.cpp \
Expand Down Expand Up @@ -933,6 +944,7 @@ libbitcoin_common_a_SOURCES = \
blsct/building_block/weighted_inner_prod_arg.cpp \
blsct/common.cpp \
blsct/double_public_key.cpp \
blsct/key_io.cpp \
blsct/private_key.cpp \
blsct/public_key.cpp \
blsct/public_keys.cpp \
Expand Down Expand Up @@ -1423,16 +1435,65 @@ if BUILD_LIBBLSCT_ONLY
LIBBLSCT = libblsct.a
noinst_LIBRARIES = $(LIBBLSCT)
libblsct_a_SOURCES = \
blsct/external_api/blsct.cpp \
common/args.cpp \
common/system.cpp \
common/url.cpp \
crypto/hmac_sha256.cpp \
crypto/ripemd160.cpp \
crypto/sha256_arm_shani.cpp \
crypto/sha256_avx2.cpp \
crypto/sha256_sse4.cpp \
crypto/sha256_sse41.cpp \
crypto/sha256_x86_shani.cpp \
crypto/sha256.cpp \
blsct/external_api/blsct.cpp \
primitives/transaction.cpp \
rpc/util.cpp \
script/interpreter.cpp \
script/script.cpp \
script/sign.cpp \
script/signingprovider.cpp \
support/cleanse.cpp \
support/lockedpool.cpp \
uint256.cpp \
util/rbf.cpp \
util/strencodings.cpp \
wallet/coincontrol.cpp \
wallet/context.cpp \
wallet/crypter.cpp \
wallet/db.cpp \
wallet/dump.cpp \
wallet/external_signer_scriptpubkeyman.cpp \
wallet/feebumper.cpp \
wallet/fees.cpp \
wallet/interfaces.cpp \
wallet/load.cpp \
wallet/receive.cpp \
wallet/rpc/addresses.cpp \
wallet/rpc/backup.cpp \
wallet/rpc/coins.cpp \
wallet/rpc/encrypt.cpp \
wallet/rpc/spend.cpp \
wallet/rpc/signmessage.cpp \
wallet/rpc/transactions.cpp \
wallet/rpc/util.cpp \
wallet/rpc/wallet.cpp \
wallet/scriptpubkeyman.cpp \
wallet/spend.cpp \
wallet/transaction.cpp \
wallet/wallet.cpp \
wallet/walletdb.cpp \
wallet/walletutil.cpp \
wallet/coinselection.cpp \
$(BLSCT_CPP)

LIBUNIVALUE_BLSCT = libunivalue_blsct.a
noinst_LIBRARIES += $(LIBUNIVALUE_BLSCT)
libunivalue_blsct_a_SOURCES = $(UNIVALUE_LIB_SOURCES_INT) $(UNIVALUE_DIST_HEADERS_INT) $(UNIVALUE_LIB_HEADERS_INT) $(UNIVALUE_TEST_FILES_INT)
libunivalue_blsct_a_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/$(UNIVALUE_INCLUDE_DIR_INT)

libblsct_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
libblsct_a_CPPFLAGS = $(AM_CPPFLAGS) $(BLS_INCLUDES) $(BOOST_CPPFLAGS)
libblsct_a_CPPFLAGS = $(AM_CPPFLAGS) $(BLS_INCLUDES) $(BOOST_CPPFLAGS) -I$(srcdir)/$(UNIVALUE_INCLUDE_DIR_INT)

if ENABLE_SSE41
libblsct_a_CXXFLAGS += $(SSE41_CXXFLAGS)
Expand All @@ -1454,7 +1515,7 @@ libblsct_a_CXXFLAGS += $(ARM_SHANI_CXXFLAGS)
libblsct_a_CPPFLAGS += -DENABLE_ARM_SHANI
endif

$(LIBBLSCT): $(LIBBLS) $(LIBMCL)
$(LIBBLSCT): $(LIBBLS) $(LIBMCL) $(LIBUNIVALUE_BLSCT)

CLEANFILES += $(LIBBLSCT) blsct/include/libblsct_a-blsct.o
endif
Expand Down
2 changes: 2 additions & 0 deletions src/blsct/arith/mcl/mcl.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#define NAVIO_BLSCT_ARITH_MCL_MCL_H

#include <blsct/arith/mcl/mcl_g1point.h>
#include <blsct/arith/mcl/mcl_init.h>
#include <blsct/arith/mcl/mcl_scalar.h>
#include <blsct/arith/mcl/mcl_util.h>

Expand All @@ -21,6 +22,7 @@ struct Mcl {
using Scalar = MclScalar;
using Point = MclG1Point;
using Util = MclUtil;
using Init = MclInit;
};

#endif // NAVIO_BLSCT_ARITH_MCL_MCL_H
Loading

0 comments on commit 5a1cb60

Please sign in to comment.