Lightning: libsodium compile error

Created on 2 Mar 2019  Â·  2Comments  Â·  Source: ElementsProject/lightning

Issue and Steps to Reproduce

I'm using Ubuntu 16.04 LTS. I've tried to compile c-lightning v0.7.0, but it failed with the following errors:

common/cryptomsg.c: In function ‘le64_nonce’:
common/cryptomsg.c:87:25: error: ‘crypto_aead_chacha20poly1305_ietf_NPUBBYTES’ undeclared (first use in this function)
  const size_t zerolen = crypto_aead_chacha20poly1305_ietf_NPUBBYTES - sizeof(le_nonce);
                         ^
common/cryptomsg.c:87:25: note: each undeclared identifier is reported only once for each function it appears in
common/cryptomsg.c: In function ‘cryptomsg_decrypt_body’:
common/cryptomsg.c:98:21: error: ‘crypto_aead_chacha20poly1305_ietf_NPUBBYTES’ undeclared (first use in this function)
  unsigned char npub[crypto_aead_chacha20poly1305_ietf_NPUBBYTES];
                     ^
common/cryptomsg.c:98:16: error: unused variable ‘npub’ [-Werror=unused-variable]
  unsigned char npub[crypto_aead_chacha20poly1305_ietf_NPUBBYTES];
                ^
common/cryptomsg.c: In function ‘cryptomsg_decrypt_header’:
common/cryptomsg.c:132:21: error: ‘crypto_aead_chacha20poly1305_ietf_NPUBBYTES’ undeclared (first use in this function)
  unsigned char npub[crypto_aead_chacha20poly1305_ietf_NPUBBYTES];
                     ^
common/cryptomsg.c:132:16: error: unused variable ‘npub’ [-Werror=unused-variable]
  unsigned char npub[crypto_aead_chacha20poly1305_ietf_NPUBBYTES];
                ^
common/cryptomsg.c: In function ‘cryptomsg_encrypt_msg’:
common/cryptomsg.c:164:21: error: ‘crypto_aead_chacha20poly1305_ietf_NPUBBYTES’ undeclared (first use in this function)
  unsigned char npub[crypto_aead_chacha20poly1305_ietf_NPUBBYTES];
                     ^
common/cryptomsg.c:164:16: error: unused variable ‘npub’ [-Werror=unused-variable]
  unsigned char npub[crypto_aead_chacha20poly1305_ietf_NPUBBYTES];

I thought this is related to libsodium, so I checked it is surely installed:

$ sudo apt install libsodium-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
libsodium-dev is already the newest version (1.0.8-5).

The version number seems to be old.
I assume libsodium related includes may come from external/libsodium. Instead in my case they look like coming from /usr/include/sodium/. And there are some minor changes in some variables' name between libsodium versions.

It may be worth mentioning when I run ./configure I see this line: checking for libsodium with IETF chacha20 variants... yes.

A workaround

I don't know what went wrong, but only a few lines of code modification needed in the lightning source to fix it. I attach what I did to manage to compile.
libsodium.patch.txt
After that everything seems to work fine!

getinfo output

Everything Is AWESOME!!!

build

Most helpful comment

Ok, added a PR that checks for the case of the IETF acronym. In the meantime you can most likely just use the in-tree version by setting HAVE_GOOD_LIBSODIUM=0 in config.vars. This will cause us to ignore the system-installed libsodium and use the submodule in external/libsodium instead.

All 2 comments

Oh, it seems libsodium broke their public API due by change the case on the IETF acronym, well that's unfortunate.

Ok, added a PR that checks for the case of the IETF acronym. In the meantime you can most likely just use the in-tree version by setting HAVE_GOOD_LIBSODIUM=0 in config.vars. This will cause us to ignore the system-installed libsodium and use the submodule in external/libsodium instead.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SPIRY-RO picture SPIRY-RO  Â·  4Comments

ZmnSCPxj picture ZmnSCPxj  Â·  4Comments

mloop1 picture mloop1  Â·  4Comments

billygarrison picture billygarrison  Â·  3Comments

Christewart picture Christewart  Â·  3Comments