Distinguishing x25519 public keys from random?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
20
down vote

favorite
2












I recently read a piece of protocol that avoided sending ephemeral x25519 keys in the clear as an effort to foil deep-packet inspection.



I understand that x25519 public keys are effectively 255 bits, which must be serialized as 256 bits, leaving one unused bit that libraries typically fix as 0. For the purposes of this question, I'd like to leave this out and focus on the 255 used bits.



Alice generates a random private key K, and 255-bit public key K'. She generates R, a 255-bit random string. She flips a fair coin, and if heads, she sends a message M = K'. Otherwise, she sends M = R.



Eve receives this message and does not know K. She must guess whether M = K'. Can she do this with better than the 50% success rate she'd get by guessing? (In other words, can she distinguish the significant bits of a x25519 public key from random?)



edit: in response to a question, Eve has knowledge of the curve parameters.







share|improve this question






















  • You can use the elligator2 encoding to avoid this
    – CodesInChaos♦
    Aug 27 at 19:33














up vote
20
down vote

favorite
2












I recently read a piece of protocol that avoided sending ephemeral x25519 keys in the clear as an effort to foil deep-packet inspection.



I understand that x25519 public keys are effectively 255 bits, which must be serialized as 256 bits, leaving one unused bit that libraries typically fix as 0. For the purposes of this question, I'd like to leave this out and focus on the 255 used bits.



Alice generates a random private key K, and 255-bit public key K'. She generates R, a 255-bit random string. She flips a fair coin, and if heads, she sends a message M = K'. Otherwise, she sends M = R.



Eve receives this message and does not know K. She must guess whether M = K'. Can she do this with better than the 50% success rate she'd get by guessing? (In other words, can she distinguish the significant bits of a x25519 public key from random?)



edit: in response to a question, Eve has knowledge of the curve parameters.







share|improve this question






















  • You can use the elligator2 encoding to avoid this
    – CodesInChaos♦
    Aug 27 at 19:33












up vote
20
down vote

favorite
2









up vote
20
down vote

favorite
2






2





I recently read a piece of protocol that avoided sending ephemeral x25519 keys in the clear as an effort to foil deep-packet inspection.



I understand that x25519 public keys are effectively 255 bits, which must be serialized as 256 bits, leaving one unused bit that libraries typically fix as 0. For the purposes of this question, I'd like to leave this out and focus on the 255 used bits.



Alice generates a random private key K, and 255-bit public key K'. She generates R, a 255-bit random string. She flips a fair coin, and if heads, she sends a message M = K'. Otherwise, she sends M = R.



Eve receives this message and does not know K. She must guess whether M = K'. Can she do this with better than the 50% success rate she'd get by guessing? (In other words, can she distinguish the significant bits of a x25519 public key from random?)



edit: in response to a question, Eve has knowledge of the curve parameters.







share|improve this question














I recently read a piece of protocol that avoided sending ephemeral x25519 keys in the clear as an effort to foil deep-packet inspection.



I understand that x25519 public keys are effectively 255 bits, which must be serialized as 256 bits, leaving one unused bit that libraries typically fix as 0. For the purposes of this question, I'd like to leave this out and focus on the 255 used bits.



Alice generates a random private key K, and 255-bit public key K'. She generates R, a 255-bit random string. She flips a fair coin, and if heads, she sends a message M = K'. Otherwise, she sends M = R.



Eve receives this message and does not know K. She must guess whether M = K'. Can she do this with better than the 50% success rate she'd get by guessing? (In other words, can she distinguish the significant bits of a x25519 public key from random?)



edit: in response to a question, Eve has knowledge of the curve parameters.









share|improve this question













share|improve this question




share|improve this question








edited Aug 26 at 19:01

























asked Aug 26 at 16:52









Jonas

422110




422110











  • You can use the elligator2 encoding to avoid this
    – CodesInChaos♦
    Aug 27 at 19:33
















  • You can use the elligator2 encoding to avoid this
    – CodesInChaos♦
    Aug 27 at 19:33















You can use the elligator2 encoding to avoid this
– CodesInChaos♦
Aug 27 at 19:33




You can use the elligator2 encoding to avoid this
– CodesInChaos♦
Aug 27 at 19:33










1 Answer
1






active

oldest

votes

















up vote
21
down vote



accepted










A valid point of an elliptic curve in Weierstrass form satisfies the equation
$$
y^2 = x^3 + ax + b,.
$$
We can rewrite this as $y = pm sqrtx^3 + ax + b$, which has either 2 solutions when $x^3 + ax + b$ is a square, 1 solution when $x^3 + ax + b = 0$, or 0 solutions when $x^3 + ax + b$ is not a square.



In X25519, we only see the $x$ coordinate, but we can still make use of the above. The curve equation is
$$
y^2 = x^3 + 486662x^2 + x bmod 2^255-19,,
$$
from which we have that given a valid public key $x$, $x^3 + 486662x^2 + x$ must have a square root modulo $2^255-19$. On the other hand, a random string will be a square only around $1/2$ of the time. By inspecting $n$ candidate public keys, we can improve our certainty to $1 - 1/2^n$.






share|improve this answer
















  • 1




    The projection onto the prime order subgroup should give another 3 bits per attempt, if the standard implementation of curve25519 is used.
    – CodesInChaos♦
    Aug 27 at 19:35










Your Answer




StackExchange.ifUsing("editor", function ()
return StackExchange.using("mathjaxEditing", function ()
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
);
);
, "mathjax-editing");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "281"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcrypto.stackexchange.com%2fquestions%2f61777%2fdistinguishing-x25519-public-keys-from-random%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
21
down vote



accepted










A valid point of an elliptic curve in Weierstrass form satisfies the equation
$$
y^2 = x^3 + ax + b,.
$$
We can rewrite this as $y = pm sqrtx^3 + ax + b$, which has either 2 solutions when $x^3 + ax + b$ is a square, 1 solution when $x^3 + ax + b = 0$, or 0 solutions when $x^3 + ax + b$ is not a square.



In X25519, we only see the $x$ coordinate, but we can still make use of the above. The curve equation is
$$
y^2 = x^3 + 486662x^2 + x bmod 2^255-19,,
$$
from which we have that given a valid public key $x$, $x^3 + 486662x^2 + x$ must have a square root modulo $2^255-19$. On the other hand, a random string will be a square only around $1/2$ of the time. By inspecting $n$ candidate public keys, we can improve our certainty to $1 - 1/2^n$.






share|improve this answer
















  • 1




    The projection onto the prime order subgroup should give another 3 bits per attempt, if the standard implementation of curve25519 is used.
    – CodesInChaos♦
    Aug 27 at 19:35














up vote
21
down vote



accepted










A valid point of an elliptic curve in Weierstrass form satisfies the equation
$$
y^2 = x^3 + ax + b,.
$$
We can rewrite this as $y = pm sqrtx^3 + ax + b$, which has either 2 solutions when $x^3 + ax + b$ is a square, 1 solution when $x^3 + ax + b = 0$, or 0 solutions when $x^3 + ax + b$ is not a square.



In X25519, we only see the $x$ coordinate, but we can still make use of the above. The curve equation is
$$
y^2 = x^3 + 486662x^2 + x bmod 2^255-19,,
$$
from which we have that given a valid public key $x$, $x^3 + 486662x^2 + x$ must have a square root modulo $2^255-19$. On the other hand, a random string will be a square only around $1/2$ of the time. By inspecting $n$ candidate public keys, we can improve our certainty to $1 - 1/2^n$.






share|improve this answer
















  • 1




    The projection onto the prime order subgroup should give another 3 bits per attempt, if the standard implementation of curve25519 is used.
    – CodesInChaos♦
    Aug 27 at 19:35












up vote
21
down vote



accepted







up vote
21
down vote



accepted






A valid point of an elliptic curve in Weierstrass form satisfies the equation
$$
y^2 = x^3 + ax + b,.
$$
We can rewrite this as $y = pm sqrtx^3 + ax + b$, which has either 2 solutions when $x^3 + ax + b$ is a square, 1 solution when $x^3 + ax + b = 0$, or 0 solutions when $x^3 + ax + b$ is not a square.



In X25519, we only see the $x$ coordinate, but we can still make use of the above. The curve equation is
$$
y^2 = x^3 + 486662x^2 + x bmod 2^255-19,,
$$
from which we have that given a valid public key $x$, $x^3 + 486662x^2 + x$ must have a square root modulo $2^255-19$. On the other hand, a random string will be a square only around $1/2$ of the time. By inspecting $n$ candidate public keys, we can improve our certainty to $1 - 1/2^n$.






share|improve this answer












A valid point of an elliptic curve in Weierstrass form satisfies the equation
$$
y^2 = x^3 + ax + b,.
$$
We can rewrite this as $y = pm sqrtx^3 + ax + b$, which has either 2 solutions when $x^3 + ax + b$ is a square, 1 solution when $x^3 + ax + b = 0$, or 0 solutions when $x^3 + ax + b$ is not a square.



In X25519, we only see the $x$ coordinate, but we can still make use of the above. The curve equation is
$$
y^2 = x^3 + 486662x^2 + x bmod 2^255-19,,
$$
from which we have that given a valid public key $x$, $x^3 + 486662x^2 + x$ must have a square root modulo $2^255-19$. On the other hand, a random string will be a square only around $1/2$ of the time. By inspecting $n$ candidate public keys, we can improve our certainty to $1 - 1/2^n$.







share|improve this answer












share|improve this answer



share|improve this answer










answered Aug 26 at 21:36









Samuel Neves

7,0972540




7,0972540







  • 1




    The projection onto the prime order subgroup should give another 3 bits per attempt, if the standard implementation of curve25519 is used.
    – CodesInChaos♦
    Aug 27 at 19:35












  • 1




    The projection onto the prime order subgroup should give another 3 bits per attempt, if the standard implementation of curve25519 is used.
    – CodesInChaos♦
    Aug 27 at 19:35







1




1




The projection onto the prime order subgroup should give another 3 bits per attempt, if the standard implementation of curve25519 is used.
– CodesInChaos♦
Aug 27 at 19:35




The projection onto the prime order subgroup should give another 3 bits per attempt, if the standard implementation of curve25519 is used.
– CodesInChaos♦
Aug 27 at 19:35

















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcrypto.stackexchange.com%2fquestions%2f61777%2fdistinguishing-x25519-public-keys-from-random%23new-answer', 'question_page');

);

Post as a guest













































































這個網誌中的熱門文章

How to combine Bézier curves to a surface?

Why am i infinitely getting the same tweet with the Twitter Search API?

Carbon dioxide