What is the algorithm Phantom Wallet (Solana) uses to sign messages?

1.4k views Asked by At

I am trying to understand what happens under the hood when we call window.solana.signMessage.

1

There are 1 answers

0
Jon C On

Solana uses the ed25519 curve for its cyrptography, so a transaction signature is:

A 64-byte ed25519 signature of R (32-bytes) and S (32-bytes). With the requirement that R is a packed Edwards point not of small order and S is a scalar in the range of 0 <= S < L. This requirement ensures no signature malleability.

The actual code called is tweetnacl's sign.detached function.

More information at the official docs: https://docs.solana.com/terminology#signature

The Solana transaction sign code: https://github.com/solana-labs/solana/blob/2a5764ef79cff391da080cc19617f171109c4158/web3.js/src/transaction.ts#L522

The underlying tweetnacl code: https://github.com/dchest/tweetnacl-js/blob/971d653d301cff2dd694e95a099cb42d9201e922/nacl.js#L1076