5#ifndef BITCOIN_BIP324_H
6#define BITCOIN_BIP324_H
The BIP324 packet cipher, encapsulating its key derivation, stream cipher, and AEAD.
Span< const std::byte > GetReceiveGarbageTerminator() const noexcept
Get the expected Garbage Terminator to receive.
Span< const std::byte > GetSendGarbageTerminator() const noexcept
Get the Garbage Terminator to send.
static constexpr unsigned REKEY_INTERVAL
static constexpr unsigned GARBAGE_TERMINATOR_LEN
static constexpr unsigned HEADER_LEN
unsigned DecryptLength(Span< const std::byte > input) noexcept
Decrypt the length of a packet.
EllSwiftPubKey m_our_pubkey
const EllSwiftPubKey & GetOurPubKey() const noexcept
Retrieve our public key.
static constexpr std::byte IGNORE_BIT
BIP324Cipher()=delete
No default constructor; keys must be provided to create a BIP324Cipher.
bool Decrypt(Span< const std::byte > input, Span< const std::byte > aad, bool &ignore, Span< std::byte > contents) noexcept
Decrypt a packet.
Span< const std::byte > GetSessionID() const noexcept
Get the Session ID.
std::optional< FSChaCha20Poly1305 > m_recv_p_cipher
std::array< std::byte, GARBAGE_TERMINATOR_LEN > m_recv_garbage_terminator
std::array< std::byte, SESSION_ID_LEN > m_session_id
std::array< std::byte, GARBAGE_TERMINATOR_LEN > m_send_garbage_terminator
void Encrypt(Span< const std::byte > contents, Span< const std::byte > aad, bool ignore, Span< std::byte > output) noexcept
Encrypt a packet.
std::optional< FSChaCha20 > m_recv_l_cipher
static constexpr unsigned LENGTH_LEN
static constexpr unsigned EXPANSION
void Initialize(const EllSwiftPubKey &their_pubkey, bool initiator, bool self_decrypt=false) noexcept
Initialize when the other side's public key is received.
std::optional< FSChaCha20Poly1305 > m_send_p_cipher
static constexpr unsigned SESSION_ID_LEN
std::optional< FSChaCha20 > m_send_l_cipher
An encapsulated private key.
static constexpr auto EXPANSION
Expansion when encrypting.
An ElligatorSwift-encoded public key.