Add BIP 352 bindings (full node scanning only)#876
Add BIP 352 bindings (full node scanning only)#876nymius wants to merge 7 commits intorust-bitcoin:masterfrom
Conversation
776653d to
76e17c5
Compare
|
In 1889342: Here you make various rust-secp types It looks like you do this so that you can cast vectors around. I'd suggest not doing this and just copying the vectors, manually converting the ffi objects into rust-secp ones. You can file a followup issue to attempt to eliminate this copying, though I'm not optimistic we'll find a solution. In 049e07f: How is |
I am not sure about this, is
Just wanted to add that this would not be a big deal, the Rust compiler often "sees through" this and makes it a pointer cast. Example: Converting between Vecs of 2 types that happen to have the same layout: https://rust.godbolt.org/z/9ahbsdr4x. Explicitly pointer casting is still more clear, not many people know that Rust has specialization behind the |
Yes.
No. |
Does this mean that other types that were already marked with |
Yep.
I think some of them are |
I've addressed this in the last changes, removing the
I have expanded on this in #878, proposing a fix in #879. To avoid mixing the base changes with requested changes, I didn't squash nor force pushed the changes, but I can do that once concerns are settled. Also, 049e07f is going to probably disappear once #879 is merged. |
|
I have updated to the latest state of libsecp256k1 PR so far, and adapted the rust code to the API changes. I've included these changes as separate commits to ease the review process. |
|
|
Need to update the lock files mate. You can do so by running |
Ouch, I always forgot this, thanks for the heads up! |
430b363 to
8095df2
Compare
8095df2 to
eadfa06
Compare
|
I have updated the lock files. As I had to force push all commits again, missing the per revision diff, I squashed the commits again. |
|
Not exactly sure what you mean by 'per revision diff'. So in case it helps, we use the stratergy that a PR is always a set of patches where each is a discreet change. Any review suggestions go in the original patch related to the suggestion. So we are constantly rebasing and force pushing. FTR that is why most of us have moved to |
|
@apoelstra is it useful to you if I review this. It would take me some time I think to get context enough to do so for anything other that just code review. |
|
In the light of the last changes in the libsecp PRs and possible changes of the spec, I will move this again to draft. |
eadfa06 to
d9ee45a
Compare
d9ee45a to
97c0765
Compare
97c0765 to
52c037b
Compare
This PR adds a silentpayments module based on bitcoin-core/secp256k1#1765.
I've agreed with @jlest01 on opening this PR replacing the old #721.
Commit 7888c66 contains all the changes from bitcoin-core/secp256k1#1765. I'm referencing my own version of the branch to be free of rebasing it in the future. These commits should refer back to master branch once bitcoin-core/secp256k1#1765 is merged.
049e07f is a workaround for a compilation issue I had. I cannot provide a confident answer about the reasons, but the old configuration was breaking the symbols of the library making linking impossible.
Commit 1889342 to 776653d contain all the main changes related to the BIP 352 module.
I've collected the feedback from #721 and applied it in this PR.
Beside the changes related to changes in bitcoin-core/secp256k1#1765 or the feedback provided in #721, I included the following:
I changed the old #721 manually implemented cache for a rust-like one, using
HashMaps. Now, thanks to the suggestion of @antonilol, you can pass a rust closure to the bindings, avoiding the implementation of unsafe extern C code.Note to the reviewers:
After looking at the different context related issues (#813), and mainly #844 (comment), I decided to apply this re-randomization step only where I had secrets related to UTXO unlocking. For context: in BIP 352 you have the scanning secret key, which is not directly associated with UTXO unlocking, that's what the spending key is for.
So I decided to implement something similar to
musig::new_nonce_pairforsilentpayments::sender::create_outputs, using the combination of secret as random seed.On the contrary, I didn't implement randomization for
silentpayments::sender::scan_outputsfor the reason explained above.I would like to know if the criteria applied here is correct or not.
To execute the test:
cargo test --features="silentpayments" -- full_silentpayment_flow_one_sender_two_receiversTo execute the example:
cargo run --example silentpayments --features="rand silentpayments"