How would one âEncryptâ a message using a Bitcoin *public key* and use its private key to decrypt it?
Clash 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?
private-key public-key encryption
add a comment |Â
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?
private-key public-key encryption
1
Do you want to encrypt to a public key, or using a password? Those two require very different technologies.
â Pieter Wuille
5 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 ãÂÂãÂÂã·
5 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
33 mins ago
add a comment |Â
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?
private-key public-key encryption
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
private-key public-key encryption
edited 4 hours ago
asked 5 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
5 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 ãÂÂãÂÂã·
5 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
33 mins ago
add a comment |Â
1
Do you want to encrypt to a public key, or using a password? Those two require very different technologies.
â Pieter Wuille
5 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 ãÂÂãÂÂã·
5 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
33 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
5 hours ago
Do you want to encrypt to a public key, or using a password? Those two require very different technologies.
â Pieter Wuille
5 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 ãÂÂãÂÂã·
5 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 ãÂÂãÂÂã·
5 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
33 mins ago
Bitcoin address is derived from publickey but is not sufficient to encrypt.
â dave_thompson_085
33 mins ago
add a comment |Â
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.
add a comment |Â
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).
add a comment |Â
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());
);
);
add a comment |Â
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.
add a comment |Â
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.
add a comment |Â
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.
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.
answered 4 hours ago
G. Maxwell
1,806218
1,806218
add a comment |Â
add a comment |Â
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).
add a comment |Â
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).
add a comment |Â
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).
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).
answered 4 hours ago
Pieter Wuille
43.4k290148
43.4k290148
add a comment |Â
add a comment |Â
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());
);
);
add a comment |Â
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());
);
);
add a comment |Â
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());
);
);
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());
);
);
answered 3 hours ago
JBaczuk
3,0361320
3,0361320
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
Do you want to encrypt to a public key, or using a password? Those two require very different technologies.
â Pieter Wuille
5 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 ãÂÂãÂÂã·
5 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
33 mins ago