Overview
Hash-Signed Coin is a Token-2022 mint with a transfer hook. The hook program does four things. It lets a wallet seal its balance behind a hash-based key. It refuses to move a sealed balance unless a valid one-time signature over the exact transaction was verified earlier in that same transaction. It keeps exact totals of sealed, program-held and exposed supply. And it holds three bounty vaults that can only be opened by breaking an elliptic curve, changing the coin's transfer rules when one opens.
Everything on this site that is a number is read from Solana or from a price feed at the time you see it. A row with no value means the account behind it does not exist or has not been read yet.
Threat model
A Solana address is an ed25519 public key. Ownership of a token account is proven by a signature under that key. Shor's algorithm solves the discrete logarithm problem in polynomial time on a fault tolerant quantum computer, which means the private key can be computed from the address. No such machine is known to exist today. The design assumes one will, and asks what a coin can do about it from inside a program.
| what the attacker has | unsealed wallet | sealed wallet |
|---|---|---|
| nothing | safe | safe |
| the ed25519 private key | balance can be moved | balance cannot be moved |
| the ed25519 key and one pending signed transaction | balance can be moved | can only land that same transaction |
| the hash seed only | nothing | nothing |
| the ed25519 key and the hash seed | balance can be moved | balance can be moved |
The last row is the ordinary case of a fully compromised holder and no scheme changes it. The point of the table is the second and third rows.
Parameters
| name | value | meaning |
|---|---|---|
N | 32 | bytes per chain value and per hash output |
W | 16 | digit base, four bits per digit |
LEN1 | 64 | digest digits |
LEN2 | 3 | checksum digits |
LEN | 67 | chains per key |
SIG_BYTES | 2,144 | LEN times N |
MAX_HASHES | 1,005 | LEN times 15 |
TAG | hash-signed-coin/v1 | domain tag, ASCII |
NODE_BYTES | 128 | node account size |
COIN_BYTES | 96 | coin account size |
CANARY_BYTES | 97 | canary account size |
TX_BYTES | 4,096 | v1 transaction limit the layout is sized for |
Keys and chains
A holder keeps one 32 byte seed. Every one-time key is derived from the seed and the key index, so the seed is the only thing to back up. The chain step binds the tag, the chain number and the step number into every hash, which keeps one chain's values from being reused in another chain or at another height.
fn secret(seed, index, j) = sha256(TAG || "sk" || seed || u64le(index) || u8(j))
fn step(j, i, x) = sha256(TAG || u8(j) || u8(i) || x)
fn chain(j, x, from, to):
for i in from + 1 ..= to:
x = step(j, i, x)
return x
fn public_end(seed, index, j) = chain(j, secret(seed, index, j), 0, 15)
fn commitment(seed, index) =
sha256(public_end(seed, index, 0) || ... || public_end(seed, index, 66))Generating one key costs 1,005 hashes. A phone does this in a few milliseconds.
Signing
To sign a digest, cut it into 64 hex digits, compute the checksum, write the checksum as three more digits, and for each of the 67 digits reveal the chain value that many steps in.
fn digits(m): // m is 32 bytes
d = []
for byte in m:
d.push(byte >> 4)
d.push(byte & 15)
c = 0
for x in d: c = c + (15 - x) // 0 ..= 960
d.push((c >> 8) & 15)
d.push((c >> 4) & 15)
d.push(c & 15)
return d // 67 digits
fn sign(seed, index, m):
d = digits(m)
return [ chain(j, secret(seed, index, j), 0, d[j]) for j in 0..67 ]A worked split. The SHA-256 digest of the ASCII string hash-signed-coin is:
3b84c459ca52b3cecce0f836e13e69153d3b1e6bd088cf5ea7b1f11515fd78f0
| quantity | value |
|---|---|
| sum of the 64 digest digits | 500 |
| checksum C = 960 - 500 | 460 |
| C in base 16 | 1 12 12 |
| hashes the signer runs | 525 |
| hashes the verifier runs | 480 |
| total, always | 1,005 |
The signer and the verifier always share 1,005 hashes between them. A digest with small digits is cheap to sign and dear to verify, and the checksum digits push the other way, which keeps the verifier's work from ever reaching the maximum on real input.
Verification
The sign instruction carries the next commitment and the 67 chain values. The program rebuilds the digest itself from the node, the next commitment and the transaction, so the caller never supplies the message.
fn sign(ctx, next_commitment: [u8; 32], sig: [[u8; 32]; 67]):
node = ctx.node // seeds: "node", mint, owner
require(node.state == SEALED)
require(coin.break_state != NATIVE_BREAK || node.state == SEALED)
ix_hash = hash_instructions(ctx.instructions_sysvar) // signature bytes zeroed
m = sha256(TAG || mint || owner || u64le(node.key_index)
|| next_commitment || ix_hash)
d = digits(m)
ends = []
for j in 0..67:
ends.push(chain(j, sig[j], d[j], 15))
require(sha256(concat(ends)) == node.commitment) // else BadSignature
node.commitment = next_commitment
node.key_index = node.key_index + 1
node.permit_hash = ix_hash
node.permit_amount = amount_of_next_transfer(ctx.instructions_sysvar)
coin.signatures_verified = coin.signatures_verified + 1
coin.last_signature_slot = clock.slotIf the transaction fails for any reason after this point, every write above is rolled back with it, including the key index. A failed transaction does not burn a key.
Transaction binding
hash_instructions walks the instructions sysvar from the first instruction to the last. For each one it hashes the program id, the number of accounts, every account key with its signer and writable flags, the length of the data, and the data. For the sign instruction itself the 2,144 signature bytes are replaced with zeros, since a signature cannot cover itself. The result is one 32 byte value that names the whole transaction.
The recent blockhash is not part of the instructions and is not covered. That is deliberate: a holder can sign, miss the blockhash window, and send the same instructions again with a fresh blockhash and the same signature, since the key index has not advanced.
What this prevents. Without binding, a party that sees a signed transaction before it lands, and that can also forge the ed25519 signature, could keep the hash signature and swap the destination. With binding, the only transaction that signature will ever authorise is the one the holder built.
Accounts
Three account types, all owned by the hook program, all program-derived. Discriminators are the first eight bytes of SHA-256 over the string account: plus the type name.
Coin account. Seeds ["coin", mint]. Discriminator bd 90 5c 57 27 50 3c 40.
| off | field | type | meaning |
|---|---|---|---|
| 0 | discriminator | [u8; 8] | type tag |
| 8 | mint | Pubkey | the coin |
| 40 | sealed_supply | u64 | raw units held by sealed wallets |
| 48 | program_supply | u64 | raw units held by off-curve owners |
| 56 | signatures_verified | u64 | count of accepted signatures |
| 64 | transfers_seen | u64 | count of hook executions |
| 72 | last_signature_slot | u64 | slot of the latest accepted signature |
| 80 | break_slot | u64 | slot of the latest state change, zero while intact |
| 88 | sealed_wallets | u32 | count of nodes |
| 92 | break_state | u8 | 0 intact, 1 adjacent break, 2 native break |
| 93 | canary_flags | u8 | bit 0 ed25519, bit 1 secp256k1, bit 2 secp256r1 |
| 94 | bump | u8 | PDA bump |
| 95 | reserved | u8 | zero |
Node account. Seeds ["node", mint, owner]. Discriminator d0 35 01 03 31 7a b4 31.
| off | field | type | meaning |
|---|---|---|---|
| 0 | discriminator | [u8; 8] | type tag |
| 8 | owner | Pubkey | the sealed wallet |
| 40 | commitment | [u8; 32] | hash of the 67 public ends of the live key |
| 72 | key_index | u64 | number of keys already spent |
| 80 | permit_hash | [u8; 32] | instruction hash of the transaction in flight |
| 112 | permit_amount | u64 | raw units the permit allows |
| 120 | state | u8 | 1 sealed |
| 121 | bump | u8 | PDA bump |
| 122 | reserved | [u8; 6] | zero |
Canary account. Seeds ["canary", mint, [curve]]. Discriminator c0 d1 d6 c5 57 1c 52 73.
| off | field | type | meaning |
|---|---|---|---|
| 0 | discriminator | [u8; 8] | type tag |
| 8 | curve | u8 | 0 ed25519, 1 secp256k1, 2 secp256r1 |
| 9 | claimed | u8 | 0 or 1 |
| 10 | bump | u8 | PDA bump |
| 11 | reserved | [u8; 5] | zero |
| 16 | pubkey | [u8; 33] | the canary public key, compressed, ed25519 padded with one zero byte |
| 49 | bounty | u64 | raw units held by the vault |
| 57 | claimer | Pubkey | zero until claimed |
| 89 | claim_slot | u64 | zero until claimed |
The extra account list that Token-2022 reads before calling the hook lives at seeds ["extra-account-metas", mint]. It names the coin account, the instructions sysvar, and two node addresses seeded from the owner fields inside the source and destination token accounts, so wallets and pools resolve them with no special handling.
Instructions
| instruction | discriminator | signer | effect |
|---|---|---|---|
initialize | af af 6d 1f 0d 98 9b ed | deployer once | creates the coin account, the extra account list and the three canary accounts |
seal | 66 ca ab a3 1b 98 69 f2 | the wallet | creates the node with the first commitment and moves the wallet's balance into the sealed total |
sign | 05 dd 9b 2e ed 5b 1c ec | the wallet | verifies a signature, ratchets the key, writes the permit |
claim_canary | 24 7b 74 92 6c 05 94 e7 | anyone | pays a vault to the caller and advances the break state |
execute | 69 25 65 c5 4b fb 66 1a | Token-2022 only | applies the transfer rules below |
execute is the transfer hook interface instruction. It checks that it is being called from inside a real transfer of this mint and rejects a direct call.
Execute rules
The hook classes each side of a transfer by its owner key. An owner that is not a point on the ed25519 curve is a program. An owner with a node account is sealed. Anything else is exposed.
| source | intact | adjacent break | native break |
|---|---|---|---|
| program | passes | passes | passes |
| sealed | needs a permit | needs a permit | needs a permit |
| exposed | passes | passes | rejected |
| destination | intact | adjacent break | native break |
|---|---|---|---|
| program | passes | passes | passes |
| sealed | passes | passes | passes |
| exposed | passes | rejected | rejected |
A permit matches when the node's permit hash equals the instruction hash of the current transaction and the permit amount equals the transfer amount. The hook zeroes both fields as it accepts. After the checks, the hook subtracts the amount from the source's class total and adds it to the destination's class total, then increments transfers_seen.
Key ratchet and recovery
The key index only moves forward and only inside a transaction that succeeds. A holder's software derives key i from the seed, signs, and learns from the node account that the index is now i + 1. There is no state to keep besides the seed.
Two things are final. A seed that is lost cannot be replaced, since replacing the commitment needs a signature under the current key. And a wallet cannot be unsealed. Both follow from the same rule: nothing but the hash key may speak for a sealed balance.
Exposure accounting
The mint's whole supply starts in program-held accounts, so the totals are exact from the first transfer. Sealed supply and program-held supply are stored. Exposed supply is the remainder, and the sealed share divides sealed supply by everything not held by programs.
After a native break, E is the amount that has left the supply for good.
Canaries
A canary key is found by hashing until the output is a valid point. For ed25519 the candidate is sha256("hash-signed-coin canary ed25519" || mint || u32le(n)) read as a compressed point, for the smallest n that decompresses, multiplied by the cofactor 8. For the two Weierstrass curves the candidate is the same construction with the curve's name, reduced into the field and used as an x coordinate, for the smallest n that lies on the curve, taking the even y. Nobody chooses these points and nobody learns a private key by computing them.
| curve | claim message | how the program checks it |
|---|---|---|
| ed25519 | sha256("claim" || mint || 0 || claimer) | a verified Ed25519 program instruction in the same transaction |
| secp256k1 | sha256("claim" || mint || 1 || claimer) | the secp256k1 recover syscall |
| secp256r1 | sha256("claim" || mint || 2 || claimer) | a verified Secp256r1 program instruction in the same transaction |
The message names the claimer, so copying a claim from a pending transaction pays the original caller. A claimer who wants to move the bounty afterwards should seal the receiving wallet before claiming the ed25519 vault, because that claim freezes every exposed balance, the claimer's included.
Break states
State only moves forward: intact, then adjacent break, then native break, or straight from intact to native break. The move happens inside claim_canary and takes effect for the next instruction in the same transaction. No timer, epoch or admin is involved.
| state | what changed | why |
|---|---|---|
| adjacent break | exposed wallets can no longer receive | a neighbouring curve of the same family has fallen, so new balances must start out sealed |
| native break | exposed balances frozen and sealing closed | a seal request signed with ed25519 can no longer be told from a forgery |
Compatibility
| who | what they need to do |
|---|---|
| an unsealed holder | nothing, the coin behaves like any transfer hook token |
| a sealed holder buying | nothing, receiving needs no signature |
| a sealed holder selling or sending | build a v1 transaction with sign first, using the open signer and their seed |
| a pool | support Token-2022 transfer hook mints |
| an explorer | nothing, all accounts are plain program-derived accounts |
A normal wallet app signs with ed25519 only and cannot send from a sealed wallet. That is the property working as intended.
Errors
| code | name | raised when |
|---|---|---|
| 6000 | NotSealed | sign is called for a wallet with no node |
| 6001 | BadSignature | the rebuilt commitment does not match |
| 6002 | PermitMissing | a sealed source has no permit for this transaction |
| 6003 | PermitAmount | the transfer amount differs from the permit |
| 6004 | ExposedReceive | an exposed destination after an adjacent break |
| 6005 | ExposedFrozen | an exposed source after a native break |
| 6006 | SealingClosed | seal after a native break |
| 6007 | AlreadySealed | seal for a wallet that has a node |
| 6008 | CanaryClaimed | the vault was already paid |
| 6009 | BadCanaryProof | the claim signature does not verify |
| 6010 | NotTransferring | execute called outside a transfer |
What it does not cover
Solana's validators sign blocks and votes with elliptic curve keys. If those fall, the chain needs its own migration, and a token program cannot stand in for it. Transaction fees are paid by an ordinary key. The SOL or stablecoin received in a sale lands in an ordinary account. A wallet that never sealed has no protection at all, and after a native break its balance is frozen for good. A sealed wallet whose seed is lost is frozen for good as well. And the scheme assumes SHA-256 stays one-way: the quantum cost of inverting it is on the order of 2128 operations, which is the security level the whole design rests on.
Reading this site
| what you see | where it comes from | how often |
|---|---|---|
| value and price | Birdeye price multiplied by on chain supply | every second |
| supply | Solana getTokenSupply | every 30 seconds |
| chart | Birdeye candles plus the live price | on load and every 15 minutes |
| token program, extension, hook program | the mint account | on load and every 30 seconds |
| coin account rows | the coin account decoded byte by byte | on load and every 30 seconds |
| canary rows | the three canary accounts | on load and every 30 seconds |
| the lit lattice | SHA-256 of the live value computed in your browser | whenever the value changes |