Documentation
Docs11. KVM — Kortana Virtual Machine

11. KVM — Kortana Virtual Machine

The KVM is Kortana's custom-built engine, designed for mathematical provability and security.

11.1 Overview: Register Machine vs. Stack Machine

Unlike the EVM, which is a stack-based machine, the KVM is a register machine. This eliminates the entire class of vulnerabilities related to stack depth, DUP/SWAP juggling, and makes static analysis and formal verification highly tractable.

11.2 Module Format

  • Magic Prefix: 4B 56 4D 00 (KVM\0)
  • Version: Currently strictly 1.
  • Structure: Modules are strictly structured with explicit sections for headers, constants, and code.

11.3 Register Architecture

  • The KVM provides 32 × 256-bit registers.
  • r0 is hardwired to zero.

11.4 Instruction Set Architecture (ISA)

  • Fixed Width: Every instruction is strictly 4 bytes wide.
  • Opcodes: 75 specialized opcodes.
  • System Calls: Handled natively via ExternalCall, StaticCall, DelegateCall, and Create.

11.6 KVM Deployment

Unlike the EVM, KVM modules require no init code. Deployment verifies the module structure, stores the bytecode directly, and executes the constructor logic once. This prevents bugs where the returned runtime bytecode differs from the audited init code.

11.7 Limits

  • Max Instructions: 1,048,576 (4 MiB of code)
  • Max Module Size: 8 MiB
  • Max Constants: 16,384