MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / Encrypt

Method Encrypt

src/bip324.cpp:73–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71}
72
73void BIP324Cipher::Encrypt(std::span<const std::byte> contents, std::span<const std::byte> aad, bool ignore, std::span<std::byte> output) noexcept
74{
75 assert(output.size() == contents.size() + EXPANSION);
76
77 // Encrypt length.
78 std::byte len[LENGTH_LEN];
79 len[0] = std::byte{(uint8_t)(contents.size() & 0xFF)};
80 len[1] = std::byte{(uint8_t)((contents.size() >> 8) & 0xFF)};
81 len[2] = std::byte{(uint8_t)((contents.size() >> 16) & 0xFF)};
82 m_send_l_cipher->Crypt(len, output.first(LENGTH_LEN));
83
84 // Encrypt plaintext.
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));
87}
88
89uint32_t BIP324Cipher::DecryptLength(std::span<const std::byte> input) noexcept
90{

Callers 2

SetMessageToSendMethod · 0.45

Calls 2

CryptMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected