Program
Accounts
The voynich program is an Anchor program. Its address on a cluster is programId in GET /v1/config. Every account below starts with an 8-byte discriminator. All but Weights are Borsh-encoded after it. Integers are little-endian.
| Account | Discriminator | Fields | Bytes |
|---|---|---|---|
Call | 3ee7a93a9a9653c4 | 16 | 302 |
Config | 9b0caae01efacc82 | 7 | 116 |
Enclave | dea6dffc12035422 | 11 | |
Grant | a1a60bcdcc87cd36 | 7 | |
Model | 98ddf77ab97ddf97 | 18 | |
Receipt | 279a496a50669199 | 16 | 401 |
bytes is the encoded length of an account whose fields are all fixed in size. Model, Enclave and Grant hold strings or lists, so their length varies inside the space they are created with.
| Account | Address | Space | Rent paid by |
|---|---|---|---|
| Config | PDA ["config"] | 116 bytes | the admin |
| Model | PDA ["model", name] | 6,000 bytes | the owner |
| Weights | any address, created by the owner | 56 bytes plus its ciphertext | the owner |
| Enclave | PDA ["enclave", signing_key] | 470 bytes | the operator |
| Grant | PDA ["grant", model, enclave] | 223 bytes | the grant's payer |
| Call | PDA ["call", caller, nonce] | 302 bytes | the caller |
| Receipt | PDA ["receipt", call] | 401 bytes | the settling payer |
In a seed, name is the model's name as UTF-8, an address is its 32 bytes, and nonce is 8 bytes little-endian.
Config#
One per program, at PDA ["config"]. Written by initialize and set_config.
| Field | Type | Offset | Meaning |
|---|---|---|---|
admin | pubkey | 8 | The wallet that may change the configuration. |
attestation_program | pubkey | 40 | The program whose attestation records the protocol reads. |
record_layout_version | u8 | 72 | The layout version of those records. |
fee_recipient | pubkey | 73 | The wallet the protocol share of every settled call is paid to. |
protocol_share_bps | u16 | 105 | The protocol share of a call's price, in basis points. |
call_deadline_slots | u64 | 107 | How many slots after opening a call can still settle. |
bump | u8 | 115 | The PDA bump. |
Model#
One per sealed model, at PDA ["model", name]. Created by create_model. Changed by seal_model, set_price, retire_model, grant_by_owner and settle_call.
| Field | Type | Meaning |
|---|---|---|
owner | pubkey | The wallet that sealed the model. |
name | string | The model's name, 1 to 32 bytes: lowercase letters and digits in groups joined by single hyphens. |
manifest | bytes | The manifest as compact UTF-8 JSON, up to 4,096 bytes. A sketch manifest leaves out the fields that equal the sketch defaults. |
weights | Vec<pubkey> | The Weights accounts in order, 1 to 8. |
size_bytes | u64 | The length of the ciphertext across all Weights accounts. |
cipher | string | The cipher id, xchacha20poly1305-64k-v1. |
nonce_prefix | [u8; 16] | The 16-byte nonce prefix of the weights cipher. |
ciphertext_sha256 | [u8; 32] | SHA-256 of the complete ciphertext. All zero until the model is sealed. |
allowed_measurements | Vec<[u8; 48]> | The measurements allowed to open the model, 1 to 8. |
price | u64 | The price of one call, in base units of the price mint. |
price_mint | pubkey | The mint the price is paid in. The default (all-zero) address means SOL. |
operator_share_bps | u16 | The operator's share of the price, in basis points. |
upload_key | pubkey | The key allowed to write the ciphertext. The default address once the model is sealed. |
status | ModelStatus | Uploading, Sealed, Live or Retired. |
created_slot | u64 | The slot the model was created in. |
sealed_slot | u64 | The slot the model was sealed in. 0 until then. |
calls_settled | u64 | How many calls to the model have settled. |
bump | u8 | The PDA bump. |
status is one byte: 0 Uploading, 1 Sealed, 2 Live, 3 Retired. A measurement is 48 bytes. What these facts mean is in Sealed models.
Weights#
A Weights account holds ciphertext. It is not an Anchor-typed account: the program reads and writes it in place. It is a 56-byte header followed by the ciphertext bytes.
| Offset | Bytes | Field | Meaning |
|---|---|---|---|
| 0 | 8 | discriminator | Set by create_model. |
| 8 | 32 | model | The Model the account belongs to. |
| 40 | 4 | index | Its place in the model's weights list, from 0. |
| 44 | 4 | size_bytes | The ciphertext bytes it holds: its data length minus 56. |
| 48 | 4 | written_bytes | The highest end written so far. Equal to size_bytes once the account is written to its end. |
| 52 | 4 | reserved | 0. |
| 56 | size_bytes | ciphertext | The model's ciphertext from this account's offset on. |
The owner creates each Weights account before create_model: owned by the voynich program, rent-exempt, with its first 56 bytes zero, and between 57 bytes and 10 MiB long. A model has 1 to 8 of them. The ciphertext of the model is the ciphertext of its Weights accounts in order, and their sizes add up to the Model's size_bytes.
Enclave#
One per registered enclave, at PDA ["enclave", signing_key]. Created by register_enclave. Changed by refresh_enclave and settle_call.
| Field | Type | Meaning |
|---|---|---|
signing_key | pubkey | The enclave's Ed25519 signing key, the key its attestation record names. |
encryption_key | [u8; 32] | The enclave's X25519 encryption key. Grants and call inputs are encrypted to it. |
operator | pubkey | The wallet that registered the enclave. It receives the operator share. |
endpoint | string | The enclave's http:// or https:// address, up to 256 bytes. |
attestation_record | pubkey | The address of the enclave's attestation record. |
hardware_type | u8 | 0 dev, 1 Intel TDX, 2 AMD SEV-SNP, as the record states. |
measurement | [u8; 48] | The 48-byte measurement the record states. |
recorded_slot | u64 | The slot the record was written in, as of the last register or refresh. |
expires_at_slot | u64 | The slot the record expires at, as of the last register or refresh. |
calls_settled | u64 | How many calls the enclave has settled. |
bump | u8 | The PDA bump. |
The record itself is in Enclaves and attestation.
Grant#
One per model and enclave, at PDA ["grant", model, enclave]. Written by grant_by_owner and grant_by_enclave. Marked by revoke_grant.
| Field | Type | Meaning |
|---|---|---|
model | pubkey | The Model the grant opens. |
enclave | pubkey | The Enclave the grant is made to. |
wrapped_key | bytes | The model key wrapped to the enclave's encryption key: a version 1 envelope of 105 bytes. |
granted_by | pubkey | The owner's wallet, or the Enclave account of the enclave that passed the key on. |
granted_slot | u64 | The slot the grant was written in. |
revoked | bool | True once the owner has revoked the grant. |
bump | u8 | The PDA bump. |
Call#
One per call, at PDA ["call", caller, nonce]. Created by open_call. Changed by settle_call and refund_call.
| Field | Type | Offset | Meaning |
|---|---|---|---|
caller | pubkey | 8 | The wallet that opened the call and paid the escrow. |
model | pubkey | 40 | The Model called. |
enclave | pubkey | 72 | The Enclave chosen to answer. |
nonce | u64 | 104 | A number the caller chose. With the caller it gives the call its address. |
input_hash | [u8; 32] | 112 | SHA-256 of the input envelope. |
price | u64 | 144 | The amount in escrow: the model's price when the call opened. |
price_mint | pubkey | 152 | The mint of the escrow. The default address means SOL. |
owner | pubkey | 184 | The model's owner when the call opened. Receives the owner's part. |
operator | pubkey | 216 | The enclave's operator when the call opened. Receives the operator share. |
fee_recipient | pubkey | 248 | The protocol's fee recipient when the call opened. Receives the protocol share. |
operator_share_bps | u16 | 280 | The model's operator share when the call opened. |
protocol_share_bps | u16 | 282 | The protocol share when the call opened. |
opened_slot | u64 | 284 | The slot the call opened in. |
deadline_slot | u64 | 292 | The last slot the call can settle in. After it the call can be refunded. |
status | CallStatus | 300 | Open, Settled or Refunded. |
bump | u8 | 301 | The PDA bump. |
status is one byte: 0 Open, 1 Settled, 2 Refunded.
The owner, operator, fee recipient, price and both shares are copied into the Call when it opens. A price change, a new fee recipient or a new share after that leaves an open call as it was.
A price in SOL is held as lamports in the Call account itself, above its rent. A price in a mint is held in the Call's associated token account for that mint.
Receipt#
One per settled call, at PDA ["receipt", call]. Created by settle_call and never changed.
| Field | Type | Offset | Meaning |
|---|---|---|---|
call | pubkey | 8 | The Call this receipt settles. |
model | pubkey | 40 | The Model that was called. |
enclave | pubkey | 72 | The Enclave that answered. |
input_hash | [u8; 32] | 104 | SHA-256 of the input envelope. |
output_hash | [u8; 32] | 136 | SHA-256 of the output envelope. |
signature | [u8; 64] | 168 | The enclave's Ed25519 signature over the receipt message. |
slot | u64 | 232 | The slot the call settled in. |
price_mint | pubkey | 240 | The mint that was paid. The default address means SOL. |
total | u64 | 272 | The whole price paid out. |
owner | pubkey | 280 | The wallet paid the owner's part. |
operator | pubkey | 312 | The wallet paid the operator share. |
fee_recipient | pubkey | 344 | The wallet paid the protocol share. |
owner_amount | u64 | 376 | What the owner received. |
operator_amount | u64 | 384 | What the operator received. |
protocol_amount | u64 | 392 | What the fee recipient received. |
bump | u8 | 400 | The PDA bump. |
owner_amount, operator_amount and protocol_amount add up to total. Reading a Receipt from your own program is in Reading a receipt from another program.