relic-toolkit / relic

Code
Other
455 stars 179 forks source link

Function name bn_init conflicts with OpenSSL when used in tandem #196

Closed kwvg closed 3 years ago

kwvg commented 3 years ago

Issue

A project I'm working on relies on https://github.com/Chia-Network/bls-signatures, which in turn relies on the Relic Toolkit.

For reasons outside of my control the root project requires functionality provided by OpenSSL 1.1.1i onwards, which in turn makes calls to bn_init, which conflicts with relic's bn_init call that is made by bls-signatures.

We are crudely trying to rename the functions "on the fly" for now but it's messy

Error Information

/usr/bin/ld: /home/kitty/[redacted]/depends/x86_64-pc-linux-gnu/share/../lib/libchiabls.a(relic_bn_mem.c.o): in function `bn_init':
relic_bn_mem.c:(.text+0x0): multiple definition of `bn_init'; /home/kitty/[redacted]/depends/x86_64-pc-linux-gnu/share/../lib/libcrypto.a(bn_lib.o):bn_lib.c:(.text+0x190): first defined here

$ uname -r
5.9.0-050900-generic

Proposed solution

Renaming bn_init to rbn_init or any other appropriate phrase that doesn't conflict with OpenSSL

dfaranha commented 3 years ago

Thanks for the notification!

This is an internal function, so it should not be a problem renaming to something else. I just pushed a commit renaming it to bn_make.

Note that RELIC has a (slightly messy) way of defining a custom library prefix, by setting the LABEL config variable, although I don't know if that breaks the Chia BLS library somehow.

hoffmang9 commented 3 years ago

I kicked off the bls-signature nightly early on 69c51954c3ce458fc6ede3dca6d2e53817e38f6b and the build failed.

The failure is bn_init related - https://github.com/Chia-Network/bls-signatures/runs/2398886577?check_suite_focus=true#step:4:1330

dfaranha commented 3 years ago

That single occurrence in privatekey.cpp needs to be renamed to bn_make, I will do a PR to look a bit deeper why it's needed there.

hoffmang9 commented 3 years ago

I think we are doing that to prep the alloc for being secured by libsodium but I'm pretty sure @mariano54 wrote that.

dfaranha commented 3 years ago

I see. There are some other conflicts with main I will take a shot at fixing then.

dfaranha commented 3 years ago

Done! The fixes live at https://github.com/Chia-Network/bls-signatures/pull/207