Like could I store the entirely encrypted file in IPFS and blockchain by having a single private key from my wallet to decrypt it, not by using GPG. I just wonder if this is possible.
You could, but in general, I would recommend against it, because keys are generally one time use. Most wallets do not reuse keys, they generate new keys for each transaction, for privacy.
However, for Bitcoin, you could use something like this eccrypto (Do your own research on the security of this implementation).
index.js
var crypto = require("crypto");
var eccrypto = require("eccrypto");
var privateKey = new Buffer("c337ded6f56c07205fb7b391654d7d463c9e0c726869523ae6024c9bec878878", "hex");
//var publicKey = eccrypto.getPublic(privateKey);
var publicKey = new Buffer("04730a151f545f5dcdb1c6d99fb1251f5c70f216f39ba2681bcf10db16bd582e6720bc881d51f25ffbe961df6a0af24a9d39a4db3d86a7f6b3f9bf4eaac0e4006b", "hex");
// Encrypting the message for B.
eccrypto.encrypt(publicKey, Buffer("msg")).then(function(encrypted) {
console.log('Encrypted message ' + JSON.stringify(encrypted));
// B decrypting the message.
eccrypto.decrypt(privateKey, encrypted).then(function(plaintext) {
console.log("Decrypted message: ", plaintext.toString());
});
});
Output
$ node index.js
Encrypted message {"iv":{"type":"Buffer","data":[204,13,168,25,80,255,9,233,111,60,165,204,180,126,53,65]},"ephemPublicKey":{"type":"Buffer","data":[4,192,3,65,241,134,65,186,52,52,250,61,208,189,216,167,122,206,156,152,27,173,69,152,37,138,164,5,54,189,227,88,37,243,220,183,22,204,235,37,212,110,207,66,225,244,25,92,69,223,247,175,218,228,134,210,247,190,211,248,239,77,183,21,36]},"ciphertext":{"type":"Buffer","data":[75,104,205,95,93,108,18,50,220,120,164,224,42,214,75,28]},"mac":{"type":"Buffer","data":[63,243,230,143,99,187,246,241,194,10,247,215,188,163,82,98,140,15,186,158,58,207,170,49,230,143,26,17,117,248,195,143]}}
Decrypted message: msg