I am able to sign a message on the client side using something like this:

const encodedMessage = new TextEncoder().encode("some message");
const signedMessage = await provider.signMessage(encodedMessage, "utf8");

Now I want to verify the signature on the back end side using Kotlin (or Java).


  1. I cannot find the information about the algorithm that is used for signing messages in the documentation.
  2. It seems like there are no Java/Kotlin libraries that work with Phantom and Solana (found a few which are not updated for a year).

Question: How can I verify a signature from the Phantom wallet using Java? Or generally how can I do that in any language? (I will port it to Java then).

1 Answer 1


In JavaScript, you can use the tweetnacl library to verify signatures.

const hasSucceededVerification = nacl.sign.detached.verify(
    encodedMessage, // the message
    signedMessage, // the signature
    publicKey.toBytes() // public key
); // returns boolean

console.log(`signature verified?: ${hasSucceededVerification}`);

Ed25519 is the signature system used on Solana.

You can find a complete example here: https://solanacookbook.com/references/offline-transactions.html#sign-transaction

  • 1
    Nothing to add to this answer, but in case it's helpful I have a codesandbox that does sign with Phantom + verify here: codesandbox.io/s/solana-sign-9exq14
    – Callum M
    Commented Aug 1, 2022 at 13:31
  • @CallumM mind if i add that to the answer?
    – C.OG
    Commented Aug 1, 2022 at 14:27
  • @ C_Ogoo of course not, go for it! :)
    – Callum M
    Commented Aug 1, 2022 at 14:45
  • Just to add, since Solana uses ED25519, you may wanna try this for Java github.com/str4d/ed25519-java but I haven't done Java coding for so long.
    – ratib90486
    Commented Aug 7, 2022 at 5:52

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.