X25519 key exchange implementation using libsodium.
Definition at line 23 of file X25519.h.
Generate a shared secret with our key pair and a peer's public key share.
Performs all necessary validation of the public key share and throws on error.
generateKeyPair() must be called before.
Implements fizz::KeyExchange.
Definition at line 39 of file X25519.cpp.
References folly::IOBuf::create(), folly::Range< Iter >::data(), and folly::Range< Iter >::size().
Referenced by fizz::test::TEST().
42 throw std::runtime_error(
"Key not generated");
44 if (keyShare.
size() != crypto_scalarmult_BYTES) {
45 throw std::runtime_error(
"Invalid external public key");
47 auto key = IOBuf::create(crypto_scalarmult_BYTES);
48 key->append(crypto_scalarmult_BYTES);
50 crypto_scalarmult(key->writableData(),
privKey_->data(), keyShare.
data());
52 throw std::runtime_error(
"Invalid point");
folly::Optional< PubKey > pubKey_
constexpr size_type size() const
folly::Optional< PrivKey > privKey_
constexpr Iter data() const