16 using namespace folly;
20 void X25519KeyExchange::generateKeyPair() {
23 auto err = crypto_box_curve25519xsalsa20poly1305_keypair(
24 pubKey.data(), privKey.data());
26 throw std::runtime_error(to<std::string>(
"Could not generate keys ", err));
32 std::unique_ptr<IOBuf> X25519KeyExchange::getKeyShare()
const {
33 if (!privKey_ || !pubKey_) {
34 throw std::runtime_error(
"Key not generated");
39 std::unique_ptr<folly::IOBuf> X25519KeyExchange::generateSharedSecret(
41 if (!privKey_ || !pubKey_) {
42 throw std::runtime_error(
"Key not generated");
44 if (keyShare.
size() != crypto_scalarmult_BYTES) {
45 throw std::runtime_error(
"Invalid external public key");
48 key->append(crypto_scalarmult_BYTES);
50 crypto_scalarmult(key->writableData(), privKey_->data(), keyShare.
data());
52 throw std::runtime_error(
"Invalid point");
static std::unique_ptr< IOBuf > create(std::size_t capacity)
constexpr detail::Map< Move > move
constexpr size_type size() const
—— Concurrent Priority Queue Implementation ——
std::array< uint8_t, crypto_scalarmult_BYTES > PubKey
constexpr Iter data() const
std::array< uint8_t, crypto_scalarmult_SCALARBYTES > PrivKey
static std::unique_ptr< IOBuf > copyBuffer(const void *buf, std::size_t size, std::size_t headroom=0, std::size_t minTailroom=0)