Documentation
¶
Overview ¶
Package neocompute provides API routes for the neocompute service.
Package neocompute provides core logic for the neocompute service.
Package neocompute provides HTTP handlers for the neocompute service.
Package neocompute provides neocompute service.
The NeoCompute service allows users to execute custom JavaScript inside the TEE enclave with access to their secrets. This enables: - Privacy-preserving computation on sensitive data - Secure execution of business logic with verifiable results - Integration with external APIs using protected credentials
Architecture: - Script execution via goja JavaScript runtime - Secure secret injection from user's secret store - Signed execution results for verification - Gas metering and resource limits
Package neocompute provides types for the neocompute service.
Index ¶
Constants ¶
const ( ServiceID = "neocompute" ServiceName = "NeoCompute Service" Version = "1.0.0" // Default execution timeout DefaultTimeout = 30 * time.Second // Max script size (100KB) MaxScriptSize = 100 * 1024 // Gas accounting is approximate and based on the submitted script size. // This value is intended for billing/rate limiting and is not tied to VM opcodes. GasPerScriptByte = 10 // Resource limits for security MaxInputSize = 1 * 1024 * 1024 // 1MB max input size MaxOutputSize = 1 * 1024 * 1024 // 1MB max output size MaxSecretRefs = 10 // Max secrets per execution MaxLogEntries = 100 // Max console.log entries MaxLogEntrySize = 4096 // Max size per log entry MaxConcurrentJobs = 5 // Max concurrent jobs per user // Result retention defaults DefaultResultTTL = 24 * time.Hour )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Marble *marble.Marble
DB database.RepositoryInterface
// SecretProvider optionally injects user secrets into the JS runtime.
SecretProvider secrets.Provider
// Optional overrides, primarily used for testing.
ResultTTL time.Duration
CleanupInterval time.Duration
}
Config holds service configuration.
type ExecuteRequest ¶
type ExecuteRequest struct {
Script string `json:"script"`
EntryPoint string `json:"entry_point,omitempty"`
Input map[string]interface{} `json:"input,omitempty"`
SecretRefs []string `json:"secret_refs,omitempty"`
Timeout int `json:"timeout,omitempty"`
AppID string `json:"app_id,omitempty"`
ScriptName string `json:"script_name,omitempty"`
}
ExecuteRequest represents a script execution request.
type ExecuteResponse ¶
type ExecuteResponse struct {
JobID string `json:"job_id"`
Status string `json:"status"`
Output map[string]interface{} `json:"output,omitempty"`
Logs []string `json:"logs,omitempty"`
Error string `json:"error,omitempty"`
GasUsed int64 `json:"gas_used"`
StartedAt time.Time `json:"started_at"`
Duration string `json:"duration,omitempty"`
// TEE attestation fields - prove result came from enclave
EncryptedOutput string `json:"encrypted_output,omitempty"` // AES-GCM encrypted output (base64)
OutputHash string `json:"output_hash,omitempty"` // SHA256 hash of plaintext output
Signature string `json:"signature,omitempty"` // HMAC-SHA256 signature of output hash
}
ExecuteResponse represents a script execution response.
type Service ¶
type Service struct {
*commonservice.BaseService
// contains filtered or unexported fields
}
Service implements the NeoCompute service.
func (*Service) Execute ¶
func (s *Service) Execute(ctx context.Context, userID string, req *ExecuteRequest) (*ExecuteResponse, error)
Execute runs code inside the TEE enclave and stores the result for later retrieval.