<p>There is a difference in encryption and signing.</p>
<ul>
<li><p><strong>Signing</strong> is the act of providing a piece of evidence alongside data that prove that the information is processed with a particular signing key. Given a public corresponding to the singing private key you can check if the data is aproved by that public key.</p>
</li>
<li><p><strong>Encryption</strong> is the act of obscuring data to make it not readable. Depending on what type of encryption you use, symmetric vs asymmetric, one can encrypt the data with a private key or public key. Decrypting can only be done with the private key.</p>
</li>
</ul>
<p>Cardano's wallets use an elliptic curve signature scheme <a href="https://en.wikipedia.org/wiki/Curve25519" rel="nofollow noreferrer">(1)</a>. Note that this can not encrypt data! It can only create signatures, you can verify signatures onchain with, for example <a href="https://playground.plutus.iohkdev.io/doc/haddock/plutus-tx/html/PlutusTx-Builtins-Internal.html#v:verifySignature" rel="nofollow noreferrer">(2)</a>. If you want to encrypt some data, you have to use another scheme (like the mentioned El-Gamal encryption scheme).</p>

CC BY-SA 4.0
2022-07-13T08:07:02.307Z
2022-07-13T08:07:02.307Z
Fermat
<p>If data is encrypted using the public key from a wallet is there a way to decrypt that data using the private key of the wallet? I am essentially looking for the inverse of <a href="https://github.com/cardano-foundation/CIPs/tree/master/CIP-0030#apisigndataaddr-address-payload-bytes-promisedatasignature" rel="nofollow noreferrer">signData</a> from CIP-0030. I'd like to encrypt a payload using the public key and then allow the user to decrypt it with their private key.</p>

CC BY-SA 4.0
2022-06-10T08:42:00.353Z
Please have a look at https://crypto.stackexchange.com/questions/83266/why-are-ed25519-keys-not-recommended-for-encryption
Fermat
CC BY-SA 4.0
2022-06-10T16:06:16.667Z
@Fermat thank you for the link as it was very helpful. What I had in mind was https://en.wikipedia.org/wiki/ElGamal_encryption where the key generation had already occurred when the wallet was created. From the answer in the link you posted, it looks like that should work fine or am I misreading that?
RJ Regenold
CC BY-SA 4.0
2022-06-10T16:12:10.260Z
I am familiar with El-Gamal (look at https://github.com/fermatspace/el-gamal-onchain for a small experiment onchain). The problem with key generation in the wallet is that it uses Ed25519 keys (El-gamal uses big integers). Now of course you could convert the Ed25519 binary representation of a key to an integer to fix this, but you will have to build the tools.
Fermat
CC BY-SA 4.0
2022-06-10T16:23:47.037Z
@Fermat thank you again. It is very cool that you already put together a little proof-of-concept for El-Gamal encryption on chain. Converting the binary representation of the Ed25519 key to an integer makes sense and I have no problem building the tools to do all this. Thank you for your help!
RJ Regenold
CC BY-SA 4.0
2022-06-10T16:54:01.453Z
No problem! Looking forward to your implementation :) Hope you open source it!
Fermat
<wallet>
Decrypt data with wallet private key
# Decrypt data with wallet private key

(Asked by: username_0 on 2022-06-08)

If data is encrypted using the public key from a wallet is there a way to decrypt that data using the private key of the wallet? I am essentially looking for the inverse of [signData](https://github.com/cardano-foundation/CIPs/tree/master/CIP-0030#apisigndataaddr-address-payload-bytes-promisedatasignature) from CIP-0030. I'd like to encrypt a payload using the public key and then allow the user to decrypt it with their private key.

**Tags:** wallet
> **Comments:**
> **username_1**: Please have a look at https://crypto.stackexchange.com/questions/83266/why-are-ed25519-keys-not-recommended-for-encryption  
> **username_0**: @Fermat thank you for the link as it was very helpful. What I had in mind was https://en.wikipedia.org/wiki/ElGamal_encryption where the key generation had already occurred when the wallet was created. From the answer in the link you posted, it looks like that should work fine or am I misreading that?  
> **username_1**: I am familiar with El-Gamal (look at https://github.com/fermatspace/el-gamal-onchain for a small experiment onchain). The problem with key generation in the wallet is that it uses Ed25519 keys (El-gamal uses big integers). Now of course you could convert the Ed25519 binary representation of a key to an integer to fix this, but you will have to build the tools.  
> **username_0**: @Fermat thank you again. It is very cool that you already put together a little proof-of-concept for El-Gamal encryption on chain. Converting the binary representation of the Ed25519 key to an integer makes sense and I have no problem building the tools to do all this. Thank you for your help!  
> **username_1**: No problem! Looking forward to your implementation :) Hope you open source it!  

---

## 1 answers

### Answer by username_1 on 2022-07-13. Score: 2 | Accepted answer

There is a difference in encryption and signing.

* **Signing** is the act of providing a piece of evidence alongside data that prove that the information is processed with a particular signing key. Given a public corresponding to the singing private key you can check if the data is aproved by that public key.
* **Encryption** is the act of obscuring data to make it not readable. Depending on what type of encryption you use, symmetric vs asymmetric, one can encrypt the data with a private key or public key. Decrypting can only be done with the private key.

Cardano's wallets use an elliptic curve signature scheme [(1)](https://en.wikipedia.org/wiki/Curve25519). Note that this can not encrypt data! It can only create signatures, you can verify signatures onchain with, for example [(2)](https://playground.plutus.iohkdev.io/doc/haddock/plutus-tx/html/PlutusTx-Builtins-Internal.html#v:verifySignature). If you want to encrypt some data, you have to use another scheme (like the mentioned El-Gamal encryption scheme).


---

