I am planning to use a key agreement mechanism in an application needing ephemeral keys, and Curve25519 looks promising, specifically because it offers 128 bits of security, just fine for AES-128 which is my symmetric cryptographic algorithm of choice (https://en.wikipedia.org/wiki/Curve25519):
In cryptography, Curve25519 is an elliptic curve used in elliptic-curve cryptography (ECC) offering 128 bits of security (256-bit key size) and designed for use with the Elliptic-curve Diffie–Hellman (ECDH) key agreement scheme
As a bonus, I can use public domain code to implement it, which doesn't cause any licensing issues.
However, the shared secret size of Curve25519 seems to be 32 bytes (256 bits). This is troubling me somewhat. I need only 128 bits.
Can I safely take only half of the bits generated by Curve25519, or is it a common property of Curve25519 that the number of bits of security is half of the number of bits used? So if I use only half of the bits, does it mean I have still 128 bits of security (safe), or 64 bits of security (unsafe)?
Of course, if it's unsafe to truncate, I could use some kind of hash function and take half of the bits of the hash function output, but I wouldn't want to do this unless absolutely needed.