Chameleon
Start
OverviewHow it worksQuickstart
Concepts
ConceptsPrivacy model
Reference
The transactionsJavaScript engineAddresses and programs
Practice
Real examplesSelling and exitingSecurity and limitsFAQChangelog
Solana mainnet

JavaScript engine

Two plain ES modules with no framework and no wallet library: core/stealth.js (the maths) and core/solana.js (transactions). The only dependency is a 32 KB bundle of @noble/curves and @noble/hashes.

stealth.js

import { deriveKeys, generateStealth, scan, stealthPrivateKey, sign } from './stealth.js';

const keys = deriveKeys(seedBytes);          // { spendPriv, viewPriv, spendPub, viewPub, metaAddress }
const s = generateStealth(keys.metaAddress); // { stealthAddress, ephemeralPubKey, viewTag }
FunctionWhat it does
deriveKeys(seed) / randomKeys()Spending and viewing scalars from 32 or more bytes.
keysFromPrivates(spend, view)Rebuild everything from two stored scalars.
parseMeta(meta)Validate st:sol:...: two valid ed25519 points of prime order.
generateStealth(meta, ephemeral?)The one-time address for a buy.
checkAnnouncement(a, viewPriv, spendPub)View tag first, then full derivation. Returns the address or null.
stealthPrivateKey(R, spendPriv, viewPriv)The scalar that controls a found address.
scan(announcements, keys)Filter a list down to yours, with their scalars.
sign(message, scalar)RFC 8032 signing from a raw scalar.
buildMemo / parseMemoThe announcement text.
explain(keys)Every intermediate value of one derivation (it feeds the page's step-through).

The maths

r, R = r x G                       (sender, per buy)
Q    = r x V = v x R               (both sides)
hash = SHA-512("chameleon/sol/shared/v1" || Q)
h    = hash mod L,  tag = hash[0]
P    = S + h x G                   (the stealth address)
p    = s + h  mod L                (its private scalar)

Signing uses nonce = SHA-512("chameleon/sol/nonce/v1" || p)[0..32], then r' = H(nonce || M), k = H(R' || P || M), sig = R' || (r' + k p). Validators verify it as any ed25519 signature.

solana.js

FunctionWhat it does
compileMessage / signWireLegacy message serialisation and signing.
buildBuy / buildSell / buildSweep / buildReturnSolThe four transactions of the transactions page.
loadMarket(rpc, mint)Reads curve, token program and fee accounts, and refuses what Chameleon cannot trade.
fetchAnnouncements(rpc, opts)One page of announcements, newest first.
sendAndConfirm(rpc, wire)Preflight send, then wait for confirmation.
findPda, ataAddress, bondingCurveAddress derivation.

Tests

node tests-js/engine.test.mjs runs 42 checks. The signatures are verified by node:crypto, an independent ed25519 implementation. Addresses, program-derived addresses and the serialised message are compared to @solana/web3.js, which is a development tool only and is not shipped. The check that a transaction signed with a stealth scalar passes Transaction.verifySignatures() is in there too.