# How to most inexpensively extract 1 byte of uniformly distributed entropy from a 32-byte Curve25519 EC point

I'm looking for the simplest and most inexpensive hash with the following properties:

Input: A 32-byte Curve25519 EC point containing approximately 125 bits of non-uniformly distributed entropy (created as a result of an ECDH exchange).

Output: 1 byte containing 8 bits of entropy, uniformly distributed.

• XOR the point 31 times. Commented Jan 31, 2022 at 16:30
• @PaulUszak What is the best way of demonstrating the validity of your method? Are there any papers that can be cited? I would need to convince people that are terrified of doing anything other than truncating the output of a cryptographically secure hash to 1 byte Commented Jan 31, 2022 at 16:52
• @kelalaka what is the fastest hash that would tame the non-uniformity, given that the one-byte output means we're not restricted to hashes that deliver collision resistance? I'm hoping that this lack of restriction means that far simpler and faster hashing methods are available for this use case Commented Jan 31, 2022 at 19:38

## 1 Answer

The usual encoding of the points is structured and non-uniform since it must satisfy the curve equation. In Curve25519 with $$x \in \mathbb Z(2^{255} - 19)\mathbb Z$$ and using the curve equation $$x^3 + 486662 x^2 + x$$ is always a square for the points. There is common advice to use a KDF on the ECDH output to use AES keys since it may attack points to related key attakks.

One solution for the requirement is using a fast PRF like ChaCha8 where the key is the key of DHKE wiht zero IV.

func extact_one_byte( Point P):

oneByte = 0
out512 = ChaCha8(key,00..00, x(P)||y(P))

return out512[0:8]

• Are you saying that the characteristics of BLAKE3 are such that if it were truncated to a single byte, that byte would not meet the requirement of being uniformly random? Please could you give your reasoning? Commented Jan 31, 2022 at 20:51
• The output of a cryptographic hash function is expected to be indistinguishable from uniform random. Unless, one can prove the reverse, all bytes, all bits are indistinguishable. Therefore their x-or, too. Commented Jan 31, 2022 at 20:53
• Then why do the XOR, if the first byte of the BLAKE3 output would already be uniformly random? Commented Jan 31, 2022 at 20:54
• You may not need it, however, condensing them to one byte has no danger and almost has no cost. Commented Jan 31, 2022 at 20:57
• If I consider the EC point to be a secret with a bit strength of 125 bits, and if I am concerned about leaking information about this secret, what would be the bit strength of this secret after publishing the 1-byte hash? And if the answer is that I should expect it to be 125-8=117 bits after publishing the 1-byte hash, why would it matter if a cryptographically secure hash is used instead of a simpler checksum? I think this is the reason that @PaulUszak said to just XOR the bytes of the EC point and not hash at all Commented Jan 31, 2022 at 21:01