Score:3

How to distinguish X25519 output from random?

za flag

Suppose that Alice has an X25519 key pair $\{S_A,P_A\}$ (secret and public key, respectively). Using randomly selected X25519 public keys $\{P_*\}$ (such that $P_A\notin \{P_*\}$), Alice calculates several values $X_* = \operatorname{X25519}(S_*,P_*)$.

She then repeatedly flips a (fair) coin. Each time, if the result is heads, she sends a (truly) random 256-bit string to Bob. If the result is tails, she sends some value in $\{X_*\}$ to Bob. Bob does not know the result of the coin flip.

I know that the output of the ECDH function is not uniformly random, so how can Bob determine—with more than 50% accuracy—whether Alice has sent him a random string or a value from the set $\{X_*\}$?

Bob knows $P_A$ and the curve parameters, but he does not know the elements of the set $\{X_*\}$.


This question is distinct from Distinguishing x25519 public keys from random?, which asks about distinguishing X25519 public keys from random. This question asks about distinguishing the output of the X25519 function (i.e., the shared secret computed with the ECDH function) from random. Given two secret, public key pairs $\{S_A,P_A\}$ and $\{S_B,P_B\}$, that is, this question asks how to distinguish $\operatorname{X25519}(S_A,P_B)$ (or, equivalently, $\operatorname{X25519}(S_B,P_A)$) from random, while the other question asks how to distinguish $P_A$ and $P_B$ from random.


Edit: Fixed names of variables. $S_*$ was intended to be $X_*$.

kelalaka avatar
in flag
Note that I don't see how this question is distinct from the last link.
William Martens avatar
gb flag
+1 agree it is either , very identical, or a small change, - @BenZ how is the question *distinct* ?
Ben Zelnick avatar
za flag
@WilliamMartens The other question asks about distinguishing X25519 *public **keys*** from random. This question asks about distinguishing the ***output** of the X25519 function* (i.e., the *shared secret computed with the ECDH function*) from random. Given two secret, public key pairs $\{S_A,P_A\}$ and $\{S_B,P_B\}$, that is, this question asks how to distinguish $\operatorname{X25519}(S_A,P_B)$ (or, equivalently, $\operatorname{X25519}(S_B,P_A)$) from random, while the other question asks how to distinguish $P_A$ and $P_B$ from random.
William Martens avatar
gb flag
@BenZ. Ohh okay, put that in the question :) so we know exactly that what it means
Ben Zelnick avatar
za flag
Done—thank you for the feedback!
William Martens avatar
gb flag
@BenZ. Thanks a lot! and no worries! Wishes from Sweden ^_^
Score:3
kr flag

Alice generates several $X_* = \operatorname{X25519}(S_*,P_*)$.

If Alice uses the X25519 function, the output will belong to $\mathbb{F_{2^{255}-19}}$ and will represent a $X$-coordinate of a point in the large prime-order subgroup of curve25519. This information can be used by Alice to distinguish from random 256 bit strings.

  1. Bob can look at the most significant bit $MSB(X_*)$, that due to little endian representation of X25519 this will be the eight bit from the right. This is zero for all public keys generated with $\operatorname{X25519}$ function. So if $MSB(X_*) = 1$ then Bob knows this is the random string.
  2. Given $X_*$ with $MSB(X_*)=0$ Bob can compute the square root of the value $X_*^3 + 486662X_*^2 + X_*$ in $\mathbb{F_{2^{255}-19}}$. If $X_*$ doesn't have a square root in the field then Bob knows this is the random string. On average, about half the value won't have a valid square root.

This two combined information allows Bob to distinguish with certainty that about $\frac{3}{4}$ of the random string are indeed random strings. This can be used to have an overall guessing accuracy of 75%.

Please note that the proper way of doing what the user is asking, without giving any advantage to Bob, would be to use the elligator scheme to encode public key points, but then there is a restriction on the usable public keys.

Score:-1
cx flag

The 248'th bit (big-endian) in the scalar multiplication is always set to zero.

kelalaka avatar
in flag
What about the lower bits?
fgrieu avatar
ng flag
I see no reasons why the 248'th bit (big-endian) of the _result_ of a scalar multiplication would be 0, in whatever common coordinate system. And I see no other well-defined meaning to the statement made.
mcore avatar
cx flag
See 1st point in Ruggero's answer. An eighth bit from the right is 248th bit from the left.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.