-
Notifications
You must be signed in to change notification settings - Fork 380
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
Update rust-bitcoin and add secp256k1 context randomization #802
Update rust-bitcoin and add secp256k1 context randomization #802
Conversation
Also added a wasm32-wasi bindings build for good measure (since we need the update to do it). |
5a166a1
to
e81fab9
Compare
Codecov Report
@@ Coverage Diff @@
## main #802 +/- ##
==========================================
- Coverage 91.04% 91.02% -0.02%
==========================================
Files 48 48
Lines 25480 25492 +12
==========================================
+ Hits 23199 23205 +6
- Misses 2281 2287 +6
Continue to review full report at Codecov.
|
a5cb963
to
85dcb52
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking care of this! Nice bite-sized commits + good to squeeze in the side channel attack mitigation.
Edit: fine to approve once CI is fixed
@@ -219,7 +219,7 @@ impl msgs::ChannelUpdate { | |||
use bitcoin::secp256k1::ffi::Signature as FFISignature; | |||
use bitcoin::secp256k1::Signature; | |||
msgs::ChannelUpdate { | |||
signature: Signature::from(FFISignature::new()), | |||
signature: Signature::from(unsafe { FFISignature::new() }), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OOC, do you know why secp256k1:;Signature
was suddenly made unsafe
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not 100% sure, but it does allow you to create an obviously-bogus Signature
object which generally you're not supposed to be able to do (once its in a Signature
its supposed to be a valid object, even if not a valid signature for a given message, I think).
Yea, sorry, I got too excited with this. I think I also need to pull in rust-bitcoin/bitcoin_hashes#111 for fuzzing and then re-redo the full_stack_target test. |
85dcb52
to
3dd72e5
Compare
OK, should be resolve now, also address your comments. |
386ccf3
to
49718cf
Compare
49718cf
to
a7863d4
Compare
Rebased. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the dependencies on open PRs, should we wait at least on some concept ACKs on those? I'm not sure if I have suitable knowledge to do so on my own.
// 0000000000000000000000000000000000000000000000000000000000000000 - our network key | ||
// 0100000000000000000000000000000000000000000000000000000000000000 - our network key |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To confirm my understanding, do these diffs extend from the fact that the use of get_secure_random_bytes
to seed Secp256k1
causes an increment to a rand_bytes_child_index
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They extend from a few things (which is why there's so many of them). This particular one extends from the fact that secp256k1's fuzzing mode now requires the private key not be all-0s (in fact it enforces the regular non-fuzzing rules around private key validity). Other changes are required because, as a result of that, we now have sha256 only return hashes with one byte set to 1-0xff instead of 0-0xff as we did previously.
a7863d4
to
4e2bdf2
Compare
Yea, to merge that probably makes sense. |
Relevant IRC discussion:
|
1543730
to
b328fcf
Compare
Squashed. I'd ideally like to take this for 0.0.13, unless someone has objections to the PR dependencies, which would be reasonable. |
fix build? |
Note that rust-fuzz wrappers (including honggfuzz) already apply this for us.
b328fcf
to
bd48726
Compare
Oops, rebase introduced errors. I droped the bindings updates cause its gonna require some minor changes in the generator, though likely not too bad. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
This is useful when rebuilding the full_stack_target test vector
bd48726
to
ea48a5a
Compare
Bumped to latest version of the rust-secp pull to fix (most of) the performance degredation. |
Note that, sadly, this still decreases the performance of, especially, chanmon_consistency, taking the CI fuzz runs from 18/91 minutes to 22/23 minutes for the fuzzing section. |
I'm seeing this failure at ea48a5a:
|
Right, you now need to set |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, you now need to set
RUSTFLAGS="--cfg fuzzing"
in order to run the fuzzing tests.
Yeah, that should have been obvious. :P
LGTM
This updates our rust-bitcoin dependency and adds secp256k1 context randomization. Note that it relies on an open PR upstream in
lightning-c-bindings
and a separate open PR upstream for fuzzing. That's probably fine for fuzzing, but for bindings it kinda sucks. Hopefully we can get those merged soon.