libbitcoin / libbitcoin-system

Bitcoin Cross-Platform C++ Development Toolkit

Home Page:https://libbitcoin.info/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build problems with libsecp256k1 dependency (seckey =/= pubkey)

LEOcab opened this issue · comments

First of all thanks @pmienk for replying to my other post!

I resolved the latter issue in that thread as well, by making a new pkg-config file for libsecp256k1 and putting it in the proper directory. That got me past ./configure, but now it's make that's spitting errors after a few minutes of building:

src/crypto/secp256k1.cpp: In function 'bool libbitcoin::system::ec_add(ec_secret&, const ec_secret&)':
src/crypto/secp256k1.cpp:197:12: error: 'secp256k1_ec_seckey_tweak_add' was not declared in this scope; did you mean 'secp256k1_ec_pubkey_tweak_add'?
  197 |     return secp256k1_ec_seckey_tweak_add(context, left.data(),
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |            secp256k1_ec_pubkey_tweak_add
src/crypto/secp256k1.cpp: In function 'bool libbitcoin::system::ec_multiply(ec_secret&, const ec_secret&)':
src/crypto/secp256k1.cpp:249:12: error: 'secp256k1_ec_seckey_tweak_mul' was not declared in this scope; did you mean 'secp256k1_ec_pubkey_tweak_mul'?
  249 |     return secp256k1_ec_seckey_tweak_mul(context, left.data(),
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |            secp256k1_ec_pubkey_tweak_mul
src/crypto/secp256k1.cpp: In function 'bool libbitcoin::system::ec_negate(ec_secret&)':
src/crypto/secp256k1.cpp:260:12: error: 'secp256k1_ec_seckey_negate' was not declared in this scope; did you mean 'secp256k1_ec_pubkey_negate'?
  260 |     return secp256k1_ec_seckey_negate(context, scalar.data()) == ec_success;
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~
      |            secp256k1_ec_pubkey_negate
./include/bitcoin/system/impl/hash/sha/algorithm.ipp: In instantiation of 'static libbitcoin::system::sha::algorithm<SHA, Compressed, Vectorized, Cached, <anonymous> >::digests_t& libbitcoin::system::sha::algorithm<SHA, Compressed, Vectorized, Cached, <anonymous> >::merk
le_hash(digests_t&) [with SHA = libbitcoin::system::sha::h256<>; bool Compressed = true; bool Vectorized = true; bool Cached = true; typename std::enable_if<is_same_type<typename SHA::T, libbitcoin::system::sha::shah_t>, bool>::type <anonymous> = true; digests_t = std::v
ector<std::array<unsigned char, 32>, std::allocator<std::array<unsigned char, 32> > >]':
./include/bitcoin/system/impl/hash/sha/algorithm.ipp:1269:20:   required from 'static libbitcoin::system::sha::algorithm<SHA, Compressed, Vectorized, Cached, <anonymous> >::digest_t libbitcoin::system::sha::algorithm<SHA, Compressed, Vectorized, Cached, <anonymous> >::me
rkle_root(digests_t&&) [with SHA = libbitcoin::system::sha::h256<>; bool Compressed = true; bool Vectorized = true; bool Cached = true; typename std::enable_if<is_same_type<typename SHA::T, libbitcoin::system::sha::shah_t>, bool>::type <anonymous> = true; digest_t = std:
:array<unsigned char, 32>; digests_t = std::vector<std::array<unsigned char, 32>, std::allocator<std::array<unsigned char, 32> > >]'
./include/bitcoin/system/impl/hash/functions.ipp:189:31:   required from here
./include/bitcoin/system/impl/hash/sha/algorithm.ipp:1281:35: warning: 'std::is_constant_evaluated' always evaluates to false in a non-'constexpr' function [-Wtautological-compare]
 1281 |     if (std::is_constant_evaluated())
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~^~
make: *** [Makefile:4454: src/crypto/libbitcoin_system_la-secp256k1.lo] Error 1

Here's the pkg-config file I made for it:

prefix=/c/users/User/Downloads/secp256k1-master
exec_prefix=${prefix}
libdir=${exec_prefix}
includedir=${prefix}/include

Name: libsecp256k1
Description: ECDSA library for Bitcoin
Version: 0.1.0.20  # Probably not the actual version

Libs: -L${libdir} -lsecp256k1
Cflags: -I${includedir}

Because the error involves method names where the words "seckey" and "pubkey" are interchanged, something tells me there's a version mismatch somewhere, probably with libsecp256k1. libbitcoin is expecting a specific version of libsecp256k1 and it looks like the one I downloaded from this repo isn't actually 0.1.0.20. I don't see the version number anywhere. What version of libsecp256k1 does libbitcoin actually expect, and what's the libsecp256k1 version on the libbitcoin repo?

@LEOcab please attempt installation via the provided script. It will install the appropriate dependency with expected version. There should be no need for you to manually construct a pkgconfig registration if the dependency is properly installed.

If you insist on sidestepping the installer, please look to that script for the specific dependency information.

The version of secp256k1 is ambiguous in the original repository which has necessitated the libbitcoin/secp256k1 project which uses branches to isolate functionality changes in the underlying repository. The version branch depended upon varies by libbitcoin project version.

@pmienk Sorry, I forgot to mention install.sh and install-cmake.sh both fail with:

Unsupported system: MINGW64_NT-10.0-19045

There's no other way for me to get libsecp256k1 in Windows other than to build it from source, unless there's a way to bypass this requirement in the install scripts

I'm using the master branch libbitcoin-system. Where should I get the libsecp256k1 that works with it? I tried with both the master branch and the 0.1.0.20 branch and they both fail with the same error

The check for system is bypassed by defining PARALLEL in your environment or invoking like so:

PARALLEL=<number of threads for parallelization> ./install.sh <parameters>

However the environment specified has not been tested.

Assuming you're installing from master branch due to previous -std=c++20 issue, reference to secp256k1 repository and branch are found within the master install.sh script here - referencing secp256k1/version8

Please let me know if there's a convenient mechanism on your platform to detect parallelization and if everything works out I'd gladly add it to the script.