Counting Nostr proof of work at a relay admission threshold
A relay rejects some notes that another implementation accepts at difficulty ten. The discrepancy can be as small as counting whole zero hex digits and losing the leading zero bits in the next digit.
Count bits in the verified event ID
The synthetic ID starts with 003. Two zero digits supply eight bits and the following 3 begins with two more. The example prints ten. A production validator must first derive the ID from the signed event and handle the all-zero boundary explicitly when implementing this count.
const id = "003" + "f".repeat(61);
const bits = [...id].map(c => parseInt(c, 16).toString(2).padStart(4, "0")).join("");
console.log(bits.indexOf("1"));
Apply the advertised target separately
The nonce tag can declare the difficulty the publisher aimed for. If your policy requires both a ten-bit result and a ten-bit commitment, a lucky event declaring a target of eight passes only the first check. Return a rejection reason that distinguishes the two. This is an anti-spam cost attached to a Nostr event, without block production or a mining reward.