DEVELOPER REFERENCE

API Reference

Complete technical specifications for the Morpheus smart contracts and the Enclave Javascript SDK.

1. Smart Contract Interface (Neo N3 C#)

The active on-chain interface is the Neo N3 C# call pattern below. Neo X reference interfaces are intentionally omitted from the public docs because they are not part of the current supported path.

Oracle Call Pattern
// Neo N3 Mainnet Oracle: 0x017520f068fd602082fe5572596185e62a4ad991

string payloadJson = "{"symbol":"TWELVEDATA:NEO-USD","json_path":"price","target_chain":"neo_n3"}";

Contract.Call(
    MorpheusOracleHash,
    "request",
    CallFlags.All,
    "privacy_oracle",
    (ByteString)payloadJson,
    Runtime.ExecutingScriptHash,
    "onOracleResult"
);

To interact with the Morpheus Oracle on Neo N3 Mainnet, use Contract.Call against 0x017520f068fd602082fe5572596185e62a4ad991 or NeoNS oracle.morpheus.neo.

2. Enclave SDK (Javascript)

NeoDID now also exposes a W3C DID resolution route for public service discovery and subject namespaces:

GET /api/neodid/resolve
GET /api/neodid/resolve?did=did:morpheus:neo_n3:service:neodid
Accept: application/ld+json;profile="https://w3id.org/did-resolution"

GET /api/neodid/resolve?did=did:morpheus:neo_n3:vault:6d0656f6dd91469db1c90cc1e574380613f43738&format=document
Accept: application/did+ld+json

The resolver exposes the public service DID document, TEE verifier JWK, registry anchors, and subject namespaces without leaking provider UIDs or nullifiers.

3. Enclave SDK (Javascript)

When using built-in compute, Morpheus exposes a fixed catalog of functions. Custom JS compute receives input and helpers; Oracle custom JS receives data, context, and helpers.

hash.sha256Hash

Hashes any JSON-serializable payload with SHA-256.

// PARAMETERS
input: any
// EXAMPLE
const digest = await morpheus.hash.sha256({ data: '...' });
hash.keccak256Hash

Hashes any JSON-serializable payload with Keccak-256.

// PARAMETERS
input: any
// EXAMPLE
const digest = await morpheus.hash.keccak256({ data: '...' });
crypto.rsa_verifyCrypto

Verifies an RSA-SHA256 signature (computationally efficient in TEE).

// PARAMETERS
public_key: string, signature: string, payload: string
// EXAMPLE
const isValid = await morpheus.crypto.rsa_verify(input);
math.modexpMath

Performs big integer modular exponentiation.

// PARAMETERS
base: string, exponent: string, modulus: string
// EXAMPLE
const result = await morpheus.math.modexp({ base: '2', exponent: '10', modulus: '100' });
math.polynomialMath

Evaluates a polynomial of arbitrary degree.

// PARAMETERS
coefficients: string[], x: string, modulus?: string
// EXAMPLE
const y = await morpheus.math.polynomial({ coefficients: ['1', '0', '1'], x: '2' });
matrix.multiplyLinear Algebra

Multiplies two dense matrices.

// PARAMETERS
left: number[][], right: number[][]
// EXAMPLE
const matrix = await morpheus.matrix.multiply({ left: [[1,2]], right: [[3],[4]] });
vector.cosine_similarityLinear Algebra

Computes cosine similarity between two vectors.

// PARAMETERS
left: number[], right: number[]
// EXAMPLE
const sim = await morpheus.vector.cosine_similarity({ left: [1,0], right: [0,1] });
merkle.rootMerkle

Builds a SHA-256 Merkle root from a list of leaves.

// PARAMETERS
leaves: string[]
// EXAMPLE
const root = await morpheus.merkle.root({ leaves: ['a', 'b', 'c'] });
zkp.public_signal_hashZKP

Computes a deterministic digest over public signals.

// PARAMETERS
circuit_id: string, signals: any[]
// EXAMPLE
const hash = await morpheus.zkp.public_signal_hash({ circuit_id: '...', signals: [] });
zkp.proof_digestZKP

Computes a deterministic digest over a proof object and optional verifying key.

// PARAMETERS
proof: any, verifying_key?: any
// EXAMPLE
const digest = await morpheus.zkp.proof_digest({ proof, verifying_key });
zkp.witness_digestZKP

Computes a digest over witness material before proving.

// PARAMETERS
witness: any, circuit_id?: string
// EXAMPLE
const digest = await morpheus.zkp.witness_digest({ witness, circuit_id: 'demo' });
zkp.groth16.verifyZKP

Verifies a Groth16 proof against a verifying key and public signals.

// PARAMETERS
verifying_key: any, public_signals: any[], proof: any
// EXAMPLE
const verdict = await morpheus.zkp.groth16.verify({ verifying_key, public_signals, proof });
zkp.groth16.prove.planZKP

Returns a planning estimate for Groth16 proving workloads.

// PARAMETERS
constraints: number, witness_count: number
// EXAMPLE
const plan = await morpheus.zkp.groth16.prove.plan({ constraints: 120000, witness_count: 4096 });
zkp.plonk.prove.planZKP

Returns a planning estimate for PLONK proving workloads.

// PARAMETERS
gates: number
// EXAMPLE
const plan = await morpheus.zkp.plonk.prove.plan({ gates: 90000 });
zkp.zerc20.single_withdraw.verifyZKP

Checks zERC20 single-withdraw public inputs and can optionally run Groth16 verification.

// PARAMETERS
public_inputs: object, verifying_key?: any, proof?: any, skip_proof_verification?: boolean
// EXAMPLE
const verdict = await morpheus.zkp.zerc20.single_withdraw.verify({ public_inputs, proof, verifying_key });
fhe.batch_planFHE

Builds a ciphertext batching plan.

// PARAMETERS
slot_count: number, ciphertext_count: number
// EXAMPLE
const plan = await morpheus.fhe.batch_plan({ slot_count: 4096, ciphertext_count: 8 });
fhe.noise_budget_estimateFHE

Estimates a rough FHE noise budget.

// PARAMETERS
multiplicative_depth: number, scale_bits: number, modulus_bits: number
// EXAMPLE
const estimate = await morpheus.fhe.noise_budget_estimate({ multiplicative_depth: 4, scale_bits: 40, modulus_bits: 218 });
fhe.rotation_planFHE

Returns a rotation and key-switch planning summary.

// PARAMETERS
indices: number[]
// EXAMPLE
const plan = await morpheus.fhe.rotation_plan({ indices: [1, 3, -2] });
privacy.maskPrivacy

Masks a sensitive string, leaving edges visible.

// PARAMETERS
value: string, unmasked_left: number, unmasked_right: number
// EXAMPLE
const masked = await morpheus.privacy.mask({ value: 'secret_key', unmasked_left: 2, unmasked_right: 2 });
privacy.add_noisePrivacy

Adds simulated Laplace noise for differential privacy.

// PARAMETERS
value: number, scale: number
// EXAMPLE
const noisy = await morpheus.privacy.add_noise({ value: 100, scale: 1.0 });
CURRENT DESIGNUPDATED FOR DUAL-CVM ARCHITECTURE