user5844: So I'm making a Dapp that uses the user's secret key to encrypt the data. It also allows another user to encrypt something else using their public key hash, but how do I get the key pairs from the web wallet integrated with my Dapp?

user1142: You can't access the secret/private key of a wallet connected to your web site.

user4627: You can't directly access private keys of your users; those should reside safely in their wallet only.
There is, however, a way you can have their wallet use those keys to sign data that you pass over.
This is described in CIP 30: https://cips.cardano.org/cips/cip30/#apisigndataaddraddresspayloadbytespromisedatasignature
You call this function in the browser like so:
window.cardano.signData(Address, HexMsgToSign)

The wallet will then open a window showing the message and asking the user to sign, and return the signature.

5844: <p>So I'm making a Dapp that uses the user's secret key to encrypt the data. It also allows another user to encrypt something else using their public key hash, but how do I get the key pairs from the web wallet integrated with my Dapp?</p>
 1142: <p>You can't access the secret/private key of a wallet connected to your web site.</p>
 4627: <p>You can't directly access private keys of your users; those should reside safely in their wallet only.</p>
<p>There is, however, a way you can have their wallet use those keys to sign data that you pass over.</p>
<p>This is described in CIP 30: <a href="https://cips.cardano.org/cips/cip30/#apisigndataaddraddresspayloadbytespromisedatasignature" rel="nofollow noreferrer">https://cips.cardano.org/cips/cip30/#apisigndataaddraddresspayloadbytespromisedatasignature</a></p>
<p>You call this function in the browser like so:</p>
<pre><code>window.cardano.signData(Address, HexMsgToSign)
</code></pre>
<p>The wallet will then open a window showing the message and asking the user to sign, and return the signature.</p>
