-
Notifications
You must be signed in to change notification settings - Fork 18
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
libsecp256k1 dep broken on Linux #8
Comments
Sorry for the delay. I completely agree and this dependency has been a thorn in my side for a while. Moving the manager to rebar, I believe, prevents us from publishing this on Hex, which I believe is why this is not done previously. The current workaround I have used is: export "CFLAGS=-I/usr/local/include -L/usr/local/lib"
cd deps/libsecp256k1 && rebar compile
mix compile But, none of this is acceptable as a long (or short term) solution. We currently use the Alternatively, we could pick up the libsecp256k1 library and proper bootstrap it into hex. Happy for your thoughts here, @tsutsu |
Would this need a patch to OTP? But yea also if you target windows you gotta compile libsecp256k1 for windows, the rebar file doesn't seem to indicate win as a target. |
Well, we would just implement the function in erlang/Elixir instead of relying on a native C library. It wouldn't be hard, but we need to make sure we get the math correct. This overflow question sums up the math which is straight-forward. There are a few nuances since there are up to 2 possible keys which could generate a message (hence the recovery bit). |
@hayesgm I think that decision comes down to how often libsecp256k1's Alternatively: if everything |
@tsutsu its not pure erlang, all the heavy lifting would be done in C via the crypto nif. The performance overhead will literary be exactly the same as it is now. To summarize now we are using the libsecp256k1 nif and this is proposing to start using the otp crypto nif. |
I was suggesting we build a native erlang version. The question is what the cost of the function is, but I am not sure it's exceedingly computationally expensive. For reference, ECDSA is called when processing an Ethereum transaction. I do not believe it's used via I agree it's best to have this upstreamed all the way to a native implementation that is exposed by erlang's |
@hayesgm it would make things so much simpler to maintain. Its worth a look. |
I did some digging: apparently OpenSSL does not expose ECDSA recover in any of its APIs. Additionally, there looks to be very little to no elliptic curve libraries currently implemented in erlang or Elixir. I would be happy to find another solution, but it looks like |
Hello, the fix that is proposed here, and what we've been using by setting in our project:
doesn't work anymore, because
What am I doing wrong? |
a late small test case to reproduce the above issue: mix.exs:
testtest.exs:
To reporoduce On Ubuntu 16.0 and
it gives:
whereas if I do
in |
@pdobacz I'm getting absolutely same issue. However,
... and exits without even cloning the library from github. Afterwards, if I run the tests, it outputs:
|
@pdobacz OMG, it worked after downgrading:
Final line in mix.exs:
(guess it has the same effect as yours) |
I think one needs to delete So yeah |
This is really an issue with exthereum/libsecp256k1, but issues are disabled there, so I'm filing it here.
It seems that the current Hex package release of
libsecp256k1
depended on by this package contains various precompiled object files (.o
,.so
,.a
,.dylib
,.la
,.lo
, etc.).It seems, as well, that this project is detected by Mix as being a
rebar3
project, despite only actually building properly usingrebar
.Because of these two factors, when
mix compile
ormix deps.compile
is run in a project that depends onlibsecp256k1
,libsecp256k1
won't actually be fully recompiled. The actual final NIF build artifact will be built, but it will be linked against the existing library.a
file rather than said file being rebuilt.This goes unnoticed when compiling on macOS, because the build artifacts in the Hex package are of macOS executable format, so the NIF build step will successfully link them.
However, when compiling on Linux, either the linking step will fail, or the linked NIF will fail to load.
Currently, I'm doing this in a
Dockerfile
I'm using as a workaround:Obviously, it'd be better to just publish a new release of the
libsecp256k1
Hex package that doesn't contain these build artifacts.As well, in order to properly build the dependent library (rather than just the build artifact), I believe
exth_crypto
needs to usemanager: :rebar
in its dep spec forlibsecp256k1
, as without thislibsecp256k1
is detected as arebar3
project for some reason, andrebar3
seems to ignorepre_hooks
andpost_hooks
. (Alternately,libsecp256k1
could be upgraded to be a properrebar3
project.)The text was updated successfully, but these errors were encountered: