useGetSharedSecret
Generate a shared secret using Elliptic Curve Diffie-Hellman key exchange with your customers' Comet wallet.
Last updated
Generate a shared secret using Elliptic Curve Diffie-Hellman key exchange with your customers' Comet wallet.
Last updated
useGetSharedSecret
is an advanced feature of Comet's React SDK. Except for situations which require secure symmetric encryption, you will probably not need this React hook.
Using Comet's built in cloud wallets, users can perform Diffie-Hellman key exchange to generate a shared secret with another party's Solana public key. This shared secret can be used for secure communication between two Solana addresses.
In the example above, the publicKey
can be a string
, Buffer
, or Uint8Array
.
getSharedSecret
is a function that can be called later on, which will bring up the confirmation dialog. Users will be prompted to log in to Comet if needed. When the user clicks "Confirm", a shared secret will be calculated between the user's private key and the supplied public key.
getSharedSecret
returns a successful Promise
containing the shared secret in Uint8Array
format if the user clicks "Confirm"; otherwise it will return a failed Promise
if the user clicks "Cancel".