Bitcoin Core 28.99.0
P2P Digital Currency
Public Member Functions | Static Public Attributes | Private Attributes | List of all members
FSChaCha20 Class Reference

Forward-secure ChaCha20. More...

#include <chacha20.h>

Collaboration diagram for FSChaCha20:
[legend]

Public Member Functions

 FSChaCha20 (const FSChaCha20 &)=delete
 
 FSChaCha20 (FSChaCha20 &&)=delete
 
FSChaCha20operator= (const FSChaCha20 &)=delete
 
FSChaCha20operator= (FSChaCha20 &&)=delete
 
 FSChaCha20 (Span< const std::byte > key, uint32_t rekey_interval) noexcept
 Construct an FSChaCha20 cipher that rekeys every rekey_interval Crypt() calls. More...
 
void Crypt (Span< const std::byte > input, Span< std::byte > output) noexcept
 Encrypt or decrypt a chunk. More...
 

Static Public Attributes

static constexpr unsigned KEYLEN = 32
 Length of keys expected by the constructor. More...
 

Private Attributes

ChaCha20 m_chacha20
 Internal stream cipher. More...
 
const uint32_t m_rekey_interval
 The number of encryptions/decryptions before a rekey happens. More...
 
uint32_t m_chunk_counter {0}
 The number of encryptions/decryptions since the last rekey. More...
 
uint64_t m_rekey_counter {0}
 The number of rekey operations that have happened. More...
 

Detailed Description

Forward-secure ChaCha20.

This implements a stream cipher that automatically transitions to a new stream with a new key and new nonce after a predefined number of encryptions or decryptions.

See BIP324 for details.

Definition at line 127 of file chacha20.h.

Constructor & Destructor Documentation

◆ FSChaCha20() [1/3]

FSChaCha20::FSChaCha20 ( const FSChaCha20 )
delete

◆ FSChaCha20() [2/3]

FSChaCha20::FSChaCha20 ( FSChaCha20 &&  )
delete

◆ FSChaCha20() [3/3]

FSChaCha20::FSChaCha20 ( Span< const std::byte >  key,
uint32_t  rekey_interval 
)
noexcept

Construct an FSChaCha20 cipher that rekeys every rekey_interval Crypt() calls.

Definition at line 344 of file chacha20.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ Crypt()

void FSChaCha20::Crypt ( Span< const std::byte >  input,
Span< std::byte >  output 
)
noexcept

Encrypt or decrypt a chunk.

Definition at line 350 of file chacha20.cpp.

Here is the call graph for this function:

◆ operator=() [1/2]

FSChaCha20 & FSChaCha20::operator= ( const FSChaCha20 )
delete

◆ operator=() [2/2]

FSChaCha20 & FSChaCha20::operator= ( FSChaCha20 &&  )
delete

Member Data Documentation

◆ KEYLEN

constexpr unsigned FSChaCha20::KEYLEN = 32
staticconstexpr

Length of keys expected by the constructor.

Definition at line 144 of file chacha20.h.

◆ m_chacha20

ChaCha20 FSChaCha20::m_chacha20
private

Internal stream cipher.

Definition at line 131 of file chacha20.h.

◆ m_chunk_counter

uint32_t FSChaCha20::m_chunk_counter {0}
private

The number of encryptions/decryptions since the last rekey.

Definition at line 137 of file chacha20.h.

◆ m_rekey_counter

uint64_t FSChaCha20::m_rekey_counter {0}
private

The number of rekey operations that have happened.

Definition at line 140 of file chacha20.h.

◆ m_rekey_interval

const uint32_t FSChaCha20::m_rekey_interval
private

The number of encryptions/decryptions before a rekey happens.

Definition at line 134 of file chacha20.h.


The documentation for this class was generated from the following files: