![]() |
Bitcoin Core
25.99.0
P2P Digital Currency
|
The BIP324 packet cipher, encapsulating its key derivation, stream cipher, and AEAD. More...
#include <bip324.h>
Public Member Functions | |
BIP324Cipher ()=delete | |
No default constructor; keys must be provided to create a BIP324Cipher. More... | |
BIP324Cipher (const CKey &key, Span< const std::byte > ent32) noexcept | |
Initialize a BIP324 cipher with specified key and encoding entropy (testing only). More... | |
BIP324Cipher (const CKey &key, const EllSwiftPubKey &pubkey) noexcept | |
Initialize a BIP324 cipher with specified key (testing only). More... | |
const EllSwiftPubKey & | GetOurPubKey () const noexcept |
Retrieve our public key. More... | |
void | Initialize (const EllSwiftPubKey &their_pubkey, bool initiator, bool self_decrypt=false) noexcept |
Initialize when the other side's public key is received. More... | |
operator bool () const noexcept | |
Determine whether this cipher is fully initialized. More... | |
void | Encrypt (Span< const std::byte > contents, Span< const std::byte > aad, bool ignore, Span< std::byte > output) noexcept |
Encrypt a packet. More... | |
unsigned | DecryptLength (Span< const std::byte > input) noexcept |
Decrypt the length of a packet. More... | |
bool | Decrypt (Span< const std::byte > input, Span< const std::byte > aad, bool &ignore, Span< std::byte > contents) noexcept |
Decrypt a packet. More... | |
Span< const std::byte > | GetSessionID () const noexcept |
Get the Session ID. More... | |
Span< const std::byte > | GetSendGarbageTerminator () const noexcept |
Get the Garbage Terminator to send. More... | |
Span< const std::byte > | GetReceiveGarbageTerminator () const noexcept |
Get the expected Garbage Terminator to receive. More... | |
Static Public Attributes | |
static constexpr unsigned | SESSION_ID_LEN {32} |
static constexpr unsigned | GARBAGE_TERMINATOR_LEN {16} |
static constexpr unsigned | REKEY_INTERVAL {224} |
static constexpr unsigned | LENGTH_LEN {3} |
static constexpr unsigned | HEADER_LEN {1} |
static constexpr unsigned | EXPANSION = LENGTH_LEN + HEADER_LEN + FSChaCha20Poly1305::EXPANSION |
static constexpr std::byte | IGNORE_BIT {0x80} |
Private Attributes | |
std::optional< FSChaCha20 > | m_send_l_cipher |
std::optional< FSChaCha20 > | m_recv_l_cipher |
std::optional< FSChaCha20Poly1305 > | m_send_p_cipher |
std::optional< FSChaCha20Poly1305 > | m_recv_p_cipher |
CKey | m_key |
EllSwiftPubKey | m_our_pubkey |
std::array< std::byte, SESSION_ID_LEN > | m_session_id |
std::array< std::byte, GARBAGE_TERMINATOR_LEN > | m_send_garbage_terminator |
std::array< std::byte, GARBAGE_TERMINATOR_LEN > | m_recv_garbage_terminator |
The BIP324 packet cipher, encapsulating its key derivation, stream cipher, and AEAD.
|
delete |
No default constructor; keys must be provided to create a BIP324Cipher.
Initialize a BIP324 cipher with specified key and encoding entropy (testing only).
Definition at line 25 of file bip324.cpp.
|
noexcept |
Initialize a BIP324 cipher with specified key (testing only).
Definition at line 31 of file bip324.cpp.
|
noexcept |
Decrypt a packet.
Only after Initialize().
It must hold that input.size() + LENGTH_LEN == contents.size() + EXPANSION. Contents.size() must equal the length returned by DecryptLength.
Definition at line 100 of file bip324.cpp.
|
noexcept |
Decrypt the length of a packet.
Only after Initialize().
It must hold that input.size() == LENGTH_LEN.
Definition at line 89 of file bip324.cpp.
|
noexcept |
Encrypt a packet.
Only after Initialize().
It must hold that output.size() == contents.size() + EXPANSION.
Definition at line 73 of file bip324.cpp.
|
inlinenoexcept |
|
inlinenoexcept |
Get the expected Garbage Terminator to receive.
Only after Initialize().
Definition at line 93 of file bip324.h.
|
inlinenoexcept |
Get the Garbage Terminator to send.
Only after Initialize().
Definition at line 90 of file bip324.h.
|
inlinenoexcept |
Get the Session ID.
Only after Initialize().
Definition at line 87 of file bip324.h.
|
noexcept |
Initialize when the other side's public key is received.
Can only be called once.
initiator is set to true if we are the initiator establishing the v2 P2P connection. self_decrypt is only for testing, and swaps encryption/decryption keys, so that encryption and decryption can be tested without knowing the other side's private key.
Definition at line 34 of file bip324.cpp.
|
inlineexplicitnoexcept |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
staticconstexpr |
|
staticconstexpr |