20using Hash = std::array<std::uint8_t, hash_len>;
Byte buffer / view aliases and protobuf base-128 varint codec.
Non-owning view over a contiguous run of bytes (a C++17 stand-in for std::span<const std::uint8_t>).
Definition bytes.hpp:17
Definition cipher_state.hpp:11
constexpr std::size_t key_len
Symmetric / DH key size.
Definition primitives.hpp:18
PublicKey x25519_base(const PrivateKey &private_key)
X25519 public key for a private scalar.
bool aead_decrypt(const SymmetricKey &key, std::uint64_t nonce, ByteView ad, ByteView ciphertext, ByteBuffer &out_plaintext)
AEAD ChaCha20-Poly1305 (IETF) decryption. Returns false on auth failure.
std::array< std::uint8_t, key_len > PublicKey
Definition primitives.hpp:22
constexpr std::size_t hash_len
SHA-256 digest / key size.
Definition primitives.hpp:17
std::array< std::uint8_t, key_len > SymmetricKey
Definition primitives.hpp:21
void generate_keypair(PrivateKey &private_key, PublicKey &public_key)
Generate a fresh X25519 keypair from the system CSPRNG.
SymmetricKey x25519(const PrivateKey &private_key, const PublicKey &peer_public)
X25519 shared secret. Throws EncryptionError on an all-zero (degenerate) result.
Hash sha256(ByteView data)
SHA-256 of data.
Hash hmac_sha256(ByteView key, ByteView data)
HMAC-SHA-256 with key over data.
bool base64_decode(const std::string &text, ByteBuffer &out)
Decode standard base64. Returns false on malformed input.
ByteBuffer aead_encrypt(const SymmetricKey &key, std::uint64_t nonce, ByteView ad, ByteView plaintext)
AEAD ChaCha20-Poly1305 (IETF) encryption.
void hkdf(const Hash &chaining_key, ByteView input_key_material, int num_outputs, Hash &o1, Hash &o2, Hash &o3)
Noise HKDF: derive num_outputs (1..3) 32-byte values from chaining_key and input_key_material.
std::array< std::uint8_t, key_len > PrivateKey
Definition primitives.hpp:23
std::array< std::uint8_t, hash_len > Hash
Definition primitives.hpp:20
std::vector< std::uint8_t > ByteBuffer
Owning, growable byte buffer.
Definition bytes.hpp:13