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.

  1. Prepare

    Choose the weights file and its manifest.

  2. Encrypt

    The model key is drawn and the weights are encrypted on this device.

    model key
  3. uploading
    Create

    Sign once to create the model and fund the upload key.

  4. Write

    The ciphertext is written to chain in chunks.

  5. sealed
    Seal

    Sign to fix the hash. The bytes can no longer change.

  6. live
    Grant

    Wrap the model key to a first enclave.

Drawn line: an act by a person or an enclaveCap: what the chain holds

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 (sketch or tensor), 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/quote returns 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.

StepWhat happensThe owner signs
PrepareThe weights file and the manifest are read on the device. Nothing is sent.
EncryptThe device draws a random model key and encrypts the weights.
CreateThe 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
WriteThe upload key writes the ciphertext to chain, 512 bytes per transaction, with no wallet prompt.
SealThe hash of the ciphertext is fixed. The bytes can no longer change.once
GrantThe model key is wrapped to the first enclave. The model is live.once

Go to /seal with a connected wallet.

  1. Prepare. Choose the weights file and the manifest.
  2. Set the name, the price and its mint, the operator share and the allowed measurements.
  3. 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.
  4. Create. Approve the transactions that create the accounts and fund the upload key.
  5. Write. The page shows the upload's progress in bytes and transactions. After a reload it picks the upload up where it stopped.
  6. Seal. Approve the transaction that fixes the hash.
  7. 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>.

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.

Next#