Curve 25519 (X25519, Ed25519) Convert coordinates between Montgomery curve and twisted Edwards curve

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











up vote
2
down vote

favorite












I have some misunderstanding about EdDSA conversion coordinates between Montgomery curve and twisted Edwards curve. In https://tools.ietf.org/html/rfc7748 I see that a base point for Curve25519 is



Montgomery curve:



U(P) 9
V(P) 14781619447589544791020593568409986887264606134616475288964881837755586237401


Twisted Edwards curve:



X(P) 15112221349535400772501151409588531511454012693041857206046113283949847762202
Y(P) 46316835694926478169428394003475163141307993866256225615783033603165251855960


and then I see



The birational maps are:


$(u, v) = frac1+y1-y, sqrt-486664*fracux$



$(x, y) = sqrt-486664*fracuv, fracu-1u+1$



But if we try convert $(x,y)$ to $(u,v)$ or $(u,v)$ to $(x,y)$ by using these formulas, we will not get correct answers. For example convert y-coordinate to u-coordinate:



(1+46316835694926478169428394003475163141307993866256225615783033603165251855960)/(1-46316835694926478169428394003475163141307993866256225615783033603165251855960)


result will not be equal to



14781619447589544791020593568409986887264606134616475288964881837755586237401


How can I convert coordinates between Montgomery curve and twisted Edwards curve correctly?










share|improve this question



























    up vote
    2
    down vote

    favorite












    I have some misunderstanding about EdDSA conversion coordinates between Montgomery curve and twisted Edwards curve. In https://tools.ietf.org/html/rfc7748 I see that a base point for Curve25519 is



    Montgomery curve:



    U(P) 9
    V(P) 14781619447589544791020593568409986887264606134616475288964881837755586237401


    Twisted Edwards curve:



    X(P) 15112221349535400772501151409588531511454012693041857206046113283949847762202
    Y(P) 46316835694926478169428394003475163141307993866256225615783033603165251855960


    and then I see



    The birational maps are:


    $(u, v) = frac1+y1-y, sqrt-486664*fracux$



    $(x, y) = sqrt-486664*fracuv, fracu-1u+1$



    But if we try convert $(x,y)$ to $(u,v)$ or $(u,v)$ to $(x,y)$ by using these formulas, we will not get correct answers. For example convert y-coordinate to u-coordinate:



    (1+46316835694926478169428394003475163141307993866256225615783033603165251855960)/(1-46316835694926478169428394003475163141307993866256225615783033603165251855960)


    result will not be equal to



    14781619447589544791020593568409986887264606134616475288964881837755586237401


    How can I convert coordinates between Montgomery curve and twisted Edwards curve correctly?










    share|improve this question

























      up vote
      2
      down vote

      favorite









      up vote
      2
      down vote

      favorite











      I have some misunderstanding about EdDSA conversion coordinates between Montgomery curve and twisted Edwards curve. In https://tools.ietf.org/html/rfc7748 I see that a base point for Curve25519 is



      Montgomery curve:



      U(P) 9
      V(P) 14781619447589544791020593568409986887264606134616475288964881837755586237401


      Twisted Edwards curve:



      X(P) 15112221349535400772501151409588531511454012693041857206046113283949847762202
      Y(P) 46316835694926478169428394003475163141307993866256225615783033603165251855960


      and then I see



      The birational maps are:


      $(u, v) = frac1+y1-y, sqrt-486664*fracux$



      $(x, y) = sqrt-486664*fracuv, fracu-1u+1$



      But if we try convert $(x,y)$ to $(u,v)$ or $(u,v)$ to $(x,y)$ by using these formulas, we will not get correct answers. For example convert y-coordinate to u-coordinate:



      (1+46316835694926478169428394003475163141307993866256225615783033603165251855960)/(1-46316835694926478169428394003475163141307993866256225615783033603165251855960)


      result will not be equal to



      14781619447589544791020593568409986887264606134616475288964881837755586237401


      How can I convert coordinates between Montgomery curve and twisted Edwards curve correctly?










      share|improve this question















      I have some misunderstanding about EdDSA conversion coordinates between Montgomery curve and twisted Edwards curve. In https://tools.ietf.org/html/rfc7748 I see that a base point for Curve25519 is



      Montgomery curve:



      U(P) 9
      V(P) 14781619447589544791020593568409986887264606134616475288964881837755586237401


      Twisted Edwards curve:



      X(P) 15112221349535400772501151409588531511454012693041857206046113283949847762202
      Y(P) 46316835694926478169428394003475163141307993866256225615783033603165251855960


      and then I see



      The birational maps are:


      $(u, v) = frac1+y1-y, sqrt-486664*fracux$



      $(x, y) = sqrt-486664*fracuv, fracu-1u+1$



      But if we try convert $(x,y)$ to $(u,v)$ or $(u,v)$ to $(x,y)$ by using these formulas, we will not get correct answers. For example convert y-coordinate to u-coordinate:



      (1+46316835694926478169428394003475163141307993866256225615783033603165251855960)/(1-46316835694926478169428394003475163141307993866256225615783033603165251855960)


      result will not be equal to



      14781619447589544791020593568409986887264606134616475288964881837755586237401


      How can I convert coordinates between Montgomery curve and twisted Edwards curve correctly?







      elliptic-curves signature ed25519 x25519






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 2 hours ago









      Ruggero

      3,9991427




      3,9991427










      asked 4 hours ago









      sribin

      1057




      1057




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          3
          down vote



          accepted










          The formulas actually work.
          You just have to keep in mind to make computation in the field of intergers modulo $2^255-19$ and that there are actually two square roots, you need to use the right one if you want to have the expected result.



          You can test the following SAGE code



          gf=GF(2^255-19)
          X_P = gf(15112221349535400772501151409588531511454012693041857206046113283949847762202)
          Y_P = gf(46316835694926478169428394003475163141307993866256225615783033603165251855960)
          u = (1+Y_P)/(1-Y_P)
          v = gf(-486664).sqrt()*u/X_P,-(gf(-486664).sqrt())*u/X_P
          print u
          print v


          on the Sage Cell server.






          share|improve this answer




















            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: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            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%2f63732%2fcurve-25519-x25519-ed25519-convert-coordinates-between-montgomery-curve-and-t%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
            3
            down vote



            accepted










            The formulas actually work.
            You just have to keep in mind to make computation in the field of intergers modulo $2^255-19$ and that there are actually two square roots, you need to use the right one if you want to have the expected result.



            You can test the following SAGE code



            gf=GF(2^255-19)
            X_P = gf(15112221349535400772501151409588531511454012693041857206046113283949847762202)
            Y_P = gf(46316835694926478169428394003475163141307993866256225615783033603165251855960)
            u = (1+Y_P)/(1-Y_P)
            v = gf(-486664).sqrt()*u/X_P,-(gf(-486664).sqrt())*u/X_P
            print u
            print v


            on the Sage Cell server.






            share|improve this answer
























              up vote
              3
              down vote



              accepted










              The formulas actually work.
              You just have to keep in mind to make computation in the field of intergers modulo $2^255-19$ and that there are actually two square roots, you need to use the right one if you want to have the expected result.



              You can test the following SAGE code



              gf=GF(2^255-19)
              X_P = gf(15112221349535400772501151409588531511454012693041857206046113283949847762202)
              Y_P = gf(46316835694926478169428394003475163141307993866256225615783033603165251855960)
              u = (1+Y_P)/(1-Y_P)
              v = gf(-486664).sqrt()*u/X_P,-(gf(-486664).sqrt())*u/X_P
              print u
              print v


              on the Sage Cell server.






              share|improve this answer






















                up vote
                3
                down vote



                accepted







                up vote
                3
                down vote



                accepted






                The formulas actually work.
                You just have to keep in mind to make computation in the field of intergers modulo $2^255-19$ and that there are actually two square roots, you need to use the right one if you want to have the expected result.



                You can test the following SAGE code



                gf=GF(2^255-19)
                X_P = gf(15112221349535400772501151409588531511454012693041857206046113283949847762202)
                Y_P = gf(46316835694926478169428394003475163141307993866256225615783033603165251855960)
                u = (1+Y_P)/(1-Y_P)
                v = gf(-486664).sqrt()*u/X_P,-(gf(-486664).sqrt())*u/X_P
                print u
                print v


                on the Sage Cell server.






                share|improve this answer












                The formulas actually work.
                You just have to keep in mind to make computation in the field of intergers modulo $2^255-19$ and that there are actually two square roots, you need to use the right one if you want to have the expected result.



                You can test the following SAGE code



                gf=GF(2^255-19)
                X_P = gf(15112221349535400772501151409588531511454012693041857206046113283949847762202)
                Y_P = gf(46316835694926478169428394003475163141307993866256225615783033603165251855960)
                u = (1+Y_P)/(1-Y_P)
                v = gf(-486664).sqrt()*u/X_P,-(gf(-486664).sqrt())*u/X_P
                print u
                print v


                on the Sage Cell server.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 2 hours ago









                Ruggero

                3,9991427




                3,9991427



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcrypto.stackexchange.com%2fquestions%2f63732%2fcurve-25519-x25519-ed25519-convert-coordinates-between-montgomery-curve-and-t%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Comments

                    Popular posts from this blog

                    What does second last employer means? [closed]

                    List of Gilmore Girls characters

                    Confectionery