Comments (16)
@ShaliDaliHaliDa : You needed to add the GNU Multiple Precision Arithmetic Library to your build command. (via -lgmp)
Ex:
g++ -lgmp ../secp256k1/.libs/libsecp256k1.a main.cpp -o main
from secp256k1.
This is not a headers only library, you can't use it as such.
You'll need to build the library, and link it into your application (either statically or dynamically). How to do that depends on the platform. I'm afraid I can't help you with usage on Windows platforms.
from secp256k1.
@mrx23dot You need to call secp256k1_ec_pubkey_serialize
to convert it to a stable format, as explained in the API documentation in secp256k1.h. You cannot do anything with secp256k1_pubkey
objects other than passing them back to other libsecp256k1 functions, as there is no guarantee about its internal format (neither across platforms, or across versions of the library).
from secp256k1.
Did you already find the documentation in the header file? If you are familiar with C and with some of the binary formats used for ECDSA, it should probably be enough:
https://github.com/bitcoin/secp256k1/blob/master/include/secp256k1.h
You might also want to look at my usage examples here, though they are written in Ruby and they use a future version of the library's API (the one from pull request #208):
https://github.com/DavidEGrayson/secp256k1-rb
from secp256k1.
Keep in mind that this is currently an unreleased experimental library with a changing interfac. When it reaches a full release there will be better documentation. (DavidEGrayson's comments about the headers are the right advice now currently.)
from secp256k1.
Thanks for the info.Unfortunately getting a bunch of errors in Xcode when I try and use any of the mehtods. I have added reference to libsecp256k1.a , the include paths, and GMP is installed via brew yet looks like it can't find GMP ? ___gmpn_gcdext?
Is there a better compiler / IDE I should be using instead of Xcode? QT? Or Eclipse perhaps?
"___gmpn_gcdext", referenced from:
_secp256k1_num_mod_inverse in libsecp256k1.a(libsecp256k1_la-secp256k1.o)
"___gmpn_get_str", referenced from:
_secp256k1_num_get_bin in libsecp256k1.a(libsecp256k1_la-secp256k1.o)
"___gmpn_set_str", referenced from:
_secp256k1_ecdsa_recover_compact in libsecp256k1.a(libsecp256k1_la-secp256k1.o)
_secp256k1_scalar_inverse_var in libsecp256k1.a(libsecp256k1_la-secp256k1.o)
_secp256k1_ge_set_all_gej_var in libsecp256k1.a(libsecp256k1_la-secp256k1.o)
"___gmpn_sub_n", referenced from:
_secp256k1_num_mod_inverse in libsecp256k1.a(libsecp256k1_la-secp256k1.o)
ld: symbol(s) not found for architecture x86_64
from secp256k1.
And how do I compile in the library as part of my project? (not as shared library)
The library has many main() functions.
Is there a simplified version? It seems to be huge.
from secp256k1.
And how do I compile in the library as part of my project? (not as shared library) The library has many main() functions. Is there a simplified version? It seems to be huge.
Depending on the build system of your project, but the best way would probably be to invoke the autogen.sh
then run ./configure
with whatever flags you need (schnorr/ecdh etc.) and then run the makefile via make
and link to the resulting libsecp256k1.a
from secp256k1.
I mean compile secp256k1.c into my exe. I tried it but it gives seg fault on context creation.
from secp256k1.
I mean compile secp256k1.c into my exe. I tried it but it gives seg fault on context creation.
That's exactly what I've talked about, you should compile libsecp256k1
as a library and then link to it.
Sounds like it is windows which I know nothing about, but maybe whatever bitcoin core is doing can help you: https://github.com/bitcoin/bitcoin/blob/master/build_msvc/libsecp256k1/libsecp256k1.vcxproj
from secp256k1.
Ok, so it wasn't designed to be used without linking in as a static library (.a) aka not as a black-box.
from secp256k1.
Ok, so it wasn't designed to be used without linking in as a static library (.a) aka not as a black-box.
I don't know what a "black box" means in the context of a library. But this is not a "header only library" and as such it needs to be compiled and linked (shared/static),
We are trying to make this library compile more easily with a one line compiler call, but it's still ongoing, See #929
from secp256k1.
Ok so how can I use it as a "header only" library?
Linking it in two steps doesn't change a thing.
gcc mymain.c secp256k1.c
Does it require some init code before I can call context init? Because it gave me segfault.
As I saw the lib itself has main function.
from secp256k1.
Could you explain how is it possible that all of these files have main() entry points and compile into .a object?
precompute_ecmult.c
precompute_ecmult_gen.c
bench.c
I would assume linker would complain for anything anything more than one main, which would come from post linking with user app. I'm on linux.
from secp256k1.
Those are separate executables that are part of the project, but are not part of the library.
The library itself is compiled from secp256k1.c, plus a few other files with assembly and precomputed tables.
from secp256k1.
I manage to build it as intended, copied over generated files, it compiles, give correct result.
Weirdly secp256k1_ec_pubkey_create returns the public key (generated from private key)
x_mirrored + y_mirrored byte array, which won't work for the next sha256+RIPE160 step.
How do you develop/debug this lib with dbg?
Is there an entry point for it? Or a script that prepares it for running by it's own?
from secp256k1.
Related Issues (20)
- group: ge(j) should have as invariant that the curve equation holds HOT 3
- Remove `SECP256K1_WARN_UNUSED_RESULT` from `secp256k1_keypair_*` functions HOT 3
- Policy for VERIFY_CHECK and #ifdef VERIFY HOT 5
- ci: Add a "compile the headers" job
- ci: Add a constant-time test job that uses MSan HOT 2
- ci: Future of CI after Cirrus pricing change HOT 37
- mingw-w64: "visibility attribute not supported in this configuration; ignored" under `-flto` HOT 5
- Silent Payments (BIP352) module -- discussion about scope and interface HOT 2
- Compile with: --with-ecmult-window=24 --with-ecmult-gen-precision=8
- ARM assembly: "missing .note.GNU-stack section implies executable stack" with recent ld
- ci: Random Valgrind MacOS build failures HOT 3
- Error: undefined symbol: secp256k1_ecdsa_recoverable_signature_parse_compact HOT 1
- Prefix all macros with SECP256K1_
- Add MuSig2 module HOT 6
- secp256k1_fe_set_b32_mod doesn't actually reduce anything HOT 4
- No implementation found HOT 2
- Add bitcoin as a topic to this repository HOT 1
- fe_sqr tests could be improved HOT 5
- docs: "pointer to context object" vs "context object"
- tests: Tidy the util functions HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from secp256k1.