Encryption and decryption workflow
Phantom deeplinks are encrypted with the following workflows:Connect
- [dapp]: On the initial connect deeplink, dapps should include a
dapp_encryption_public_keyquery parameter. It’s recommended to create a new x25519 keypair for every session started withconnect. In all methods, the public key for this keypair is referred to asdapp_encryption_public_key. - [phantom]: Upon handling a
connectdeeplink, Phantom will also generate a new x25519 keypair.- Phantom will return this public key as
phantom_encryption_public_keyin theconnectresponse. - Phantom will create a secret key using Diffie-Hellman with
dapp_encryption_public_keyand the private key associated withphantom_encryption_public_key. - Phantom will locally store a mapping of
dapp_encryption_public_keyto shared secrets for use with decryption in subsequent deeplinks.
- Phantom will return this public key as
- [dapp]: Upon receiving the
connectresponse, the dapp should create a shared secret by using Diffie-Hellman withphantom_encryption_public_keyand the private key associated withdapp_encryption_public_key. This shared secret should then be used to decrypt thedatafield in the response. If done correctly, the user’s public key will be available to share with the dapp inside thedataJSON object.
Subsequent deeplinks
- [dapp]: For any subsequent methods (such as SignTransaction and SignMessage), dapps should send a
dapp_encryption_public_key(the public key side of the shared secret) used with Phantom along with an encryptedpayloadobject. - [phantom]: Upon approval, Phantom will encrypt the signed response as a JSON object with the encryption sent as a
data=query param. - [dapp]: Upon receiving the deeplink response, dapps should decrypt the object in the
data=query param to view the signature.