Botan 3.5.0
Crypto and TLS for C&
kyber_types.h
Go to the documentation of this file.
1/*
2 * Crystals Kyber key encapsulation mechanism
3 *
4 * Strong Type definitions used throughout the Kyber implementation
5 *
6 * (C) 2024 Jack Lloyd
7 * (C) 2024 René Meusel, Rohde & Schwarz Cybersecurity
8 *
9 * Botan is released under the Simplified BSD License (see license.txt)
10 */
11
12#ifndef BOTAN_KYBER_TYPES_H_
13#define BOTAN_KYBER_TYPES_H_
14
15#include <botan/secmem.h>
16#include <botan/strong_type.h>
17
18#include <variant>
19#include <vector>
20
21namespace Botan {
22
23/// Principal seed used to generate Kyber key pairs
24using KyberSeedRandomness = Strong<secure_vector<uint8_t>, struct KyberSeedRandomness_>;
25
26/// Public seed value to generate the Kyber matrix A
27using KyberSeedRho = Strong<std::vector<uint8_t>, struct KyberSeedRho_>;
28
29/// Private seed used to generate polynomial vectors s and e during key generation
30using KyberSeedSigma = Strong<secure_vector<uint8_t>, struct KyberSeedSigma_>;
31
32/// Secret random value (called Z in the spec), used for implicit rejection in the decapsulation
33using KyberImplicitRejectionValue = Strong<secure_vector<uint8_t>, struct KyberImplicitRejectionValue_>;
34
35/// Random message value to be encrypted by the CPA-secure Kyber encryption scheme
36using KyberMessage = Strong<secure_vector<uint8_t>, struct KyberMessage_>;
37
38/// Random value used to generate the Kyber ciphertext
39using KyberEncryptionRandomness = Strong<secure_vector<uint8_t>, struct KyberEncryptionRandomness_>;
40
41/// PRF value used for sampling of error polynomials
42using KyberSamplingRandomness = Strong<secure_vector<uint8_t>, struct KyberSamplingRandomness_>;
43
44/// Shared secret value generated during encapsulation and recovered during decapsulation
45using KyberSharedSecret = Strong<secure_vector<uint8_t>, struct KyberSharedSecret_>;
46
47/// Public key in serialized form (t || rho)
48using KyberSerializedPublicKey = Strong<std::vector<uint8_t>, struct KyberSerializedPublicKey_>;
49
50// Hash value of the serialized public key
51using KyberHashedPublicKey = Strong<std::vector<uint8_t>, struct KyberHashedPublicKey_>;
52
53// Compressed and serialized ciphertext value
54using KyberCompressedCiphertext = Strong<std::vector<uint8_t>, struct KyberCompressedCiphertext_>;
55
56// Hash of the compressed and serialized ciphertext value
57// TODO: Remove this once Kyber-R3 is removed
58using KyberHashedCiphertext = Strong<std::vector<uint8_t>, struct KyberHashedCiphertext_>;
59
60// Variant value of either a KyberSeedSigma or a KyberEncryptionRandomness
62 std::variant<StrongSpan<const KyberSeedSigma>, StrongSpan<const KyberEncryptionRandomness>>;
63
64} // namespace Botan
65
66#endif
std::variant< StrongSpan< const KyberSeedSigma >, StrongSpan< const KyberEncryptionRandomness > > KyberSigmaOrEncryptionRandomness
Definition kyber_types.h:61