Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amalgamation updates #472

Merged
merged 6 commits into from
Jan 6, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
amalgamation: make the source amalgamation a single file
Use the preprocessor to redefine internal ccan symbols so that only a
single source file is needed to include the whole library.

Also standardizes the source includes which were inexplicably different.
jgriffiths committed Jan 4, 2025

Verified

This commit was signed with the committer’s verified signature.
commit 9d1263ccd2d402e9997221219c9d40bf8253550d
4 changes: 1 addition & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -128,9 +128,7 @@ def _call(args, cwd=ABS_PATH):
'./src/secp256k1/include',
]
sources += [
'src/amalgamation/combined.c',
'src/amalgamation/combined_ccan.c',
'src/amalgamation/combined_ccan2.c',
'src/amalgamation/combined.c'
]
else:
# Compile the swig python wrapper file and link it with wally/secp
94 changes: 63 additions & 31 deletions src/amalgamation/combined.c
Original file line number Diff line number Diff line change
@@ -33,38 +33,70 @@
#include "src/secp256k1/src/secp256k1.c"
#include "src/secp256k1/src/precomputed_ecmult_gen.c"
#include "src/secp256k1/src/precomputed_ecmult.c"
#include "ccan/ccan/crypto/sha256/sha256.c"
#include "src/ccan/ccan/crypto/sha256/sha256.c"

#include "internal.c"
#include "address.c"
#include "aes.c"
#include "anti_exfil.c"
#include "base_58.c"
#include "base_64.c"
#include "bech32.c"
#include "blech32.c"
#include "bip32.c"
#include "bip38.c"
#include "bip39.c"
#include "bip85.c"
#include "coins.c"
#include "descriptor.c"
#include "ecdh.c"
#include "elements.c"
#include "hex_.c"
#include "hmac.c"
#include "map.c"
#include "mnemonic.c"
#include "pbkdf2.c"
#include "pullpush.c"
#include "psbt.c"
#include "script.c"
#include "scrypt.c"
#include "sign.c"
#include "symmetric.c"
#include "transaction.c"
#include "wif.c"
#include "wordlist.c"
#include "src/internal.c"
#include "src/address.c"
#include "src/aes.c"
#include "src/anti_exfil.c"
#include "src/base_58.c"
#include "src/base_64.c"
#include "src/bech32.c"
#include "src/blech32.c"
#include "src/bip32.c"
#include "src/bip38.c"
#include "src/bip39.c"
#include "src/bip85.c"
#include "src/coins.c"
#include "src/descriptor.c"
#include "src/ecdh.c"
#include "src/elements.c"
#include "src/hex_.c"
#include "src/hmac.c"
#include "src/map.c"
#include "src/mnemonic.c"
#include "src/pbkdf2.c"
#include "src/pullpush.c"
#include "src/psbt.c"
#include "src/script.c"
#include "src/scrypt.c"
#include "src/sign.c"
#include "src/symmetric.c"
#include "src/transaction.c"
#include "src/wif.c"
#include "src/wordlist.c"

/* Redefine internal names so sha-512 can be included without conflicts */
#define Round Round_512
#define Transform Transform_512
#define Maj Maj_512
#define Sigma0 Sigma0_512
#define sigma0 sigma0_512
#define Sigma1 Sigma1_512
#define sigma1 sigma1_512
#define add add_512
#define Ch Ch_512
#include "src/ccan/ccan/crypto/sha512/sha512.c"
#undef Round
#undef Transform
#undef Sigma0
#undef sigma0
#undef sigma1
#undef Sigma1
#undef add
#undef Maj
#undef Ch
#include "src/ccan/ccan/str/hex/hex.c"

/* Redefine internal names so ripemd-160 can be included without conflicts */
#define Transform Transform_ripemd160
#define add add_ripemd160
#define Round Round_ripemd160
#include "src/ccan/ccan/crypto/ripemd160/ripemd160.c"
#undef Transform
#undef add
#undef Round
#include "src/ccan/ccan/base64/base64.c"

void wally_silence_unused_warnings(void)
{
4 changes: 0 additions & 4 deletions src/amalgamation/combined_ccan.c

This file was deleted.

3 changes: 0 additions & 3 deletions src/amalgamation/combined_ccan2.c

This file was deleted.

2 changes: 1 addition & 1 deletion tools/msvc/build.bat
Original file line number Diff line number Diff line change
@@ -7,4 +7,4 @@ if "%ELEMENTS_BUILD%" == "elements" (
)

REM Compile everything (wally, ccan, libsecp256k) in one lump.
cl /utf-8 /DWALLY_CORE_BUILD %OPTS% /I%LIBWALLY_DIR% /I%LIBWALLY_DIR%\src /I%LIBWALLY_DIR%\include /I%LIBWALLY_DIR%\src\ccan /I%LIBWALLY_DIR%\src\ccan\base64 /I%LIBWALLY_DIR%\src\secp256k1 /Zi /LD src/amalgamation/combined.c src/amalgamation/combined_ccan.c src/amalgamation/combined_ccan2.c /Fewally.dll
cl /utf-8 /DWALLY_CORE_BUILD %OPTS% /I%LIBWALLY_DIR% /I%LIBWALLY_DIR%\src /I%LIBWALLY_DIR%\include /I%LIBWALLY_DIR%\src\ccan /I%LIBWALLY_DIR%\src\ccan\base64 /I%LIBWALLY_DIR%\src\secp256k1 /Zi /LD src/amalgamation/combined.c /Fewally.dll