5#ifndef BITCOIN_BIP324_H
6#define BITCOIN_BIP324_H
71 void Encrypt(std::span<const std::byte> contents, std::span<const std::byte> aad,
bool ignore, std::span<std::byte> output)
noexcept;
77 unsigned DecryptLength(std::span<const std::byte> input)
noexcept;
84 bool Decrypt(std::span<const std::byte> input, std::span<const std::byte> aad,
bool& ignore, std::span<std::byte> contents)
noexcept;
The BIP324 packet cipher, encapsulating its key derivation, stream cipher, and AEAD.
static constexpr unsigned REKEY_INTERVAL
bool Decrypt(std::span< const std::byte > input, std::span< const std::byte > aad, bool &ignore, std::span< std::byte > contents) noexcept
Decrypt a packet.
std::span< const std::byte > GetSendGarbageTerminator() const noexcept
Get the Garbage Terminator to send.
static constexpr unsigned GARBAGE_TERMINATOR_LEN
static constexpr unsigned HEADER_LEN
unsigned DecryptLength(std::span< const std::byte > input) noexcept
Decrypt the length of a packet.
std::span< const std::byte > GetSessionID() const noexcept
Get the Session ID.
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.
std::span< const std::byte > GetReceiveGarbageTerminator() const noexcept
Get the expected Garbage Terminator to receive.
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
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
void Encrypt(std::span< const std::byte > contents, std::span< const std::byte > aad, bool ignore, std::span< std::byte > output) noexcept
Encrypt a packet.
An encapsulated private key.
static constexpr auto EXPANSION
Expansion when encrypting.
An ElligatorSwift-encoded public key.