Privacy SDK features: - Confidential transactions with Pedersen commitments - Bulletproof range proofs for value validation - Ring signatures for anonymous signing with key images - Stealth addresses for unlinkable payments - Blinding factor generation and value operations Contract SDK features: - Smart contract deployment (standard and CREATE2) - Call (view/pure) and Send (state-changing) operations - Event log filtering, subscription, and decoding - ABI encoding/decoding utilities - Gas estimation and contract verification - Multicall for batched operations - Storage slot reading Languages implemented: - JavaScript/TypeScript - Python (async with httpx) - Go - Rust (async with reqwest/tokio) - Java (async with OkHttp) - Kotlin (coroutines with Ktor) - Swift (async/await with URLSession) - Flutter/Dart - C (header-only interface) - C++ (header-only with std::future) - C#/.NET (async with HttpClient) - Ruby (Faraday HTTP client) All SDKs follow consistent patterns: - Configuration with API key, endpoint, timeout, retries - Custom exception types with error codes - Retry logic with exponential backoff - Health check endpoints - Closed state management |
||
|---|---|---|
| .. | ||
| bridge | ||
| contract | ||
| database | ||
| economics | ||
| governance | ||
| hosting | ||
| mining | ||
| privacy | ||
| rpc | ||
| storage | ||
| wallet | ||
| go.mod | ||
| README.md | ||
| synor.go | ||
| synor_test.go | ||
Synor Compute SDK for Go
Access distributed heterogeneous compute at 90% cost reduction.
Installation
go get github.com/synor/compute-sdk-go
Quick Start
package main
import (
"context"
"fmt"
"log"
synor "github.com/synor/compute-sdk-go"
)
func main() {
client := synor.NewClient("your-api-key")
// Create tensors
a := synor.NewTensor(data, []int{512, 512}, synor.FP32)
b := synor.Zeros([]int{512, 512}, synor.FP32)
// Matrix multiplication
ctx := context.Background()
result, err := client.MatMul(ctx, a, b,
synor.WithPrecision(synor.FP16),
synor.WithProcessor(synor.GPU),
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Execution time: %.2fms\n", result.Metrics.ExecutionTimeMs)
}
Configuration
config := synor.Config{
APIKey: "your-api-key",
Endpoint: "https://api.synor.io/compute/v1",
Strategy: synor.Balanced,
Precision: synor.FP16,
Timeout: 30 * time.Second,
}
client := synor.NewClientWithConfig(config)
Tensor Operations
// Create tensors
zeros := synor.Zeros([]int{3, 3}, synor.FP32)
ones := synor.Ones([]int{2, 2}, synor.FP32)
// From slice
data := []float32{1, 2, 3, 4, 5, 6}
tensor := synor.NewTensor(data, []int{2, 3}, synor.FP32)
// Serialize for API
serialized := tensor.Serialize()
Matrix Operations
// Matrix multiplication
result, err := client.MatMul(ctx, a, b,
synor.WithPrecision(synor.FP16),
synor.WithProcessor(synor.GPU),
synor.WithStrategy(synor.Speed),
)
// 2D Convolution
conv, err := client.Conv2D(ctx, input, kernel,
synor.WithStride(1, 1),
synor.WithPadding(1, 1),
)
// Attention
attention, err := client.Attention(ctx, query, key, value,
synor.WithNumHeads(8),
synor.WithFlash(true),
)
LLM Inference
// Single response
response, err := client.Inference(ctx, "llama-3-70b", "Explain quantum computing",
synor.WithMaxTokens(512),
synor.WithTemperature(0.7),
)
fmt.Println(response.Result)
// Streaming (using channel)
stream, err := client.InferenceStream(ctx, "llama-3-70b", "Write a poem")
for chunk := range stream {
fmt.Print(chunk)
}
Job Management
// Submit async job
job, err := client.SubmitJob(ctx, "matmul", map[string]interface{}{
"a": a.Serialize(),
"b": b.Serialize(),
})
// Get status
status, err := client.GetJobStatus(ctx, job.ID)
// Cancel
err = client.CancelJob(ctx, job.ID)
Error Handling
result, err := client.MatMul(ctx, a, b)
if err != nil {
if synorErr, ok := err.(*synor.SynorError); ok {
fmt.Printf("API Error: %s (status: %d)\n",
synorErr.Message, synorErr.StatusCode)
}
}
Processor Types
synor.CPU // General-purpose CPU
synor.GPU // NVIDIA/AMD GPU
synor.TPU // Google TPU
synor.NPU // Neural Processing Unit
synor.LPU // Language Processing Unit
synor.FPGA // Field-Programmable Gate Array
synor.WASM // WebAssembly runtime
synor.WebGPU // Browser GPU
Precision Levels
synor.FP64 // 64-bit float
synor.FP32 // 32-bit float (default)
synor.FP16 // 16-bit float
synor.BF16 // Brain float 16
synor.INT8 // 8-bit integer
synor.INT4 // 4-bit integer
Testing
go test ./...
License
MIT