28 m_our_pubkey = m_key.EllSwiftCreate(
ent32);
32 m_key(key), m_our_pubkey(pubkey) {}
48 (
side ? m_send_l_cipher : m_recv_l_cipher).emplace(
hkdf_32_okm, REKEY_INTERVAL);
50 (
side ? m_send_p_cipher : m_recv_p_cipher).emplace(
hkdf_32_okm, REKEY_INTERVAL);
52 (
side ? m_recv_l_cipher : m_send_l_cipher).emplace(
hkdf_32_okm, REKEY_INTERVAL);
54 (
side ? m_recv_p_cipher : m_send_p_cipher).emplace(
hkdf_32_okm, REKEY_INTERVAL);
59 (
initiator ? m_send_garbage_terminator : m_recv_garbage_terminator).begin());
61 (
initiator ? m_recv_garbage_terminator : m_send_garbage_terminator).begin());
78 std::byte len[LENGTH_LEN];
82 m_send_l_cipher->Crypt(len, output.first(LENGTH_LEN));
85 std::byte header[HEADER_LEN] = {ignore ? IGNORE_BIT : std::byte{0}};
86 m_send_p_cipher->Encrypt(header,
contents,
aad, output.subspan(LENGTH_LEN));
91 assert(input.size() == LENGTH_LEN);
93 std::byte buf[LENGTH_LEN];
95 m_recv_l_cipher->Crypt(input, buf);
104 std::byte header[HEADER_LEN];
105 if (!m_recv_p_cipher->Decrypt(input,
aad, header,
contents))
return false;
107 ignore = (header[0] & IGNORE_BIT) == IGNORE_BIT;
const CChainParams & Params()
Return the currently selected parameters.
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.
unsigned DecryptLength(std::span< const std::byte > input) noexcept
Decrypt the length of a packet.
BIP324Cipher()=delete
No default constructor; keys must be provided to create a BIP324Cipher.
void Initialize(const EllSwiftPubKey &their_pubkey, bool initiator, bool self_decrypt=false) noexcept
Initialize when the other side's public key is received.
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.
const MessageStartChars & MessageStart() const
A rfc5869 HKDF implementation with HMAC_SHA256 and fixed key output length of 32 bytes (L=32)
An encapsulated private key.
void memory_cleanse(void *ptr, size_t len)
Secure overwrite a buffer (possibly containing secret data) with zero-bytes.
std::array< std::byte, ECDH_SECRET_SIZE > ECDHSecret
unsigned char * UCharCast(char *c)
An ElligatorSwift-encoded public key.
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.