How would one “Encrypt” a message using a Bitcoin *public key* and use its private key to decrypt it?

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











up vote
1
down vote

favorite












I have the following text string:



This is a test message.



  • Using my bitcoin public key (bitcoin address?), how can I encrypt this message?


  • How would I decrypt the message using a bitcoin private key?










share|improve this question



















  • 1




    Do you want to encrypt to a public key, or using a password? Those two require very different technologies.
    – Pieter Wuille
    4 hours ago










  • basically take anyone's bitcoin address and encrypt a message, then send this person the encrypted message where he can decrypt with his bitcoin private key. Or that doesn't work at all?
    – Patoshi パトシ
    4 hours ago










  • But you're also mentioning AES and needing a password to decrypt?
    – Pieter Wuille
    4 hours ago










  • updated question. removed aes reference. was confusing.
    – Patoshi パトシ
    4 hours ago










  • Bitcoin address is derived from publickey but is not sufficient to encrypt.
    – dave_thompson_085
    6 mins ago














up vote
1
down vote

favorite












I have the following text string:



This is a test message.



  • Using my bitcoin public key (bitcoin address?), how can I encrypt this message?


  • How would I decrypt the message using a bitcoin private key?










share|improve this question



















  • 1




    Do you want to encrypt to a public key, or using a password? Those two require very different technologies.
    – Pieter Wuille
    4 hours ago










  • basically take anyone's bitcoin address and encrypt a message, then send this person the encrypted message where he can decrypt with his bitcoin private key. Or that doesn't work at all?
    – Patoshi パトシ
    4 hours ago










  • But you're also mentioning AES and needing a password to decrypt?
    – Pieter Wuille
    4 hours ago










  • updated question. removed aes reference. was confusing.
    – Patoshi パトシ
    4 hours ago










  • Bitcoin address is derived from publickey but is not sufficient to encrypt.
    – dave_thompson_085
    6 mins ago












up vote
1
down vote

favorite









up vote
1
down vote

favorite











I have the following text string:



This is a test message.



  • Using my bitcoin public key (bitcoin address?), how can I encrypt this message?


  • How would I decrypt the message using a bitcoin private key?










share|improve this question















I have the following text string:



This is a test message.



  • Using my bitcoin public key (bitcoin address?), how can I encrypt this message?


  • How would I decrypt the message using a bitcoin private key?







private-key public-key encryption






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 4 hours ago

























asked 4 hours ago









Patoshi パトシ

3,292105190




3,292105190







  • 1




    Do you want to encrypt to a public key, or using a password? Those two require very different technologies.
    – Pieter Wuille
    4 hours ago










  • basically take anyone's bitcoin address and encrypt a message, then send this person the encrypted message where he can decrypt with his bitcoin private key. Or that doesn't work at all?
    – Patoshi パトシ
    4 hours ago










  • But you're also mentioning AES and needing a password to decrypt?
    – Pieter Wuille
    4 hours ago










  • updated question. removed aes reference. was confusing.
    – Patoshi パトシ
    4 hours ago










  • Bitcoin address is derived from publickey but is not sufficient to encrypt.
    – dave_thompson_085
    6 mins ago












  • 1




    Do you want to encrypt to a public key, or using a password? Those two require very different technologies.
    – Pieter Wuille
    4 hours ago










  • basically take anyone's bitcoin address and encrypt a message, then send this person the encrypted message where he can decrypt with his bitcoin private key. Or that doesn't work at all?
    – Patoshi パトシ
    4 hours ago










  • But you're also mentioning AES and needing a password to decrypt?
    – Pieter Wuille
    4 hours ago










  • updated question. removed aes reference. was confusing.
    – Patoshi パトシ
    4 hours ago










  • Bitcoin address is derived from publickey but is not sufficient to encrypt.
    – dave_thompson_085
    6 mins ago







1




1




Do you want to encrypt to a public key, or using a password? Those two require very different technologies.
– Pieter Wuille
4 hours ago




Do you want to encrypt to a public key, or using a password? Those two require very different technologies.
– Pieter Wuille
4 hours ago












basically take anyone's bitcoin address and encrypt a message, then send this person the encrypted message where he can decrypt with his bitcoin private key. Or that doesn't work at all?
– Patoshi パトシ
4 hours ago




basically take anyone's bitcoin address and encrypt a message, then send this person the encrypted message where he can decrypt with his bitcoin private key. Or that doesn't work at all?
– Patoshi パトシ
4 hours ago












But you're also mentioning AES and needing a password to decrypt?
– Pieter Wuille
4 hours ago




But you're also mentioning AES and needing a password to decrypt?
– Pieter Wuille
4 hours ago












updated question. removed aes reference. was confusing.
– Patoshi パトシ
4 hours ago




updated question. removed aes reference. was confusing.
– Patoshi パトシ
4 hours ago












Bitcoin address is derived from publickey but is not sufficient to encrypt.
– dave_thompson_085
6 mins ago




Bitcoin address is derived from publickey but is not sufficient to encrypt.
– dave_thompson_085
6 mins ago










3 Answers
3






active

oldest

votes

















up vote
3
down vote













If you want to encrypt messages, you should use a proper message/file encryption tool like PGP/GPG. Homebrewed cryptography using bitcoin things is prone to having poor security properties.






share|improve this answer



























    up vote
    3
    down vote













    Yes, this is possible.



    However, I want to upfront state that this is not advisable for multiple reasons:



    • Bitcoin keys are intended to be single use for privacy reasons, and leveraging them for encryption unnecessarily encourages treating them as a long-lived identity.

    • There may be ugly and dangerous interactions when keys are used for multiple protocols independently.

    • You're much better off using systems that were actually designed for encryption than trying to piggy-back off Bitcoin's cryptography.

    • Implementing your own cryptography is very dangerous (in general, unless you know what you're doing, and get plenty of review from experts).

    A scheme called ECIES exists that lets you leverage elliptic curve keys to create an encryption system.



    In short, it works by:



    The sender:



    • generates an ephemeral private key k using a strong cryptographic random number generator, with associated public key k = kG (multiplication refers to Elliptic Curve multiplication here).

    • computes an ECDH shared secret s = H(kP), where P is the public key of the recipient.

    • encrypts the message m using AES, with s as the key, to obtain c = AECEncs(m).

    • sends K and c to the recipient.

    The recipient:



    • also computes the ECDH shared secret, using s = H(pK), where p is his private key.

    • decrypts the message using s, m' = AESDecs(c).





    share|improve this answer



























      up vote
      1
      down vote













      Be sure to follow the warnings given previously in other answers, but for the record there is an npm module that implemented this: eccrypto (DYOR on it's security):



      Install dependencies



      $ npm install -g eccrypto


      index.js



      var crypto = require("crypto");
      var eccrypto = require("eccrypto");

      var privateKeyA = crypto.randomBytes(32);
      var publicKeyA = eccrypto.getPublic(privateKeyA);
      var privateKeyB = crypto.randomBytes(32);
      var publicKeyB = eccrypto.getPublic(privateKeyB);

      // Encrypting the message for B.
      eccrypto.encrypt(publicKeyB, Buffer("msg to b")).then(function(encrypted)
      // B decrypting the message.
      eccrypto.decrypt(privateKeyB, encrypted).then(function(plaintext)
      console.log("Message to part B:", plaintext.toString());
      );
      );

      // Encrypting the message for A.
      eccrypto.encrypt(publicKeyA, Buffer("msg to a")).then(function(encrypted)
      // A decrypting the message.
      eccrypto.decrypt(privateKeyA, encrypted).then(function(plaintext)
      console.log("Message to part A:", plaintext.toString());
      );
      );





      share|improve this answer




















        Your Answer








        StackExchange.ready(function()
        var channelOptions =
        tags: "".split(" "),
        id: "308"
        ;
        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%2fbitcoin.stackexchange.com%2fquestions%2f80638%2fhow-would-one-encrypt-a-message-using-a-bitcoin-public-key-and-use-its-priva%23new-answer', 'question_page');

        );

        Post as a guest






























        3 Answers
        3






        active

        oldest

        votes








        3 Answers
        3






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes








        up vote
        3
        down vote













        If you want to encrypt messages, you should use a proper message/file encryption tool like PGP/GPG. Homebrewed cryptography using bitcoin things is prone to having poor security properties.






        share|improve this answer
























          up vote
          3
          down vote













          If you want to encrypt messages, you should use a proper message/file encryption tool like PGP/GPG. Homebrewed cryptography using bitcoin things is prone to having poor security properties.






          share|improve this answer






















            up vote
            3
            down vote










            up vote
            3
            down vote









            If you want to encrypt messages, you should use a proper message/file encryption tool like PGP/GPG. Homebrewed cryptography using bitcoin things is prone to having poor security properties.






            share|improve this answer












            If you want to encrypt messages, you should use a proper message/file encryption tool like PGP/GPG. Homebrewed cryptography using bitcoin things is prone to having poor security properties.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered 4 hours ago









            G. Maxwell

            1,806218




            1,806218




















                up vote
                3
                down vote













                Yes, this is possible.



                However, I want to upfront state that this is not advisable for multiple reasons:



                • Bitcoin keys are intended to be single use for privacy reasons, and leveraging them for encryption unnecessarily encourages treating them as a long-lived identity.

                • There may be ugly and dangerous interactions when keys are used for multiple protocols independently.

                • You're much better off using systems that were actually designed for encryption than trying to piggy-back off Bitcoin's cryptography.

                • Implementing your own cryptography is very dangerous (in general, unless you know what you're doing, and get plenty of review from experts).

                A scheme called ECIES exists that lets you leverage elliptic curve keys to create an encryption system.



                In short, it works by:



                The sender:



                • generates an ephemeral private key k using a strong cryptographic random number generator, with associated public key k = kG (multiplication refers to Elliptic Curve multiplication here).

                • computes an ECDH shared secret s = H(kP), where P is the public key of the recipient.

                • encrypts the message m using AES, with s as the key, to obtain c = AECEncs(m).

                • sends K and c to the recipient.

                The recipient:



                • also computes the ECDH shared secret, using s = H(pK), where p is his private key.

                • decrypts the message using s, m' = AESDecs(c).





                share|improve this answer
























                  up vote
                  3
                  down vote













                  Yes, this is possible.



                  However, I want to upfront state that this is not advisable for multiple reasons:



                  • Bitcoin keys are intended to be single use for privacy reasons, and leveraging them for encryption unnecessarily encourages treating them as a long-lived identity.

                  • There may be ugly and dangerous interactions when keys are used for multiple protocols independently.

                  • You're much better off using systems that were actually designed for encryption than trying to piggy-back off Bitcoin's cryptography.

                  • Implementing your own cryptography is very dangerous (in general, unless you know what you're doing, and get plenty of review from experts).

                  A scheme called ECIES exists that lets you leverage elliptic curve keys to create an encryption system.



                  In short, it works by:



                  The sender:



                  • generates an ephemeral private key k using a strong cryptographic random number generator, with associated public key k = kG (multiplication refers to Elliptic Curve multiplication here).

                  • computes an ECDH shared secret s = H(kP), where P is the public key of the recipient.

                  • encrypts the message m using AES, with s as the key, to obtain c = AECEncs(m).

                  • sends K and c to the recipient.

                  The recipient:



                  • also computes the ECDH shared secret, using s = H(pK), where p is his private key.

                  • decrypts the message using s, m' = AESDecs(c).





                  share|improve this answer






















                    up vote
                    3
                    down vote










                    up vote
                    3
                    down vote









                    Yes, this is possible.



                    However, I want to upfront state that this is not advisable for multiple reasons:



                    • Bitcoin keys are intended to be single use for privacy reasons, and leveraging them for encryption unnecessarily encourages treating them as a long-lived identity.

                    • There may be ugly and dangerous interactions when keys are used for multiple protocols independently.

                    • You're much better off using systems that were actually designed for encryption than trying to piggy-back off Bitcoin's cryptography.

                    • Implementing your own cryptography is very dangerous (in general, unless you know what you're doing, and get plenty of review from experts).

                    A scheme called ECIES exists that lets you leverage elliptic curve keys to create an encryption system.



                    In short, it works by:



                    The sender:



                    • generates an ephemeral private key k using a strong cryptographic random number generator, with associated public key k = kG (multiplication refers to Elliptic Curve multiplication here).

                    • computes an ECDH shared secret s = H(kP), where P is the public key of the recipient.

                    • encrypts the message m using AES, with s as the key, to obtain c = AECEncs(m).

                    • sends K and c to the recipient.

                    The recipient:



                    • also computes the ECDH shared secret, using s = H(pK), where p is his private key.

                    • decrypts the message using s, m' = AESDecs(c).





                    share|improve this answer












                    Yes, this is possible.



                    However, I want to upfront state that this is not advisable for multiple reasons:



                    • Bitcoin keys are intended to be single use for privacy reasons, and leveraging them for encryption unnecessarily encourages treating them as a long-lived identity.

                    • There may be ugly and dangerous interactions when keys are used for multiple protocols independently.

                    • You're much better off using systems that were actually designed for encryption than trying to piggy-back off Bitcoin's cryptography.

                    • Implementing your own cryptography is very dangerous (in general, unless you know what you're doing, and get plenty of review from experts).

                    A scheme called ECIES exists that lets you leverage elliptic curve keys to create an encryption system.



                    In short, it works by:



                    The sender:



                    • generates an ephemeral private key k using a strong cryptographic random number generator, with associated public key k = kG (multiplication refers to Elliptic Curve multiplication here).

                    • computes an ECDH shared secret s = H(kP), where P is the public key of the recipient.

                    • encrypts the message m using AES, with s as the key, to obtain c = AECEncs(m).

                    • sends K and c to the recipient.

                    The recipient:



                    • also computes the ECDH shared secret, using s = H(pK), where p is his private key.

                    • decrypts the message using s, m' = AESDecs(c).






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered 4 hours ago









                    Pieter Wuille

                    43.4k290148




                    43.4k290148




















                        up vote
                        1
                        down vote













                        Be sure to follow the warnings given previously in other answers, but for the record there is an npm module that implemented this: eccrypto (DYOR on it's security):



                        Install dependencies



                        $ npm install -g eccrypto


                        index.js



                        var crypto = require("crypto");
                        var eccrypto = require("eccrypto");

                        var privateKeyA = crypto.randomBytes(32);
                        var publicKeyA = eccrypto.getPublic(privateKeyA);
                        var privateKeyB = crypto.randomBytes(32);
                        var publicKeyB = eccrypto.getPublic(privateKeyB);

                        // Encrypting the message for B.
                        eccrypto.encrypt(publicKeyB, Buffer("msg to b")).then(function(encrypted)
                        // B decrypting the message.
                        eccrypto.decrypt(privateKeyB, encrypted).then(function(plaintext)
                        console.log("Message to part B:", plaintext.toString());
                        );
                        );

                        // Encrypting the message for A.
                        eccrypto.encrypt(publicKeyA, Buffer("msg to a")).then(function(encrypted)
                        // A decrypting the message.
                        eccrypto.decrypt(privateKeyA, encrypted).then(function(plaintext)
                        console.log("Message to part A:", plaintext.toString());
                        );
                        );





                        share|improve this answer
























                          up vote
                          1
                          down vote













                          Be sure to follow the warnings given previously in other answers, but for the record there is an npm module that implemented this: eccrypto (DYOR on it's security):



                          Install dependencies



                          $ npm install -g eccrypto


                          index.js



                          var crypto = require("crypto");
                          var eccrypto = require("eccrypto");

                          var privateKeyA = crypto.randomBytes(32);
                          var publicKeyA = eccrypto.getPublic(privateKeyA);
                          var privateKeyB = crypto.randomBytes(32);
                          var publicKeyB = eccrypto.getPublic(privateKeyB);

                          // Encrypting the message for B.
                          eccrypto.encrypt(publicKeyB, Buffer("msg to b")).then(function(encrypted)
                          // B decrypting the message.
                          eccrypto.decrypt(privateKeyB, encrypted).then(function(plaintext)
                          console.log("Message to part B:", plaintext.toString());
                          );
                          );

                          // Encrypting the message for A.
                          eccrypto.encrypt(publicKeyA, Buffer("msg to a")).then(function(encrypted)
                          // A decrypting the message.
                          eccrypto.decrypt(privateKeyA, encrypted).then(function(plaintext)
                          console.log("Message to part A:", plaintext.toString());
                          );
                          );





                          share|improve this answer






















                            up vote
                            1
                            down vote










                            up vote
                            1
                            down vote









                            Be sure to follow the warnings given previously in other answers, but for the record there is an npm module that implemented this: eccrypto (DYOR on it's security):



                            Install dependencies



                            $ npm install -g eccrypto


                            index.js



                            var crypto = require("crypto");
                            var eccrypto = require("eccrypto");

                            var privateKeyA = crypto.randomBytes(32);
                            var publicKeyA = eccrypto.getPublic(privateKeyA);
                            var privateKeyB = crypto.randomBytes(32);
                            var publicKeyB = eccrypto.getPublic(privateKeyB);

                            // Encrypting the message for B.
                            eccrypto.encrypt(publicKeyB, Buffer("msg to b")).then(function(encrypted)
                            // B decrypting the message.
                            eccrypto.decrypt(privateKeyB, encrypted).then(function(plaintext)
                            console.log("Message to part B:", plaintext.toString());
                            );
                            );

                            // Encrypting the message for A.
                            eccrypto.encrypt(publicKeyA, Buffer("msg to a")).then(function(encrypted)
                            // A decrypting the message.
                            eccrypto.decrypt(privateKeyA, encrypted).then(function(plaintext)
                            console.log("Message to part A:", plaintext.toString());
                            );
                            );





                            share|improve this answer












                            Be sure to follow the warnings given previously in other answers, but for the record there is an npm module that implemented this: eccrypto (DYOR on it's security):



                            Install dependencies



                            $ npm install -g eccrypto


                            index.js



                            var crypto = require("crypto");
                            var eccrypto = require("eccrypto");

                            var privateKeyA = crypto.randomBytes(32);
                            var publicKeyA = eccrypto.getPublic(privateKeyA);
                            var privateKeyB = crypto.randomBytes(32);
                            var publicKeyB = eccrypto.getPublic(privateKeyB);

                            // Encrypting the message for B.
                            eccrypto.encrypt(publicKeyB, Buffer("msg to b")).then(function(encrypted)
                            // B decrypting the message.
                            eccrypto.decrypt(privateKeyB, encrypted).then(function(plaintext)
                            console.log("Message to part B:", plaintext.toString());
                            );
                            );

                            // Encrypting the message for A.
                            eccrypto.encrypt(publicKeyA, Buffer("msg to a")).then(function(encrypted)
                            // A decrypting the message.
                            eccrypto.decrypt(privateKeyA, encrypted).then(function(plaintext)
                            console.log("Message to part A:", plaintext.toString());
                            );
                            );






                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered 3 hours ago









                            JBaczuk

                            3,0361320




                            3,0361320



























                                 

                                draft saved


                                draft discarded















































                                 


                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function ()
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fbitcoin.stackexchange.com%2fquestions%2f80638%2fhow-would-one-encrypt-a-message-using-a-bitcoin-public-key-and-use-its-priva%23new-answer', 'question_page');

                                );

                                Post as a guest













































































                                Comments

                                Popular posts from this blog

                                Long meetings (6-7 hours a day): Being “babysat” by supervisor

                                Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

                                Confectionery