EXTENDED SERVICE

Enclave Compute

Morpheus Enclave Compute allows developers to execute complex, non-deterministic, or proprietary logic inside a Trusted Execution Environment. The network supports multiple runtimes, ensuring that inputs and intermediate states are never visible to the public blockchain.

Supported Runtimes

Javascript (QuickJS)

High-level scripting for data aggregation, custom API parsing, and business logic.

WebAssembly (WASM)

Performance-critical tasks like ZKP witness generation or complex mathematical models.

Built-in Capabilities

The TEE environment provides a global morpheus object with optimized cryptographic and utility functions:

  • Hashing: SHA-256 and Keccak-256 for integrity checks.
  • Verification: High-performance RSA signature verification.
  • Planning: ZKP and FHE planning helpers for witness, proof, batching, and rotation workflows.
  • Linear Algebra: Optimized matrix and vector operations.
  • Privacy: Masking and noise helpers for privacy-preserving post-processing.

Handling Confidential Arguments

When you dispatch a compute job, the encrypted blob you sealed locally is decrypted by the TEE core and merged into the final compute payload. For custom JS compute, your entry point receives input and helpers, not a live network client.

javascriptCustom Compute Script
function process(input, helpers) {
    const values = Array.isArray(input.values) ? input.values : [];
    const total = values.reduce((sum, value) => sum + Number(value || 0), 0);
    return {
        total,
        count: values.length,
        generated_at: helpers.getCurrentTimestamp(),
    };
}

Contract-Backed Script Registry

If an inline script would make the request payload too large, you can store the script body in a Neo N3 contract getter and send only a compact script_ref. Morpheus resolves the script on-chain, then applies the same sandbox, timeout, and size checks before execution.

jsonscript_ref Payload
{
  "mode": "script",
  "script_ref": {
    "contract_hash": "0x1111111111111111111111111111111111111111",
    "method": "getScript",
    "script_name": "sum"
  },
  "entry_point": "process",
  "input": { "a": 2, "b": 3 },
  "target_chain": "neo_n3"
}

Security Model

Compute tasks are strictly time-bounded (default 30s timeout) and executed in a stateless enclave instance. Any data required for the next execution cycle must be stored back on the blockchain via the callback mechanism.

The current runtime also enforces input-size, result-size, and upstream body-size ceilings to reduce DoS risk from oversized user payloads or oversized fetch/script outputs.

Untrusted Scripts

Direct JS execution requires MORPHEUS_ENABLE_UNTRUSTED_SCRIPTS=true. Production deployments should prefer built-in functions or WASM when stronger isolation and tighter runtime control are required.

CURRENT DESIGNUPDATED FOR DUAL-CVM ARCHITECTURE