From: valentinewallace Date: Wed, 17 Jan 2024 17:53:02 +0000 (-0500) Subject: Merge pull request #2828 from TheBlueMatt/2024-01-crypto-module X-Git-Tag: v0.0.120~2 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;ds=sidebyside;h=a1759582ada5531d85f91e56a60b9c4d66341511;hp=-c;p=rust-lightning Merge pull request #2828 from TheBlueMatt/2024-01-crypto-module Move cryptographic algorithms and utilities to a new `crypto` mod --- a1759582ada5531d85f91e56a60b9c4d66341511 diff --combined lightning/src/ln/msgs.rs index bc914ce49,efd04d143..d39f1a608 --- a/lightning/src/ln/msgs.rs +++ b/lightning/src/ln/msgs.rs @@@ -53,7 -53,7 +53,7 @@@ use crate::io::{self, Cursor, Read} use crate::io_extras::read_to_end; use crate::events::{EventsProvider, MessageSendEventsProvider}; - use crate::util::chacha20poly1305rfc::ChaChaPolyReadAdapter; + use crate::crypto::streams::ChaChaPolyReadAdapter; use crate::util::logger; use crate::util::ser::{LengthReadable, LengthReadableArgs, Readable, ReadableArgs, Writeable, Writer, WithoutLength, FixedLengthReader, HighZeroBytesDroppedBigSize, Hostname, TransactionU16LenLimited, BigSize}; use crate::util::base32; @@@ -1714,7 -1714,7 +1714,7 @@@ mod fuzzy_internal_msgs payment_relay: PaymentRelay, payment_constraints: PaymentConstraints, features: BlindedHopFeatures, - intro_node_blinding_point: PublicKey, + intro_node_blinding_point: Option, }, BlindedReceive { sender_intended_htlc_amt_msat: u64, @@@ -2394,7 -2394,7 +2394,7 @@@ impl ReadableArgs<(Option None => return None, }; let payment_relay: PaymentRelay = match details.counterparty.forwarding_info { - Some(forwarding_info) => forwarding_info.into(), + Some(forwarding_info) => match forwarding_info.try_into() { + Ok(payment_relay) => payment_relay, + Err(()) => return None, + }, None => return None, }; - // Avoid exposing esoteric CLTV expiry deltas - let cltv_expiry_delta = match payment_relay.cltv_expiry_delta { - 0..=40 => 40u32, - 41..=80 => 80u32, - 81..=144 => 144u32, - 145..=216 => 216u32, - _ => return None, - }; - + let cltv_expiry_delta = payment_relay.cltv_expiry_delta as u32; let payment_constraints = PaymentConstraints { max_cltv_expiry: tlvs.payment_constraints.max_cltv_expiry + cltv_expiry_delta, htlc_minimum_msat: details.inbound_htlc_minimum_msat.unwrap_or(0), @@@ -2701,7 -2706,7 +2701,7 @@@ where L::Target: Logger } } - // Means we succesfully traversed from the payer to the payee, now + // Means we successfully traversed from the payer to the payee, now // save this path for the payment route. Also, update the liquidity // remaining on the used hops, so that we take them into account // while looking for more paths. @@@ -3190,7 -3195,7 +3190,7 @@@ mod tests use crate::offers::invoice::BlindedPayInfo; use crate::util::config::UserConfig; use crate::util::test_utils as ln_test_utils; - use crate::util::chacha20::ChaCha20; + use crate::crypto::chacha20::ChaCha20; use crate::util::ser::{Readable, Writeable}; #[cfg(c_bindings)] use crate::util::ser::Writer; @@@ -7798,7 -7803,7 +7798,7 @@@ fn do_min_htlc_overpay_violates_max_htlc(blinded_payee: bool) { // Test that if overpaying to meet a later hop's min_htlc and causes us to violate an earlier // hop's max_htlc, we don't consider that candidate hop valid. Previously we would add this hop - // to `targets` and build an invalid path with it, and subsquently hit a debug panic asserting + // to `targets` and build an invalid path with it, and subsequently hit a debug panic asserting // that the used liquidity for a hop was less than its available liquidity limit. let secp_ctx = Secp256k1::new(); let logger = Arc::new(ln_test_utils::TestLogger::new()); @@@ -8447,7 -8452,7 +8447,7 @@@ pub(crate) mod bench_utils } break; } - // If we couldn't find a path with a higer amount, reduce and try again. + // If we couldn't find a path with a higher amount, reduce and try again. score_amt /= 100; }