Skip to main content

Basic Message Signing

Authentication Flow

Backend Verification (Conceptual)

On your backend, verify message signatures by following these steps:
  1. Receive data from client: message, signature, and public key
  2. Verify Ed25519 signature: Use a cryptographic library (e.g., tweetnacl, @noble/ed25519)
  3. Validate message contents: Check nonce, timestamp, and domain match expectations
  4. Prevent replay attacks: Store used nonces temporarily and reject duplicates
  5. Check expiration: Verify message timestamp is recent (e.g., within 5 minutes)
  6. Generate auth token: Create JWT or session token if signature is valid
Security Notes:
  • Never trust client-side verification - always verify server-side
  • Use HTTPS to protect signatures in transit
  • Rate limit verification endpoints to prevent brute force attacks
  • Store nonces with TTL to prevent replay attacks
Pseudo-code for verification:

Sign-In With Solana (SIWS)

Message Signing (@solana/kit)

When to use Kit for message signing:
  • Building with @solana/kit architecture
  • Need type-safe signer interfaces
  • Working with Kit-native libraries
  • Want better tree-shaking and smaller bundles
Note: The Kit messageSigner integrates seamlessly with wallet adapters through createKitSignersFromAdapter, providing a bridge between traditional wallet adapters and modern Kit signers.