Skip to content
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

Schnorr stuff is based on old secp256k1 #1

Closed
ysangkok opened this issue Feb 13, 2022 · 5 comments
Closed

Schnorr stuff is based on old secp256k1 #1

ysangkok opened this issue Feb 13, 2022 · 5 comments
Labels
help wanted Extra attention is needed

Comments

@ysangkok
Copy link

As you can see from the PR, the schnorr bindings were made against the BIP340 spec as it was around March 2020. The spec and implementation were since changed, some symbols probably have different names, that's why you got linking errors. To make it work, you should diff the commit mentioned in the PR with the upstream secp256k1 that you want this library to target. Then you can know how to adjust the bindings.

@prolic
Copy link
Owner

prolic commented Feb 13, 2022

Thank you very much @ysangkok
I will try to work further on this tomorrow.

@prolic
Copy link
Owner

prolic commented Feb 18, 2022

@ysangkok I hope you can help me out a bit.

when running "stack test" I receive this output:

Linking .stack-work/dist/x86_64-linux-tinfo6/Cabal-3.2.1.0/build/spec/spec ...
/home/sasa/code/secp256k1-schnorr/.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.2.1.0/build/libHSsecp256k1-schnorr-0.0.1-5vEVrcdlMg8E6qf3nbjOqc.a(Schnorr.o):function secp256k1zmschnorrzm0zi0zi1zm5vEVrcdlMg8E6qf3nbjOqc_CryptoziSchnorr_zdwverifyMsgSchnorr_info: error: undefined reference to 'secp256k1_schnorrsig_verify'
/home/sasa/code/secp256k1-schnorr/.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.2.1.0/build/libHSsecp256k1-schnorr-0.0.1-5vEVrcdlMg8E6qf3nbjOqc.a(Schnorr.o):function secp256k1zmschnorrzm0zi0zi1zm5vEVrcdlMg8E6qf3nbjOqc_CryptoziSchnorr_zdwsignMsgSchnorr_info: error: undefined reference to 'secp256k1_schnorrsig_sign'
/home/sasa/code/secp256k1-schnorr/.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.2.1.0/build/libHSsecp256k1-schnorr-0.0.1-5vEVrcdlMg8E6qf3nbjOqc.a(Schnorr.o):function secp256k1zmschnorrzm0zi0zi1zm5vEVrcdlMg8E6qf3nbjOqc_CryptoziSchnorr_zdwimportXOnlyPubKey_info: error: undefined reference to 'secp256k1_xonly_pubkey_parse'
/home/sasa/code/secp256k1-schnorr/.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.2.1.0/build/libHSsecp256k1-schnorr-0.0.1-5vEVrcdlMg8E6qf3nbjOqc.a(Internal.o)(.text+0xa8f): error: undefined reference to 'secp256k1_schnorrsig_sign'
/home/sasa/code/secp256k1-schnorr/.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.2.1.0/build/libHSsecp256k1-schnorr-0.0.1-5vEVrcdlMg8E6qf3nbjOqc.a(Internal.o)(.text+0xe39): error: undefined reference to 'secp256k1_xonly_pubkey_serialize'
/home/sasa/code/secp256k1-schnorr/.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.2.1.0/build/libHSsecp256k1-schnorr-0.0.1-5vEVrcdlMg8E6qf3nbjOqc.a(Internal.o)(.text+0x10a7): error: undefined reference to 'secp256k1_schnorrsig_verify'
/home/sasa/code/secp256k1-schnorr/.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.2.1.0/build/libHSsecp256k1-schnorr-0.0.1-5vEVrcdlMg8E6qf3nbjOqc.a(Internal.o)(.text+0x12d9): error: undefined reference to 'secp256k1_xonly_pubkey_parse'
collect2: error: ld returned 1 exit status
`gcc' failed in phase `Linker'. (Exit code: 1)

However "stack build" works just fine.

the "tests" part of my package.yaml file is this:

tests:
  spec:
    main: Spec.hs
    source-dirs: test
    pkg-config-dependencies:
      - libsecp256k1
    ghc-options:
      - -threaded
      - -rtsopts
      - -with-rtsopts=-N
      - -lsecp256k1
    verbatim:
      build-tool-depends:
          hspec-discover:hspec-discover
    dependencies:
      - hspec
      - secp256k1-schnorr
      - mtl
      - HUnit
    extra-lib-dirs:
      - /usr/local/lib

As you can see, I added extra-lib-dirs (I compiled secp256k1 from source), however the linker doesn't seem to find it.

Any suggestions on how to solve this? Thanks in advance.

@prolic
Copy link
Owner

prolic commented Feb 19, 2022

when compiling from source, you need to add the extra flags ./configure --enable-module-schnorrsig --enable-module-extrakeys --enable-module-ecdh --enable-experimental, then compiling works just fine.

@ysangkok
Copy link
Author

Ensure that you don't have an old version of libsecp256k1 laying around. I don't wanna investigate more, since I don't work in cryptocurrency any more and I think it is already a disproportionate part of the Haskell ecosystem.

@prolic
Copy link
Owner

prolic commented Feb 22, 2022

This is not for some cryptocurrency shitcoin. Anyway, thanks for your hints @ysangkok.

@prolic prolic closed this as completed Feb 22, 2022
@prolic prolic added the help wanted Extra attention is needed label Feb 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants