Core Concept
Wallet Derivation
Buff creates a deterministic wallet from the user's signature. Same wallet every time, no storage needed, fully exportable.
How It Works
- –User signs a fixed message: "Buff Portfolio Wallet v1"
- –The signature (unique per wallet) is SHA-256 hashed to get a 32-byte seed
- –The seed generates a Solana Keypair — this is the Buff wallet
- –Same main wallet → same signature → same Buff wallet, every time
- –No private keys are stored anywhere — the wallet is derived on-the-fly
derivation.ts
typescript
1import { sha256 } from "@noble/hashes/sha2.js"2import { Keypair } from "@solana/web3.js"34// 1. User signs a message5const message = "Buff Portfolio Wallet v1"6const signature = await wallet.signMessage(encode(message))78// 2. Hash the signature to get 32 bytes9const seed = sha256(signature)1011// 3. Create keypair from seed12const buffWallet = Keypair.fromSeed(seed)13// Same signature = same wallet, alwaysExporting the Wallet
Users can export their Buff wallet's private key at any time and import it into Phantom, Solflare, or any Solana wallet. They have full control.
export.ts
typescript
1// Export the secret key2const secretKey = buff.exportKey()3// Uint8Array(64) — import this into Phantom45// The wallet address6const address = buff.getWalletAddress()7// e.g. "E71R6Ph2sS4eYJVSNLacorUtSDNK1rUixVswgFD5hCY3"Note
Buff never stores the private key. It's derived fresh each time from the user's signature. If the user signs with the same main wallet on a different device, they get the same Buff wallet.
Security
- –Private key only exists in memory during the session
- –Uses @noble/hashes — audited, pure JS, no native dependencies
- –The derivation message is versioned to prevent collisions
- –Buff platform never has access to user funds