<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>

CC BY-SA 4.0
2022-07-01T11:55:15.490Z
2022-07-01T11:55:15.490Z
sean
<p>You can't access the secret/private key of a wallet connected to your web site.</p>

CC BY-SA 4.0
2022-07-01T11:44:14.300Z
2022-07-01T11:44:14.300Z
eddex
<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>

<wallet><nami-wallet><public-key><signing-key-file><lightwallet>
How to Access Secret Key Hash and PKH from a web wallet?
# How to Access Secret Key Hash and PKH from a web wallet?

(Asked by: username_0 on 2022-07-01)

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?

**Tags:** wallet, nami-wallet, public-key, signing-key-file, lightwallet

---

## 2 answers

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

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.


---

### Answer by username_2 on 2022-07-01. Score: 1

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


---

