Skip to content

Kyber example #3889

Answered by reneme
yanboti asked this question in Q&A
Jan 17, 2024 · 1 comments · 5 replies
Discussion options

You must be logged in to vote

Perhaps you need to remove the salt from the encrypt() and decrypt() calls? The following works for me:

#include <botan/kyber.h>
#include <botan/pubkey.h>
#include <botan/system_rng.h>
#include <array>
#include <iostream>

int main() {
   const size_t shared_key_len = 32;
   const std::string kdf = "Raw";

   Botan::System_RNG rng;

   Botan::Kyber_PrivateKey priv_key(rng, Botan::KyberMode::Kyber512_R3);
   auto pub_key = priv_key.public_key();

   Botan::PK_KEM_Encryptor enc(*pub_key, kdf);

   const auto kem_result = enc.encrypt(rng, shared_key_len);

   Botan::PK_KEM_Decryptor dec(priv_key, rng, kdf);

   auto dec_shared_key = dec.decrypt(kem_result.encapsulated_shared_key(), shared_ke…

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@yanboti
Comment options

@reneme
Comment options

reneme Jan 17, 2024
Collaborator

Answer selected by yanboti
@yanboti
Comment options

@reneme
Comment options

reneme Jan 17, 2024
Collaborator

@yanboti
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants