How can I get the user's wallet public key?

Hello community!

My master’s thesis will be made in Cardano, and I have a question I can’t find anywhere: How can I get the user’s public key?

I can get the user address at the time of wallet connection, but then, for security reasons, I want that some information is only available to that user. I realized I can make a user sign a transaction with a token to be used later, however, how can I get the public key to prove authenticity?

Thank you for your help :slight_smile:

The public key is kept secret until it’s needed (e.g. when sending ADA). So the user has to provide the public key. If the public key is given, you can verify that the address is derived from it. You can’t derive the public key from an address.

1 Like

Depends on the method used to sign. If you are using CIP 30’s signData, the public key is given to you in the response:

If you just let them sign a transaction with signTx you get a signed transaction back. You can just try to submit it and it will only be successful if the signature checks out. Or you can try to analyse the signed transaction with whatever library you use. It has to contain the public key in its witness set.