Entropy Edge Resolver

Nostr npubs are self-describing: any client can compute which prefix or suffix edge to display prominently using the difficulty metric L × (5 − H).

1. Interactive Resolver

Paste an npub or generate a random one. The resolver finds the edge with the highest difficulty (bits of pattern) and highlights it.

Difficulty by edge length

Each row shows the difficulty for a prefix edge (right) and suffix edge (left) of that length. The winning edge is highlighted.

3. How it works

Why 5.0: the bech32 alphabet

Every npub is encoded in bech32, which uses exactly 32 symbols:

qpzry9x8gf2tvdw0s3jn54khce6mua7l

Bech32 deliberately excludes 1, b, i, and o to prevent visual confusion (1 vs l, 0 vs o). That leaves 36 − 4 = 32 symbols.

Shannon entropy of a uniform distribution over N symbols is log2(N). For bech32:

log2(32) = log2(25) = 5.0 bits per character

This is the maximum possible entropy — a perfectly random bech32 string has entropy exactly 5.0 bits/char. Any pattern (repeated characters, skewed distribution) drives it below 5.0. The value 5.0 is not a tuning parameter; it is mathematically determined by the bech32 specification. Anyone who knows the charset can derive it.

H = 0.0
monochrome
(all same char)
H = 3.0
quality floor
(~8 distinct chars)
H = 5.0
fully random
(log232)

The difficulty metric: L × (5 − H)

L is the edge length (characters from the start or end of the npub data). H is the Shannon entropy of those characters. The product measures bits of pattern — how far below maximum randomness the edge is, scaled by its length.

The quality floor: H ≤ 3.0

Edges with entropy above 3.0 = log2(8) are "barely below random" and receive zero difficulty. Only edges using effectively ≤ 8 of the 32 bech32 symbols qualify. This prevents a long mediocre edge (e.g. 29 chars at H=4.0) from outscoring a short genuinely-patterned edge (e.g. 10 chars at H=1.0).

EdgeLHAbove floor?DifficultyVisual
aa20.0no10.0Trivial
aaaaaaabcab100.7no43.0Good
aaaaabcaaaabcd141.2no53.2Very recognizable
qpzry9x8gf2tvdw0164.0yes → zeroed0.0Rejected — too random
abcdefghijklmnopqrs204.1yes → zeroed0.0Rejected — too random

The Zucos triangle problem

Classic vanity npubs (e.g. npub1rana...) are forgeable: an attacker can mine a look-alike prefix at the same cost the original holder paid. The vanity property is symmetric.

Low-entropy edges flip this into an asymmetric defense. An attacker can mine another npub with similarly low entropy, but the residual randomness forces the result to look recognisably different. Pattern-imitation is not identity-imitation.

Self-describing npubs

The bestEdge(npub) function is deterministic and requires no parameters beyond the constants 5.0 (derived from the bech32 charset) and 3.0 (the quality floor). Any Nostr client can implement it to determine which portion of an npub to display prominently. The miner (rana) and the client agree on the same edge without any out-of-band communication.

Mine your own

cargo install rana
rana --entropy-difficulty=40

github.com/grunch/rana