Seraphin seals a model. Its weights are written on Solana as ciphertext anyone can fetch, they open only inside an enclave whose runtime the chain has measured, and every answer comes back with a receipt anyone can check.
Why seal a model
A model you publish is a model you give away. A model you keep on your own server is a model nobody can audit. A sealed model sits between the two: the bytes are public and fixed by hash, so anyone can see that the model exists and has not changed, and the key that opens them lives only where the owner allows.
The four parts
Part
What it is
Where it lives
Model
The ciphertext of the weights, its SHA-256, its price and the measurements allowed to open it.
Model and weights accounts
Enclave record
An enclave's signing key, encryption key, measurement, hardware type and expiry.
Record account
Grant
The model key wrapped to one enclave's encryption key, 125 bytes.
Grant account, beside the model
Receipt
The enclave's signature over the call, the slot and both hashes.
Receipt account
codex-16
codex-16 is the first sealed model. It recognises 16 drawings: circle, triangle, square, star, heart, moon, arrow, check, cross, spiral, lightning, house, fish, sun, eye and infinity. It is a $P point-cloud recogniser: 96 templates of 32 points each, 6,351 bytes of weights, 6,471 bytes of ciphertext.
NOTEThe enclave that answers codex-16 today has hardware type dev: the runtime runs as a Web Worker in your tab. Every step is real cryptography, and every check on this site runs on real bytes. What dev hardware cannot give you is secrecy from the person at the keyboard; see the threat model.
Start
Call a model in five minutes
One import, one call. The SDK is a single ES module served from this site, with no dependencies.
Import
import { call } from'https://seraphinus.vercel.app/lib/seraph.js'// strokes: an array of strokes, each an array of [x, y] in any unitsconst { answer, receipt, verified } = awaitcall('codex-16', strokes)
console.log(answer.label, answer.p) // 'star' 0.98
console.log(verified.ok) // true
The SDK fetches the model's manifest and ciphertext, checks the ciphertext against the sealed SHA-256, starts the enclave runtime, encrypts your input to it, and verifies the receipt before it hands you the answer.
Try it
LIVE · codex-16
Ask it to read a doodle of
// press Run
From another site
The module, the manifest and the ciphertext are static files, so a page on any origin can import the SDK by its full address. The enclave starts as a module Worker from the same origin as the SDK.
Start
Seal a model in ten minutes
The Seal page walks through six steps. The same steps in code:
seal.js
import { train, seal, grant, slot, unb64, b64 } from'https://seraphinus.vercel.app/lib/seraph.js'// 1 · prepare: labelled drawings become SRPH weightsconst weights = train([{ label: 'frog', strokes }, { label: 'boat', strokes: s2 }])
// 2–3 · encrypt and create: a fresh 256-bit key, 1 KiB chunks, an addressconst sealed = awaitseal(weights) // { key, ciphertext, sha256, address }// 4–5 · write the ciphertext, fix the hash at a slotconst sealedAt = awaitslot()
// 6 · grant: wrap the key to an enclave, then forget itconst record = await (awaitfetch('https://seraphinus.vercel.app/models/enclave.json')).json()
const wrapped = awaitgrant(sealed.key, unb64(record.encKey))
sealed.key.fill(0)
const model = { name: 'my-codex', address: sealed.address, sha256: sealed.sha256,
ciphertext: b64(sealed.ciphertext), grant: b64(wrapped), measurements: [record.measurement], sealedAt }
Pass model to call(model, strokes) and it answers. The key existed in plaintext in your tab between seal and fill(0), and nowhere else.
Concepts
Sealed models
A sealed model is a ciphertext with a fixed hash, a price and a list of runtimes allowed to open it.
Ciphertext
The weights are encrypted with AES-256-GCM under a random 256-bit model key, in 1,024-byte chunks. The ciphertext starts with an 8-byte nonce prefix; each chunk's nonce is that prefix followed by the chunk index as a big-endian u32, and each chunk's additional data is srph-chunk-<index>. A chunk cannot be moved or swapped without its tag failing.
Address and hash
The SHA-256 of the whole ciphertext is fixed at sealing. The model's address is that hash in base58. The SDK refuses to call a model whose fetched bytes hash to anything else.
The manifest
/models/codex-16.json
…
Concepts
Enclaves and attestation
An enclave is a runtime that holds two keys and runs models in its own memory. Its record says which runtime it is and until when it may be trusted.
Two keys
Encryption key, ECDH P-256. Grants and call inputs are encrypted to it.
Signing key, ECDSA P-256. Every receipt is signed with it.
Measurement
The measurement is the SHA-256 of the runtime file as served: /lib/enclave.js. Change one byte of the runtime and the measurement changes, and no model that lists the old one will be granted to it. Your browser can check it right now:
LIVE · measure the runtime
// press Measure
The record
/models/enclave.json
…
Hardware type
Where the runtime runs
Keeps keys from
dev
A module Web Worker in the caller's tab
Other sites, the network
tee
A confidential VM with a hardware attestation report
The operator, the host, the network
Concepts
Grants
A grant is the model key wrapped to one enclave. 125 bytes, on chain, useless to everyone else.
How the key is wrapped
Make an ephemeral ECDH P-256 key pair.
Derive a shared secret with the enclave's encryption key.
HKDF-SHA256 it with info srph/grant into an AES-256-GCM key.
Encrypt the 32-byte model key under a random 12-byte IV.
Bytes
Field
0–64
Ephemeral public key, uncompressed P-256
65–76
IV
77–124
Wrapped key and its 16-byte tag
Granting the next enclave
The owner makes the first grant. A granted enclave can grant another one: it reads the newcomer's record, checks its measurement against the model's list and its expiry against the current slot, wraps the key inside its own memory and signs the grant.
Concepts
Calls and receipts
A call carries an input encrypted to the enclave, a reply key made for that call, the price in escrow and a deadline.
One call
The caller normalises the drawing to 32 points and encrypts it to the enclave (srph/input).
The caller makes a reply key pair; only its public half travels.
The enclave unwraps the grant, opens the weights, runs the model.
The output is encrypted to the reply key (srph/output).
The enclave signs a receipt over seraphin-receipt|v1|model|call|slot|input|output.
A receipt
receipt.json
{
"v": 1,
"model": "8ta8EXsVrMQAHTQJs5yVhNz7q7vW8kifCGv1e2RySUwP",
"call": "87nVVP…G3WVCQ",
"slot": 472079882,
"input": "3650b30b…", // SHA-256 of the encrypted input"output": "6318e647…", // SHA-256 of the answer JSON"enclave": "6NGtXp…5E86aG",
"sig": "hN2c9vQ…", // ECDSA P-256, raw r‖s, base64"answer": { … } // only when the call asked for an open answer
}
Sealed or open answers
By default the answer exists in plaintext only in the enclave and in the caller's tab. Pass { open: true } and the enclave also writes it into the receipt, so a program or a stranger can act on it.
Deadline
A call not settled within 450 slots, about three minutes, returns the escrow to the caller. There is no third way out of escrow.
Concepts
Fees and the token
A call has one price, set by the owner and split at settlement between the owner, the operator and the protocol.
The split
Party
Receives
Operator
price × operator share, set by the owner per model
Protocol
price × 5%
Owner
the rest
codex-16 runs on dev hardware, so its price is 0 SOL and every share of it is also 0 SOL. The arithmetic is very reliable.
The runtime is one file. Serve it, and it boots, reads its record and answers calls for every model granted to it.
worker.js
const w = newWorker('https://seraphinus.vercel.app/lib/enclave.js', { type: 'module' })
w.onmessage = e => console.log(e.data) // { type: 'boot', record } then one reply per job// job: { id, address, grant, ciphertext, input, reply, call, slot, open }
WARNINGA worker can only start from its own origin, so a page elsewhere should go through call(), which starts the runtime for you. A runtime you modify gets a new measurement and needs its own record and grants.
Guides
The script
Every byte on this site is drawn as one of 256 glyphs. Byte 0 always looks the same; nobody has ever read a sentence in it.
Each glyph is built on a 3 × 4 lattice from a seeded generator: an optional stem, one to three lines, hooks, arcs or loops, sometimes a dot. drawGlyph(ctx, byte, x, y, w, h) draws one on a canvas, glyphSVG(byte, size) returns it as SVG.
LIVE · write in it
Reference
SDK
/lib/seraph.js, about 20 KB, no dependencies, browsers and Node 20+.
Function
Returns
call(model, strokes, opts?)
{ answer, receipt, verified, timings }. model is a name or a manifest.
open(model)
A handle with call(), after checking the ciphertext hash.
normalize(strokes, n = 32)
n points, resampled, scaled to a unit box, centred.
The bytes you fetched are not the bytes that were sealed. Do not call.
not SRPH weights
The key opened something, but not a Seraphin model.
The operation failed for some operation-specific reason
WebCrypto's way of saying a tag failed: wrong key, wrong enclave, or a changed byte.
enclave failed to boot
Module workers are blocked, or the runtime was served from another origin.
More
Threat model
What sealing protects, and from whom.
It protects against
Anyone who reads the chain: the ciphertext is AES-256-GCM under a key that never touches it in plaintext.
Swapped or edited weights: the hash is fixed, every chunk carries a tag.
A forged answer: the receipt is signed by a key the record binds to a measured runtime.
A changed runtime: a new measurement gets no grant.
It does not protect against
The operator of dev hardware. The dev runtime's keys sit in its public source, which is why it is called dev. Secrecy from the operator needs tee hardware.
A model owner who leaks their own key before granting.
Model extraction by asking many questions. Price per call is the defence, and codex-16 is free.
More
FAQ
Short answers.
Why does everything look like a manuscript?
Because ciphertext is a book in a language nobody speaks. We just gave it an alphabet.
Is codex-16 a neural network?
No. It is a point-cloud recogniser with 96 templates. Sealing does not care what the weights mean; a larger model is a longer ciphertext.
Can I see the weights?
Every byte, on the front page and in /models/codex-16.bin. Reading them is the part we cannot help with.
What does $SERAPH do?
It takes the protocol share of every settled call. On dev hardware calls cost 0 SOL, so it takes 5% of nothing, faithfully.
Where is my sealed model stored?
In your browser's local storage: the ciphertext and the grant. The key is never stored anywhere.