Skip to content
arkin0xPublic

About

The Cyberspace client for the one true metaverse: nostr

Topics

Resources

Stars

61 stars

Watchers

2 watching

Forks

Repository files navigation

ONOSENDAI V2

A spatial explorer for the Cyberspace Protocol v2.

Move through the 85-bit axis space one step at a time and watch what each step actually costs. The protocol's central and least intuitive property is that movement cost is set by which power-of-two boundary you cross, not by how far you travel. This makes that visible: bright gridlines are expensive crossings, and the terrain underneath shows where the temporal work is concentrated.

Status: MVP. Rendering verified manually in a real browser; the protocol maths and view geometry are covered by unit tests.

Relays and auth

The client speaks NIP-42: it answers a relay's AUTH challenge with the session key before reading or writing, so an auth-required relay works.

The canonical relay is wss://relay.onosendai.tech (since 2026-11-05), the owner's own relay, holding the full history copied from wss://cyberspace.nostr1.com. Reads are open; it asks for AUTH only for protected (NIP-70) events, and takes events up to 512 KB.

wss://cyberspace.nostr1.com, canonical until 2026-11-05, is being retired (the owner, 2026-11-22). Stage 1: READ_FALLBACK_RELAY in src/store/useRelays.ts. Nothing is published there but your own movement events, which still go there so a device of yours on an older build (which trusts it) never forks your chain. It never vouches for a head or counts as holding a chain, and its answer alone never passes a move; it is still read beside your relays, so anything only it holds is still seen. It requires auth for reads.

Running it

npm install
npm run dev     # http://localhost:5173

cyberspace-core is a file: dependency pointing at ../cyberspace-cli-js. Clone both repos as siblings, and build the core once:

cd ../cyberspace-cli-js && npm install && npm run build

Browsers

The oldest browser ONOSENDAI supports is Safari 15.4, so the minimum for iPhone and iPad is iOS / iPadOS 15.4. On iPhone and iPad every browser (Safari, Brave, Chrome, Firefox) runs on Apple's WebKit, so the iOS version is what counts, not the browser. On a computer or Android: a current Chrome, Firefox, Edge or Safari.

Why 15.4:

  • WebGL 2. three.js (r163 and later) draws only with WebGL 2, which Safari has had since 15.0. Without it nothing can be drawn at all.
  • JavaScript. The app calls Object.hasOwn, Array.prototype.at and findLast, and structuredClone, all Safari 15.4, without a fallback. Every device that ran iOS 15.0 can update to 15.8 for free, so 15.4 asks nothing of the hardware beyond what 15.0 does.
  • CSS. :has() and dvh are Safari 15.4 too. The few newer things (color-mix() 16.2, container queries 16.0, -webkit-backdrop-filter before Safari 18) have fallbacks or are cosmetic.

What holds it there:

  • vite.config.ts builds for safari15.4: esbuild writes newer syntax in older words (a class static block, a regex lookbehind as new RegExp) and adds the CSS prefixes Safari still needs.
  • index.html runs a small ES5 preflight before the app (src/lib/preflight.ts). A browser without WebGL 2 or without the Safari 15.4 JavaScript gets a page in plain words saying what is missing and what works, instead of a spinning wordmark or a half-drawn page. If the app's script fails to load or run, the same page says it could not start, with the reason and RELOAD.
  • A render that throws shows its error and RELOAD (hud/CrashNote.tsx) around the 3D view, each coach, the HUD, the modals and the whole app, never a black page.
  • src/lib/__tests__/preflight.test.ts keeps regex lookbehind (Safari 16.4) and a list of newer built-ins out of the source.

Devices that stop below 15.4 (iPad Air 1st gen, iPad mini 2 and 3, iPhone 5s and 6, all on iOS 12) cannot run it and get the preflight's page. The iPads that stop at iPadOS 15.8 (iPad Air 2, iPad mini 4) meet the minimum but have 2 GB of memory, which may be too little for the 3D view.

Controls

Key Action
W A S D move the cursor one step in a screen direction
Space commit the cursor's hop and compute its proof
X cancel an in-flight proof, or recall the cursor
Shift + W A S D rotate the view 90 degrees
Tab return to the previous view
Esc close one thing: the topmost dialog, else the menu, else the most recently opened chip
Q / E scale the step up / down, logarithmically
R / F cursor along the axis into / out of the screen
C canonical view ("facing the black sun")
P toggle dataspace and ideaspace
[ / ] chain explorer: one action back / forward (hold to repeat)
Home / End chain explorer: the spawn / the live head
H / V / Y straight into HOP / VIEW / WALK, turned off in MODES or not (off is only out of the turns)
B / N BUILD / SCAN in and out
M menu open / closed
L hyperspace line scrubber: browse the block line, set a destination

Movement is expressed in screen directions and resolved to world axes through the current view, so W is always "away from you" in any of the 24 reachable axis-aligned orientations.

Movement is two-phase. WASD noodles a free cursor; nothing is computed until Space commits the hop. While the cursor is away from the avatar the proof panel live-previews what committing would cost (the estimate is closed-form, so it never blocks), the dashed tether shows the hop being lined up, and both turn red when the hop is beyond the compute ceiling. Position only advances when a committed proof completes, so the movement chain shown in the HUD is contiguous by construction.

You spawn at your pubkey. The first visit generates a keypair and keeps it in localStorage, and per spec section 8.3 the spawn coordinate IS the pubkey: the 256-bit key decodes directly to x / y / z / plane.

The chain is real. Spawning signs a kind:3333 spawn event, and every committed hop or sidestep is signed into its own event the moment the proof lands, naming the spawn as genesis and the previous event as previous (spec section 8). The next proof's temporal work is bound to that event's id, exactly as a verifier recomputes it. The chain persists as those events, so a reload reads position, plane and history back out of them.

The chain explorer. Under the XOR readout, the CHAIN instrument walks the chain: back, forward, spawn, head, or scrub the rail. The scene re-anchors on the action shown (avatar, trail, terrain, rooms, and the readout, which then shows what that hop cost); what came after is drawn faint. Off the head the movement controls stand down and RETURN TO LIVE brings them back. The same instrument walks any other avatar's chain while spectating.

Shards. The Shards panel opens the workshop: a full-screen bench where a shard is built on an integer grid. STAMP places a whole shape where you tap (BLOCK, WEDGE, PYRAMID, COLUMN, RING, STAR, ARROW), sized in whole units and turned a quarter at a time; a ghost shows where it will land before it does. ADD places one vertex at the current level; SELECT picks a point for the nudge pad (a unit along X, Y or Z), the color input and DELETE; FACE picks corners in order and FILL joins them into a face, any number of corners, notches and all (tap the first corner again to close), and a tap on a drawn face selects it for DELETE FACE. The color picker paints live and puts each color it settles on at the front of the palette, which persists; hold a swatch to be asked whether to delete it. A shard renders SOLID (triangles, colors blended across faces), POINTS (every vertex a light) or LINES (a polyline through the vertices, colors blending along it), chosen per shard and previewed live; a new shard starts in LINES and switches itself to SOLID the first time it gets faces. Stamps keep their own vertices even where they touch, so a red block against a blue one keeps a crisp seam (the wall between them is dropped rather than paid for), and a point that several vertices share moves, colors and deletes as one. unit says what one grid unit is in gibsons (2^unit), shown beside the control as a real size. Every edit undoes. While the bench is up the world canvas behind it stops drawing (its frameloop goes to never, with the clock kept across the pause), which on a phone was most of every frame. Shards persist in localStorage; COPY and PASTE in the shard list carry one through the clipboard in its wire form. Keys on the bench: 1 2 3 4 pick tools, Q turns a stamp, WASD / RF or arrows nudge, Del deletes, Enter fills, [ ] change the level, Ctrl+Z / Ctrl+Shift+Z undo and redo, Esc closes an open panel, then deselects, then closes the workshop (a sheet or confirmation over it closes first).

Comments. A found shard or message, and each of your own deployments, carries a comment section: NIP-22 kind:1111 events whose root scope is the bag by address (A, K, P) and whose parent is the inner item (e, k, p), replies parenting the comment they answer, every one tagged ["client", "ONOSENDAI"]. The author is p-tagged, so any nostr client tells them. The words are sealed to the place like the item they answer: per FF-1 (a derived-key event) the public .content is the placeholder "This comment is hidden at an undisclosed location in cyberspace. Happy hunting: https://onosendai.tech" and the text sits in ["encrypted", "aes-256-gcm", <ciphertext>, "cyberspace:region"] under the bag's region key, with no d tag. Other clients show the invitation; this one derives the key from where the bag is, as it did to open the bag, and shows the words. A comment the key does not open shows the placeholder, dimmed.

Hidden content is a bag of signed events. A hidden thing is a full signed nostr event — a shard (kind:3330, geometry in the content) or a message (kind:1, text). All the things one author hides in one region-and-height live together in a single kind:33330 envelope (spec section 8.6), keyed by d = lookup_id: the envelope's encrypted content is a bag of those inner events. Deploying reads the region's bag, appends the new item, and rewrites it — kind:33330 is addressable, so the newer bag replaces the old, and one place accumulates content with no per-item tags. Discovery decrypts a bag, verifies each inner signature (and that its author is the one who wrapped it), and renders every item by its kind. The location encryption is the access control: there is no NIP-70 protected tag, because the ciphertext is public anyway and anyone who can decrypt can re-sign identical content as themselves regardless.

Leave a hidden message. The Shards panel has a WRITE A MESSAGE box: type text, then aim and place at a height, exactly like a shard. Discovered messages render as billboarded notes at their coordinate with a marker of who left them.

Test discovery. The card of a thing you hid has TEST DISCOVERY in its event data, once it is LIVE: it derives the region key fresh from the coordinate, as a stranger would, asks the relay, and opens what comes back, proving the whole round-trip independent of local state. A SCANNING / N NEAR indicator on the Shards panel shows the background scan working.

Models vs instances. A model is a named design that lives on this device (the Shards panel's Models section). A deployed instance is one copy of it placed at a coordinate and published (the Deployed section). One model can have many instances. Deleting a model (behind a modal) removes it from this device and leaves its instances alone; deleting an instance sends a NIP-09 deletion to the relays it is on and leaves the model alone. Tapping a deployment flies the scene to it and opens its card, whose event data at the bottom has the wire facts: event id, kind, lookup id, coordinate, the height it is hidden at, the relays that hold it, and its LOCAL / LIVE switch.

Deploying a shard. DEPLOY on the bench, or from the Shards panel, enters deploy mode: aim the movement cursor at where it should go (it ghosts there at its true size), pick a height to hide it at, and place (DEPLOY, Space, or the PLACE button). Height is the discovery radius (spec section 7.3): 0 is a single gibson, each step up doubles the aligned cube it hides in. What is published is a location-encrypted kind:33330 event (spec section 8.6): the shard, its coordinate and plane are AES-256-GCM encrypted to the region key sha256(region_bytes), and only the lookup_id = sha256(key) is public, so the coordinate never leaves in the clear. The derivation is spec section 7.2 exactly, so a shard hidden here is one the reference CLI can find and open. The events go to the canonical relay alongside movement. CANCEL on a deploy started from the bench goes back to the bench. The green box is the region it will be found in; one too big for the view is drawn clipped around the cursor, with ZOOM OUT walls on the faces it continues through.

Moving a shard. EDIT on a shard of yours (tap it in the world) is the same deploy, started where the shard stands: its height, size and pose, the ghost on it. The shard itself stays, breathing on the WALK walls' cycle, until the move lands; then the new version is hidden and the old one leaves its bag. The new version carries d = the first version's id, which its comments and reactions name, so they stay with it. Comments also answer the bag, so they stay with it only while it stays in its region at its height; the bar says when a move leaves it. A shard hidden by reference keeps its object's own d instead.

Discovery. A background scan derives the region keys for heights 0 to 12 at wherever the scene is anchored (in a worker, since that is the O(2^h) work the protocol says looking must cost), asks the relay for content under those lookup ids, and renders whatever decrypts. Your own deployments always render; others' appear when you are near enough to compute their region. The scan only re-runs when you cross a region boundary (spec section 7.5).

Targets. The Targets panel points at any number of pubkeys the way the HUD points at Earth: a reticle in frame, a chevron on the nearest edge out of frame, the distance either way, and the avatar itself (a wireframe icosahedron in the target's own color, named) once you are near. Add a key, toggle one from the Avatars list, or load a kind 3 contact list for any npub and toggle follows. Positions are chain heads on the relay, kept live by a per-target subscription; a key with no chain is pointed at its spawn coordinate. Targets persist across reloads.

Spectating. The Avatars panel lists every pubkey with a v2 action on the relay, newest first, with a field for any npub. SPECTATE anchors the scene on that avatar's chain head (their terrain, their rooms, their trail, their spawn marker), keeps their hops arriving live, hands the chain explorer their history, and points a YOU marker back at your own avatar. The panels lock, the movement controls stand down, the compass and view controls stay, and END SPECTATION brings you home.

Cyberspace TV. TV, at the right of the question under the wordmark, or onosendai.tech/tv, plays v2's history back as a broadcast: from a random event since v2 began (2026-08-23), every movement action in the order it was signed, on a curved, fringed, scanlined picture tube set in a black surround, with the ONOSENDAI logo in its corner. Everything on the picture (the logo, clock, chiron, marquee and segment panels) is painted into the tube in Monaspace Argon, so it bends and fringes with it; cuts are a dip, a roll or a burst of dark snow. Each avatar's run of actions is one shot, framed close, medium or wide from above with a slow push-in; shots play in the order they started, so someone who moved at the same time is shown next, from their own start (MEANWHILE), and nothing is dropped. Dead air is skipped (LATER), and a spawn that went nowhere is a line on the ticker rather than a shot. The chiron says who and what, with a zoom gauge; the ticker gives the counts as of the moment on tape (avatars, bags, objects, their chain, their bags). Watching only: nothing is signed or published, and OFF or Escape puts the view back. scripts/tv-smoke.mjs plays a recorded tape offline.

The tape carries more than moves, each as a segment in its place by time. A bag sealed with a public hint box is shown there: its outline draws, its sides fill, a key stamps onto each side, the sides fade, and the outline stays for the rest of the tape. A bag without one is never placed (where it is, is the hunt): it plays on a cube in an inset, LOCATION UNKNOWN. A public object gets an advertisement: NOW AVAILABLE!, the model turning in the middle. A comment on a move or a bag gets the news desk: the commenter as a photograph, the quote printing out; one sealed to a bag's region prints as redaction. A new avatar gets the product shot too (NEW LOOK), and a reaction to a shard or a move is a line on the ticker.

The spawn marker. v1's spawn model (public/spawn.glb: three hexagonal rings, a hollow cube, six radiating bars) stands at the pubkey coordinate, sized in cells like the avatar so it marks the spawn cell at any scale.

Derezz. The last panel in the HUD abandons the chain: a new spawn event is signed (and published, when Live), which per spec section 3.2 retires every action before it, and the avatar is back at its pubkey with nothing behind it. It arms a warning first, in v1's words, because it cannot be undone.

Local / Live. The switch under RECALL and COMMIT decides whether events leave the device. Live (the default) publishes each one to the canonical relay wss://relay.onosendai.tech as it is signed, in chain order, and the proof chain panel shows how many the relay has acknowledged. Local keeps them here; switching to Live later publishes the whole backlog, oldest first, so every prefix the relay holds is itself a valid chain.

What you are looking at

Cell fill is terrain K. K in [0, 16] is the terrain-derived temporal height for a destination, setting the non-cacheable temporal work every hop into that cell costs. It is Binomial(16, 0.5), so it clusters around 8; the palette is tuned to spread the common 5..11 band rather than the unused extremes.

Line brightness is LCA height. For each gridline the app computes the real findLcaHeight of crossing it at the current scale, and lights it in proportion to how far above the cheapest possible crossing that is. Stepping 7 -> 8 costs height 4 while 8 -> 9 costs height 1, for the same single gibson. That asymmetry is the whole point, and it is drawn.

Scale changes what a boundary means. Q and E move the step size by powers of two. At 2^0 you see individual gibsons; at 2^30 each cell is a sector. Terrain correlates at cell sizes 2^3 to 2^11, so the field looks smooth when you zoom below that band and uncorrelated above it.

Handedness, and why it matters

Cyberspace is a left-handed coordinate system. Section 9.4 defines it as ECEF with two axes swapped (X_cs = X_ecef, Y_cs = Z_ecef, Z_cs = Y_ecef), and swapping two axes of a right-handed frame inverts handedness. That is why section 11.1's convention (+X screen-right, +Y up, +Z forward into the screen) cannot be reproduced in three.js, which is right-handed, by camera placement alone.

Section 11.4 requires resolving this with a render-space transform rather than by mirroring or re-labelling axes. This app does it in exactly one place: flipHandedness in lib/space.ts, applied at the boundary where viewAxes converts camera directions back into cyberspace axis names. Everything upstream is render space; everything downstream is cyberspace.

Getting this wrong does not produce a visibly broken picture. It produces a mirrored one, which looks perfectly fine on its own and silently disagrees with every other viewer about which way is left. It is asserted directly in the test suite across all 24 reachable views.

Two consequences worth knowing:

  • The canonical view comes out as the identity quaternion, i.e. three.js's default camera. That it lands exactly there is a good sign the transform sits in the right place.
  • The top-down map view puts +Z (forward, the black sun direction) up the screen, which is the conventional map orientation. Before the handedness fix it pointed down.

Architecture

src/
  lib/space.ts        coordinate <-> render-space maths, view orientation
  lib/palette.ts      the two visual encodings (terrain fill, boundary lines)
  lib/events.ts       kind:3333 builders, parser, chain reassembly (spec 8, 10)
  lib/relay.ts        the one relay, publish / query / subscribe
  lib/publisher.ts    drains unpublished events in chain order while Live
  lib/workers.ts      worker singletons
  store/              zustand store: position, scale, view, proof telemetry
  workers/            proof and terrain sampling, off the main thread
  scene/              R3F: camera rig, terrain field, lattice, avatar, cursor
  hud/                overlay panels

Two rules hold the design together:

No absolute coordinate is ever converted to a float. Positions are bigint throughout and are rendered as integer offsets from the avatar's aligned cell, so precision is exact at any depth into the axis. subCellFraction uses fixed-point bigint division for the same reason: past 2^53 a float ratio collapses to zero.

Compute never blocks the frame. A hop is O(2^h) Cantor pairings, so at higher scales a single keypress is real work. Proofs and terrain sampling both run in workers, and the proof worker streams progress so the HUD shows genuine elapsed cost rather than a spinner.

When a hop's LCA height exceeds the Cantor compute ceiling, Space commits a Merkle sidestep instead (spec section 6): a Merkle hash tree over the same LCA subtree, which has no storage wall and costs purely time (2^(h+1) SHA-256 evaluations per crossing axis). A sidestep lands exactly 1 gibson past the blocking boundary, not at the cursor: crossing the mountain drops you at the pass, and the rest of the journey is the next commit. The tether shows this as two legs: purple to the landing, then amber (or red, if another wall stands) for the remainder. The proof panel previews the hash count and a rough wall-clock estimate before you pay; X cancels mid-hash.

Relationship to v1

This branch starts from zero. ONOSENDAI v1 lives on master and targets Cyberspace v1, whose movement model (proof-of-work drift and velocity over DecimalVector3) is precisely what v2 replaced. The two share constants but not semantics, so v1 code is cherry-picked deliberately rather than carried over.

Tests

npm test        # view geometry and coordinate maths

The protocol maths itself is tested in cyberspace-cli-js against golden vectors shared with the Python implementation.

Disclaimer

This software is experimental. It is provided "as is", without warranty of any kind. Use it at your own risk.

  • Your keys, funds and agents are your responsibility. Anyone who has your private key, your signer or your wallet connection string can act as you or spend from your wallet. Keep them safe and keep backups. Nobody can recover them for you.
  • Lightning payments are final. A payment that has been sent cannot be reversed, and nobody has to refund it.
  • Not financial advice. Nothing in this software or its documentation is financial, investment, legal or tax advice.
  • Other people's services can fail. This software relies on things the author does not run: nostr relays, Lightning wallets and nodes, ecash mints, hosting and other services. They can go down, lose data, refuse service or change without notice.
  • Nostr is public. What you publish can be copied by anyone and may never be fully deleted.
  • AI agents make mistakes. If you connect an AI agent to this software, you are responsible for everything it does, including what it publishes, signs and pays for.
  • No liability. To the fullest extent the law allows, the author (arkinox) and the contributors are not liable for any loss or damage of any kind that comes from using this software, including lost funds, keys, data or work, whether it is caused by a bug, a relay, a mint, a wallet, another service, an AI agent or anything else.

This is a plain-language summary. The license in this repository governs, and its disclaimer of warranties and limitation of liability apply in full.

The app's own terms are at onosendai.tech/terms (public/terms.html), linked from the menu and from the tutorial's welcome.

License

The code is CC BY-SA 4.0. The full legal code is in LICENSE.

The ONOSENDAI, HOSAKA and Cyberspace TV logos and brand artwork are © 2023-2026 arkinox, licensed under CC BY-NC-ND 4.0. ONOSENDAI™, HOSAKA™ and CYBERSPACE TV™ are trademarks of arkinox and are not covered by either license: a fork must not present itself under these names, and monetized code must not use the names or logos. See NOTICE.md.

About

The Cyberspace client for the one true metaverse: nostr

Topics

Resources

Stars

61 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages