Seal a model in ten minutes
This page ends with a model of your own on chain as ciphertext, granted to an enclave and taking paid calls.
- Prepare
Choose the weights file and its manifest.
- Encrypt
The model key is drawn and the weights are encrypted on this device.
model key - uploadingCreate
Sign once to create the model and fund the upload key.
- Write
The ciphertext is written to chain in chunks.
- sealedSeal
Sign to fix the hash. The bytes can no longer change.
- liveGrant
Wrap the model key to a first enclave.
What it takes#
- The weights, as an ONNX file. One Weights account holds 10,485,704 bytes of ciphertext and a model has up to 8.
- A manifest, as JSON: the model's name, its input kind (
sketchortensor), its input shape and its labels. The fields are in Sealed models. - A wallet that holds SOL for the rent of the Model and Weights accounts, the upload's fees and a few transactions of its own.
POST /v1/models/quotereturns the amounts for a ciphertext size, the upload funding among them. - A measurement to allow and an enclave to grant. /enclaves lists every registered enclave with its measurement. The model lists the measurements that may open it, and the first grant goes to one enclave with a listed measurement.
- A price per call, the mint it is paid in, and the operator share. See Fees and the token.
The steps#
Sealing is the same six steps every way it is done.
| Step | What happens | The owner signs |
|---|---|---|
| Prepare | The weights file and the manifest are read on the device. Nothing is sent. | |
| Encrypt | The device draws a random model key and encrypts the weights. | |
| Create | The model's metadata is quoted to check it fits the create_model transaction. Then the Weights accounts and the Model are created and a one-time upload key is funded. | once per Weights account, once for the Model |
| Write | The upload key writes the ciphertext to chain, 512 bytes per transaction, with no wallet prompt. | |
| Seal | The hash of the ciphertext is fixed. The bytes can no longer change. | once |
| Grant | The model key is wrapped to the first enclave. The model is live. | once |
Go to /seal with a connected wallet.
- Prepare. Choose the weights file and the manifest.
- Set the name, the price and its mint, the operator share and the allowed measurements.
- Encrypt. Set a password of at least 8 characters, entered twice. The browser draws the model key and encrypts the weights. The model key, and the upload key while the seal is being written, are saved in that browser only encrypted under the password. The site asks for the password once each time it is opened and never stores it.
- Create. Approve the transactions that create the accounts and fund the upload key.
- Write. The page shows the upload's progress in bytes and transactions. After a reload it picks the upload up where it stopped.
- Seal. Approve the transaction that fixes the hash.
- Grant. Choose the first enclave and approve the grant.
The page ends on the model's address and leads to its page at /models/<name>.
npm install -g voynich
export VOYNICH_API_URL=https://<api host>voynich seal model.onnx \
--manifest manifest.json \
--state owner.enc.json \
--price <base units> \
--operator-share-bps <basis points> \
--measurement <96 hex characters> \
--upload-funding <lamports> \
--enclave <enclave address> \
--keypair <path to a Solana keypair file>The CLI asks for a password and keeps the model key and the upload's state in owner.enc.json, encrypted under it. Progress goes to stderr. The model is printed as JSON when it is live. An interrupted sealing carries on with --resume. Every flag is in CLI: seal.
const price = { amount: '100000', mint: null, decimals: 9, symbol: 'SOL' }
const { model, resume } = await voynich.seal({
weights: onnxBytes,
manifest,
price,
operatorShareBps: 2500,
allowedMeasurements: [measurement],
uploadFundingLamports: '5000000',
grantEnclave: enclave,
onPrepared: state => save(state),
onProgress: progress => console.log(progress.step, progress.bytesWritten, progress.totalBytes),
})The figures in this sample are sample inputs. Every option, the saved state and resuming are in SDK: seal.
What exists now#
- A Model at the address derived from its name, with status
live, listed on /models. - Its ciphertext in Weights accounts, readable by anyone, with its SHA-256 fixed in the Model.
- A Grant to the first enclave, which fetches the ciphertext, checks the hash, unwraps the key and starts answering.
- A call panel on the model's page. Each settled call pays the owner's part to the owner's wallet.