Enable simultaneous deserialization+decryption of a ChaChaPoly stream
authorValentine Wallace <vwallace@protonmail.com>
Tue, 14 Jun 2022 20:28:45 +0000 (16:28 -0400)
committerValentine Wallace <vwallace@protonmail.com>
Tue, 21 Jun 2022 21:08:28 +0000 (17:08 -0400)
commitee805e97ff0888bcfd9dabc0de1027ae6b75163e
treea3656a6a4d158db82af3ec4c8561ad73ad74a03d
parent945cec3027cb88edd506123ca0995a8aeac9ebe9
Enable simultaneous deserialization+decryption of a ChaChaPoly stream

In the upcoming onion messages PR, this will allow us to avoid decrypting onion
message encrypted data in an intermediate Vec before decoding it. Instead we
decrypt and decode it at the same time using this new ChaChaPolyReadAdapter object.

In doing so, we need to adapt the decode_tlv_stream macro such that it will
decode a LengthReadableArgs, which is a new trait as well. This trait is
necessary because ChaChaPoly needs to know the total length ahead of time to
separate out the tag at the end.
lightning/src/util/chacha20poly1305rfc.rs
lightning/src/util/ser.rs
lightning/src/util/ser_macros.rs