2

Questions:

  1. In Solidity, how can we fetch the encrypted public key for the wallet directly from the smart contract using solidity? I have managed to retrieve it using JavaScript, but I need to know how we can use this functionality within the Solidity smart contract itself. The JavaScript function used for the retrieval can be found here: https://docs.metamask.io/wallet/reference/eth_getencryptionpublickey

  2. How can we encrypt a message using the 'x25519-xsalsa20-poly1305' version directly within a Solidity smart contract? I've successfully accomplished this in JavaScript, as shown in the code snippet below, Do we have a similar method in Solidity?

javascript
import sigUtil from '@metamask/eth-sig-util';
const value = sigUtil.encrypt({ publicKey: key, data: msg, version: 'x25519-xsalsa20-poly1305' });
const buf = Buffer.from(JSON.stringify(value), 'utf8');
const returnValue = '0x' + buf.toString('hex');

Any input is appreciated.

1 Answer 1

1

In Solidity, how can we fetch the encrypted public key for the wallet directly from the smart contract using solidity?

You cannot.

How can we encrypt a message using the 'x25519-xsalsa20-poly1305' version directly within a Solidity smart contract?

You cannot.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.