BlockstreamResearch / rust-secp256k1-zkp

Creative Commons Zero v1.0 Universal
31 stars 38 forks source link

question: How to correctly add the MuSig module to this project? #72

Open ssantos21 opened 1 year ago

ssantos21 commented 1 year ago

I would like to add the MuSig module to this project to use it in Rust.

Is there a workflow document on how to do this?

Anyway, I'm running ./vendor-libsecp.sh without specifying the rev and it says 2 of 4 hunks FAILED. What does it mean and how to fix it?

$ ./vendor-libsecp.sh
Using version code 0_8_1. Set SECP_VENDOR_VERSION_CODE to override.
Using depend directory /home/user/Dev/rust-secp256k1-zkp/secp256k1-zkp-sys/depend. Set SECP_VENDOR_DEPEND_DIR to override.
Using secp repository https://github.com/ElementsProject/secp256k1-zkp.git. Set SECP_VENDOR_SECP_REPO to override.
WARNING: No secp256k1 revision specified. Will use whatever we find at the git repo.

Cloning into './secp256k1'...
remote: Enumerating objects: 14089, done.
remote: Counting objects: 100% (14087/14087), done.
remote: Compressing objects: 100% (3643/3643), done.
remote: Total 14089 (delta 10380), reused 13928 (delta 10317), pack-reused 2
Receiving objects: 100% (14089/14089), 10.06 MiB | 25.62 MiB/s, done.
Resolving deltas: 100% (10380/10380), done.
~/Dev/rust-secp256k1-zkp/secp256k1-zkp-sys/depend ~/Dev/rust-secp256k1-zkp/secp256k1-zkp-sys
patching file ./secp256k1/include/secp256k1.h
Reversed (or previously applied) patch detected!  Assume -R? [n] y
patching file ./secp256k1/src/secp256k1.c
Hunk #1 succeeded at 161 (offset 22 lines).
Hunk #2 FAILED at 153.
Hunk #3 FAILED at 172.
Hunk #4 succeeded at 230 (offset 35 lines).
2 out of 4 hunks FAILED -- saving rejects to file ./secp256k1/src/secp256k1.c.rej
ssantos21 commented 1 year ago

I noticed that the *.patch files were out of date. I updated them as per secp256k1-zkp master branch and it worked.

apoelstra commented 1 year ago

Is there a workflow document on how to do this?

Afraid not. We probably ought to have a workflow document upstream in rust-secp256k1, though we introduce new modules there extremely infrequently. This library has had a fair bit of friction with rust-secp256k1 (we've tried to make the context objects compatible even though they come from different C libraries, which is neither fun nor safe..) so we've been doing a lot of iteration on that in parallel to adding new features, which makes all of our "processes" pretty messy and ad-hoc.

In the specific case of MuSig I think we are planning to move that (or have already moved it) from libsecp256k1-zkp to libsecp256k1, so it would be better to add musig support to rust-secp rather than here. We still don't have a process document but rust-secp is a much more mature library and we'd be happy to help guide you. And "just copy one of the existing modules" should be a good a approach.

I updated them as per secp256k1-zkp master branch and it worked.

Thank you!