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?
2 Answers
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.