.\"
.\" ----------------------------------------------------------------------------
.\"
-.\" Copyright (c) 2017-2021 Loup Vaillant
+.\" Copyright (c) 2017-2021, 2022 Loup Vaillant
.\" Copyright (c) 2017-2018 Michael Savage
.\" Copyright (c) 2017, 2019-2020, 2022 Fabio Scotoni
.\" Copyright (c) 2020 Richard Walmsley
.\" with this software. If not, see
.\" <https://creativecommons.org/publicdomain/zero/1.0/>
.\"
-.Dd February 13, 2022
+.Dd February 14, 2022
.Dt CRYPTO_X25519 3MONOCYPHER
.Os
.Sh NAME
.Bd -literal -offset indent
const uint8_t their_pk [32]; /* Their public key */
uint8_t your_sk [32]; /* Your secret key */
+uint8_t your_pk [32]; /* Your public key */
uint8_t shared_secret[32]; /* Shared secret (NOT a key) */
arc4random_buf(your_sk, 32);
+crypto_x25512(your_pk, your_sk);
crypto_x25519(shared_secret, your_sk, their_pk);
/* Wipe secrets if they are no longer needed */
crypto_wipe(your_sk, 32);
uint8_t shared_keys[64]; /* Two shared session keys */
-crypto_blake2b(shared_keys, shared_secret, 32);
+crypto_blake2b_ctx ctx;
+crypto_blake2b_init (&ctx);
+crypto_blake2b_update(&ctx, shared_secret, 32);
+crypto_blake2b_update(&ctx, your_pk , 32);
+crypto_blake2b_update(&ctx, their_pk , 32);
+crypto_blake2b_final (&ctx, shared_keys);
const uint8_t *key_1 = shared_keys; /* Shared key 1 */
const uint8_t *key_2 = shared_keys + 32; /* Shared key 2 */
/* Wipe secrets if they are no longer needed */