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.

AccountDiscriminatorFieldsBytes
Call3ee7a93a9a9653c416302
Config9b0caae01efacc827116
Enclavedea6dffc1203542211
Granta1a60bcdcc87cd367
Model98ddf77ab97ddf9718
Receipt279a496a5066919916401

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.

AccountAddressSpaceRent paid by
ConfigPDA ["config"]116 bytesthe admin
ModelPDA ["model", name]6,000 bytesthe owner
Weightsany address, created by the owner56 bytes plus its ciphertextthe owner
EnclavePDA ["enclave", signing_key]470 bytesthe operator
GrantPDA ["grant", model, enclave]223 bytesthe grant's payer
CallPDA ["call", caller, nonce]302 bytesthe caller
ReceiptPDA ["receipt", call]401 bytesthe 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.

FieldTypeOffsetMeaning
adminpubkey8The wallet that may change the configuration.
attestation_programpubkey40The program whose attestation records the protocol reads.
record_layout_versionu872The layout version of those records.
fee_recipientpubkey73The wallet the protocol share of every settled call is paid to.
protocol_share_bpsu16105The protocol share of a call's price, in basis points.
call_deadline_slotsu64107How many slots after opening a call can still settle.
bumpu8115The 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.

FieldTypeMeaning
ownerpubkeyThe wallet that sealed the model.
namestringThe model's name, 1 to 32 bytes: lowercase letters and digits in groups joined by single hyphens.
manifestbytesThe manifest as compact UTF-8 JSON, up to 4,096 bytes. A sketch manifest leaves out the fields that equal the sketch defaults.
weightsVec<pubkey>The Weights accounts in order, 1 to 8.
size_bytesu64The length of the ciphertext across all Weights accounts.
cipherstringThe 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_measurementsVec<[u8; 48]>The measurements allowed to open the model, 1 to 8.
priceu64The price of one call, in base units of the price mint.
price_mintpubkeyThe mint the price is paid in. The default (all-zero) address means SOL.
operator_share_bpsu16The operator's share of the price, in basis points.
upload_keypubkeyThe key allowed to write the ciphertext. The default address once the model is sealed.
statusModelStatusUploading, Sealed, Live or Retired.
created_slotu64The slot the model was created in.
sealed_slotu64The slot the model was sealed in. 0 until then.
calls_settledu64How many calls to the model have settled.
bumpu8The 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.

OffsetBytesFieldMeaning
08discriminatorSet by create_model.
832modelThe Model the account belongs to.
404indexIts place in the model's weights list, from 0.
444size_bytesThe ciphertext bytes it holds: its data length minus 56.
484written_bytesThe highest end written so far. Equal to size_bytes once the account is written to its end.
524reserved0.
56size_bytesciphertextThe 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.

FieldTypeMeaning
signing_keypubkeyThe 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.
operatorpubkeyThe wallet that registered the enclave. It receives the operator share.
endpointstringThe enclave's http:// or https:// address, up to 256 bytes.
attestation_recordpubkeyThe address of the enclave's attestation record.
hardware_typeu80 dev, 1 Intel TDX, 2 AMD SEV-SNP, as the record states.
measurement[u8; 48]The 48-byte measurement the record states.
recorded_slotu64The slot the record was written in, as of the last register or refresh.
expires_at_slotu64The slot the record expires at, as of the last register or refresh.
calls_settledu64How many calls the enclave has settled.
bumpu8The 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.

FieldTypeMeaning
modelpubkeyThe Model the grant opens.
enclavepubkeyThe Enclave the grant is made to.
wrapped_keybytesThe model key wrapped to the enclave's encryption key: a version 1 envelope of 105 bytes.
granted_bypubkeyThe owner's wallet, or the Enclave account of the enclave that passed the key on.
granted_slotu64The slot the grant was written in.
revokedboolTrue once the owner has revoked the grant.
bumpu8The PDA bump.

Call#

One per call, at PDA ["call", caller, nonce]. Created by open_call. Changed by settle_call and refund_call.

FieldTypeOffsetMeaning
callerpubkey8The wallet that opened the call and paid the escrow.
modelpubkey40The Model called.
enclavepubkey72The Enclave chosen to answer.
nonceu64104A number the caller chose. With the caller it gives the call its address.
input_hash[u8; 32]112SHA-256 of the input envelope.
priceu64144The amount in escrow: the model's price when the call opened.
price_mintpubkey152The mint of the escrow. The default address means SOL.
ownerpubkey184The model's owner when the call opened. Receives the owner's part.
operatorpubkey216The enclave's operator when the call opened. Receives the operator share.
fee_recipientpubkey248The protocol's fee recipient when the call opened. Receives the protocol share.
operator_share_bpsu16280The model's operator share when the call opened.
protocol_share_bpsu16282The protocol share when the call opened.
opened_slotu64284The slot the call opened in.
deadline_slotu64292The last slot the call can settle in. After it the call can be refunded.
statusCallStatus300Open, Settled or Refunded.
bumpu8301The 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.

FieldTypeOffsetMeaning
callpubkey8The Call this receipt settles.
modelpubkey40The Model that was called.
enclavepubkey72The Enclave that answered.
input_hash[u8; 32]104SHA-256 of the input envelope.
output_hash[u8; 32]136SHA-256 of the output envelope.
signature[u8; 64]168The enclave's Ed25519 signature over the receipt message.
slotu64232The slot the call settled in.
price_mintpubkey240The mint that was paid. The default address means SOL.
totalu64272The whole price paid out.
ownerpubkey280The wallet paid the owner's part.
operatorpubkey312The wallet paid the operator share.
fee_recipientpubkey344The wallet paid the protocol share.
owner_amountu64376What the owner received.
operator_amountu64384What the operator received.
protocol_amountu64392What the fee recipient received.
bumpu8400The 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.