Acki Nacki VM Instructions
MINTECC (C726)
Mint any ECC Token
Input: ECC KEYCan be invoked only in special contracts. link to the opcode
CNVRTSHELLQ (С727)
Converts SHELL to VMSHELL at a 1:1 ratio.
Input: amount of nanotokens to convertQ in the end stands for ‘quiet’ which means that if there is not enough Shell, it will not throw an exception.
If the account balance does not have the required number of tokens, the exchange will be made for the entire available amount. That is, MIN(available_tokens, want_cnt_to_convert).
link to the opcode
MINTSHELL (С728)
Mint some VMSHELL tokens, allowed by available credit in Dapp Config for this Dapp Id
Input: amount of nanoVMSHELL to mintCALCBKREWARD (С729)
Calculate reward for BK after epoch ended.
CALCMINSTAKE (С730)
Calculate minstake for BK epoch start.
VERGRTH16 (С731)
Verify Groth16 zero-knowledge proof prepared based on JWT token and extra salt password to prove that the user owns some OpenId account (Google, Facebook, Kakao accounts etc). Takes as input the proof, related public input Poseidon hash and index of verification key.
Note: public_inputs must be prepared using POSEIDON instruction.
POSEIDON (С732)
Calculate POSEIDON hash function. This hash function is designed for now especially for ZkLogin protocol needs. It takes as input all public ZkLogin data related to OpenId authentication (i.e. some public fields of JWT token and extra public data).
Note: There is: zkaddr = Poseidon(JWT.stable_id, JWT.iss, User salt password), where JWT.stable_id and User salt password are secrets. ephimeral_pub_key is a temporary key that will be used sign transactions (i.e. the related secret key) till Unix timestamp max_epoch (ephimeral_pub_key is embedded into JWT.nonce and JWT is a kind of TLS certificate for ephimeral_pub_key). modulus is RSA JWK public fresh modulus published by OpenId provider (the JWK is used to sign JWT tokens). iss_base_64, index_mod_4 is JWT public data describing OpenId provider. header_base_64 is JWT public data containing “kid” (key id) of JWK. link to the opcode
ZKHALO2VERIFYWITHVK (С74A)
Native Halo2 SHPLONK proof verification where the verifying key, public inputs, and proof are supplied as three separate stack cells. Designed for the Acki Nacki ↔ Ethereum bridge: each deployed bridge contract carries its own immutable VK, so one opcode covers every circuit anyone deploys to AN without growing per-circuit code in the node.
Assembly:
How to assemble public_inputs_cell
The payload is headerless: just N 32-byte little-endian Fr values concatenated. For each public input:
Encode the field element as a 32-byte little-endian byte string (
Fr::to_bytesin halo2-base;to_le_byteszero-padded to 32 B for values that fit in a u64).Concatenate the 32-byte chunks in the order the circuit's instance vector expects them.
Wrap the resulting
N × 32-byte buffer as the payload of a single TVMCell(useBUILDER/STZEROES/STIRpatterns or a host-side helper that emits a fresh cell).
Out-of-range bytes (i.e. a 32-byte chunk that ≥ BN254 scalar modulus) are always a structural FatalError — this catches caller bugs early instead of letting them masquerade as cryptographic rejects.
How to assemble proof_cell
Pass the proof bytes through unchanged. The producer side (acki-nacki-bridge/crates/bridge-prover-orchestrator) emits exactly the byte stream that Blake2bWrite::<_, _, Challenge255<_>>::finalize() produces. Just wrap it as the payload of a single TVM Cell.
How to assemble / deploy vk_cell
The VkBlob is long-lived — a TokenBridge contract typically stores it in c4 / persistent storage at deploy time and re-uses it on every verify call. The producer side at acki-nacki-bridge/crates/bridge-prover-orchestrator/src/halo2_tvm_bundle.rs builds it via:
A real bridge Circuit 1B (fallback BLS attestation verifier) VkBlob fixture is checked in at tvm-sdk/tvm_vm/halo2_test_data/fallback_vk_blob.bin (6308 B) together with sample public inputs (fallback_public_inputs.bin, 4 × 32 B) and a sample proof (fallback_proof.bin, 14784 B).
Notes:
The opcode invokes
halo2_proofs::plonk::verify_proof::<KZGCommitmentScheme<Bn256>, VerifierSHPLONK, Challenge255, Blake2bRead, SingleStrategy>directly. Nogosh-zk-snark-halo2-utilsruntime dependency.KZG SRS: only three points (
g[0],g2,s_g2) are embedded as constants inzk_halo2_utils.rs;ParamsKZG<Bn256>is reconstructed at runtime for anykviafrom_parts. No on-disk SRS blob is required for verification.Per-VK cache: bounded FIFO (8 entries) keyed by
vk_bytes.config.kis cross-checked againstvk.get_domain().k()on both the cold path (after VK::read) and the hot path (cache hit) as defence-in-depth against a malicious header that lies aboutk.DoS hardening:
VerifyingKey::read::<_, BaseCircuitBuilder<Fr>>can panic deep insidehalo2-baseon adversarialBaseCircuitParams(e.g.lookup_bits >= k). The handler wraps the read instd::panic::catch_unwindand converts the unwind into a structuralFatalError, so a single malicious blob cannot abort the executor.VkBlobparser rejects: bad magic, wrong version, wrong transcript-kind, length-prefix overrun, trailing garbage, and blobs over 1 MiB.
Producer reference: acki-nacki-bridge/docs/zkhalo2verifywithvk_reference.md. Design memo: docs/zkhalo2verifywithvk_design.md.
RUNWASM
Instruction allows arbitrary pre-compiled wasm code to be executed directly by the node.
You can find official documentation here and example project here link to the opcode
Last updated