Module 3 of 5 · Beginner
Nostr
How clients find where you write and read, then how a stale list or a dark outbox misleads them.
Nostr key handling
Your nsec Is Not a Password: Nostr Key Handling and Signers
Optional practical
Build a dummy Nostr event — without signing or sending it
Estimated 10–15 minutes (untested estimate). Not a saved checkpoint, not a quiz score, not a certificate.
This optional practical does not change saved checkpoints or quizzes in this browser. Existing ticks and answers stay as they are. You do not need it to finish the module.
You will build a local event-shaped template, inspect its fields, and calculate its event ID. You will not create an account, generate or use a key, sign anything, connect to a relay, or publish a post. The supplied scripts make no network calls. Local execution is not automatically risk-free: read the code first, use an ordinary terminal without administrator privileges, and stop if it differs from the example. Do not paste it into a browser console or a wallet/signing prompt.
Important: this is a DUMMY UNSIGNED template, not a valid publishable Nostr event. The all-zero pubkey is deliberately fake filler, not an identity you control. A 64-character hex string is not proof of a real public key or anyone's identity.
1. Prepare (2 minutes)
Use a text editor and a terminal with Node.js already installed (tested with Node 24), or choose the Python 3 alternative below. No packages are needed. If neither runtime is available, stop and read the captured output instead; installing software is outside this exercise. Never paste a real private key or nsec into either file.
Make an empty folder outside any site repository, save files as UTF-8, and keep punctuation exactly as shown:
mkdir nostr-dummy-pilot
cd nostr-dummy-pilot2. Copy and run (3 minutes)
Save this as dummy-event.mjs:
// DUMMY UNSIGNED template only. No keys, signing, network, or dependencies.
import { createHash } from 'node:crypto';
const template = {
pubkey: '0'.repeat(64), // DUMMY filler; not a usable identity or a real key.
created_at: 1700000000, // Fixed example timestamp in Unix seconds.
kind: 1,
tags: [],
content: 'DUMMY UNSIGNED — café\n"Hello" from a local file; path: C:\\demo'
};
const serialized = JSON.stringify([
0, template.pubkey, template.created_at,
template.kind, template.tags, template.content
]);
const id = createHash('sha256').update(serialized, 'utf8').digest('hex');
const event = { id, ...template }; // Intentionally NO sig field.
console.log('DUMMY UNSIGNED — LOCAL INSPECTION ONLY; NOT PUBLISHABLE');
console.log('Serialized: ' + serialized);
console.log('Event id: ' + id);
console.log(JSON.stringify(event, null, 2));
console.log('sig present: ' + Object.hasOwn(event, 'sig'));Tested on Node v24.22.1 / v22.23.4; node:crypto only, no packages · 7 Nov 2026
Never paste a real private key or seed into anything. Examples use placeholder keys.
From that folder, run:
node dummy-event.mjsPrefer Python? Use the optional Python alternative at the end instead; do not run both.
3. Inspect the result (3 minutes)
Expected output below is the actual captured stdout from the tested Node version; the Python version matched it exactly:
DUMMY UNSIGNED — LOCAL INSPECTION ONLY; NOT PUBLISHABLE
Serialized: [0,"0000000000000000000000000000000000000000000000000000000000000000",1700000000,1,[],"DUMMY UNSIGNED — café\n\"Hello\" from a local file; path: C:\\demo"]
Event id: 920110e51f0d0c6af72ca8be01ae7f1778a4f913f24255898e084be18ec4a14c
{
"id": "920110e51f0d0c6af72ca8be01ae7f1778a4f913f24255898e084be18ec4a14c",
"pubkey": "0000000000000000000000000000000000000000000000000000000000000000",
"created_at": 1700000000,
"kind": 1,
"tags": [],
"content": "DUMMY UNSIGNED — café\n\"Hello\" from a local file; path: C:\\demo"
}
sig present: falseTested on Node and Python stdout agreed byte-for-byte; no packages · 7 Nov 2026
Never paste a real private key or seed into anything. Examples use placeholder keys.
| Field | What it means; what our dummy uses |
|---|---|
pubkey | NIP-01 specifies the creator's 32-byte lowercase hex public key. Here it is 64 zeros, solely a visible dummy placeholder. We have generated no keypair. |
created_at | Unix timestamp in seconds, not milliseconds. 1700000000 is fixed historical sample data, not the time you run the code. That makes reruns reproducible. |
kind | Integer from 0 to 65535 telling clients how to interpret the event. 1 denotes a text note, as NIP-01 explains with a reference to NIP-10. It is not a permission or validity flag. |
tags | An array of tag arrays; each tag contains strings. This example uses []: no tags. Tags can reference other events or users, but none are needed here. |
content | The event's text string. Our dummy label, accented text, newline, quotes and backslash let you see JSON encoding. The path text is just text; no file at that path is opened. |
id | Lowercase hex SHA-256 digest (32 bytes, displayed as 64 characters) of the exact serialized array, computed below. It is a content-derived identifier, not a signature. |
sig | A real event requires a 64-byte lowercase-hex Schnorr signature over the event ID (BIP-340 on secp256k1). Absent on purpose here; sig present: false confirms that. |
The line beginning Serialized: is what we hash, not the pretty-printed object. It has this fixed order:
[0,pubkey,created_at,kind,tags,content]The initial 0 is a required literal in NIP-01's serialization, not the kind value. Neither id nor sig belongs inside that array. Hash its UTF-8 bytes with SHA-256, then display the digest as lowercase hex. Do not hash the Serialized: label or add a trailing newline.
4. Why exact JSON matters (2 minutes)
The current NIP-01, Events and signatures states:
“To obtain the event.id, we sha256 the serialized event.”
“Whitespace, line breaks or other unnecessary formatting should not be included in the output JSON.”
This means no extra JSON formatting; it does not mean deleting spaces or line breaks from the message itself. NIP-01 also says UTF-8 must be used and that the listed characters in content must be escaped, with all other characters included verbatim:
| Character in the content | Representation in serialized JSON |
|---|---|
| Line break (0x0A) | \n |
| Double quote (0x22) | \" |
| Backslash (0x5C) | \\ |
| Carriage return (0x0D) | \r |
| Tab (0x09) | \t |
| Backspace (0x08) | \b |
| Form feed (0x0C) | \f |
The table shows literal escape sequences, not extra content. JSON.stringify handles our sample in Node. Python uses ensure_ascii=False so é and — stay verbatim, and separators=(",", ":") to remove formatting spaces. The message's newline is encoded as \n, rather than splitting the serialized JSON into lines. Both versions explicitly hash UTF-8 bytes.
These are intentionally narrow learning examples, not general-purpose Nostr serializers or validators. The test file also checks all seven escape cases and a non-ASCII character independently across both runtimes.
Optional experiment: add ! to the end of content, save, and run again. The ID changes. Restore the original to recover the captured ID. This demonstrates a different digest for this particular edit, not authorship. It is not a claim that SHA-256 can never have collisions.
5. Stop at the boundary (1 minute)
Do not try to publish this output. It has no BIP-340 Schnorr signature and no genuine creator key. A conforming validating relay would reject it as invalid. We have not tested a relay and make no network connection. Merely adding an empty or invented sig would not fix it.
NIP-01 says signatures and public keys follow the Schnorr signatures standard for secp256k1 (BIP-340). Calculating an ID is separate from making and verifying such a signature. Even a valid signature establishes a key-based cryptographic claim, not a legal name or real-world identity. Our dummy public-key string proves nothing about identity or key ownership.
A few words for this exercise
These are short pointers into existing notes, not a new glossary:
- Event: Nostr's structured object carrying fields and, when valid, a signature; our unsigned template stops short of that. Key-handling context.
- Public key: the public part of a keypair used to check signatures; not a private key or an identity document. Keys and signers.
- Signature: cryptographic evidence checked against a public key and event ID, not just a hash or a name. None is made here. Authentication is not identity.
- Client: an app that reads or prepares Nostr events and talks to relays. This script only illustrates local preparation; it is not a connected client. Client/relay context.
- Relay: a server that can store and forward events under its own limits and policy; not a master identity registry. Relay information documents.
- Relay list: an author's advertised read/write destinations, separate from an individual text note's contents. NIP-65 routing.
- Stale list / dark outbox: an old routing advertisement or a writing destination that is unavailable; neither is evidence that the author has nothing to say. Stale lists and dark outboxes.
Three self-checks (2 minutes)
Questions and explanations, readable without JavaScript. Revealing an explanation does not save progress and does not count toward the module checkpoint or quizzes.
Why does adding ! to content change the ID?
Reveal explanation 1
contentis in the serialized array. Its changed UTF-8 bytes change the SHA-256 digest in this example. Restoring the exact original bytes restores the original ID.Is this publishable because it has an id and a 64-character pubkey?
Reveal explanation 2
No. The public key is dummy filler and the required verifiable BIP-340 signature is absent. A hash is not proof of key ownership or identity.
Which bytes are hashed: the pretty-printed object, or the compact array?
Reveal explanation 3
UTF-8 bytes of the compact
[0,pubkey,created_at,kind,tags,content]array, with NIP-01 escaping; noid, nosig, no extra JSON whitespace or trailing newline.
You are done when you can locate all six array entries, explain the ID, and explain why this template cannot be published. Continue with the relay-list steps below, then the existing module checkpoints and quizzes when ready. This practical does not add a saved checkpoint or quiz score, and finishing it is not certification.
Optional Python alternative (instead of Node)
Python alternative: use this instead of Node if you already have Python 3. Save it as dummy_event.py, then run python3 dummy_event.py (on systems where the Python 3 executable is python, use python dummy_event.py). Both versions produce the same output; you only need one.
# DUMMY UNSIGNED template only. No keys, signing, network, or dependencies.
import hashlib
import json
template = {
"pubkey": "0" * 64, # DUMMY filler, not a usable identity or a real key.
"created_at": 1700000000, # Fixed example Unix seconds.
"kind": 1,
"tags": [],
"content": 'DUMMY UNSIGNED — café\n"Hello" from a local file; path: C:\\demo',
}
serialized = json.dumps(
[0, template["pubkey"], template["created_at"], template["kind"],
template["tags"], template["content"]],
ensure_ascii=False, separators=(",", ":"),
)
event_id = hashlib.sha256(serialized.encode("utf-8")).hexdigest()
event = {"id": event_id, **template} # Intentionally NO sig field.
print("DUMMY UNSIGNED — LOCAL INSPECTION ONLY; NOT PUBLISHABLE")
print("Serialized: " + serialized)
print("Event id: " + event_id)
print(json.dumps(event, ensure_ascii=False, indent=2))
print("sig present: " + str("sig" in event).lower())Tested on Python 3.13.5 / 3.12.3; hashlib+json only, no packages · 7 Nov 2026
Never paste a real private key or seed into anything. Examples use placeholder keys.
Step 5 of 10 · Module 3 of 5 · Beginner
Identity without platforms
NIP-65: Relay Lists, Outbox, and Inbox — Routing Beyond One Home Relay
Step 6 of 10 · Module 3 of 5 · Beginner
Stale lists and dark outboxes
Stale Lists and Dark Outboxes: When NIP-65 Metadata Lies by Age or Uptime
Go deeper
Your summary
Your progress is read from this browser once the page loads.
Educational only. Not financial advice.