synor/sdk/java
Gulshan Yadav e65ea40af2 feat: implement Privacy and Contract SDKs for all 12 languages (Phase 5)
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
2026-01-28 09:03:34 +05:30
..
src feat: implement Privacy and Contract SDKs for all 12 languages (Phase 5) 2026-01-28 09:03:34 +05:30
.gitignore feat(sdk): add consumer SDKs for Java, Kotlin, Swift, C, C++, C#, Ruby, and Rust 2026-01-11 17:46:22 +05:30
pom.xml Add Synor Storage and Wallet SDKs for Swift 2026-01-27 01:56:45 +05:30
README.md docs(sdk): add comprehensive documentation for all 12 SDKs 2026-01-11 18:05:03 +05:30

Synor Compute SDK for Java

Access distributed heterogeneous compute at 90% cost reduction.

Installation

Maven

<dependency>
    <groupId>io.synor</groupId>
    <artifactId>compute-sdk</artifactId>
    <version>0.1.0</version>
</dependency>

Gradle

implementation 'io.synor:compute-sdk:0.1.0'

Quick Start

import io.synor.compute.*;

public class Example {
    public static void main(String[] args) {
        SynorCompute client = new SynorCompute("your-api-key");

        // Matrix multiplication on GPU
        Tensor a = Tensor.random(512, 512);
        Tensor b = Tensor.random(512, 512);

        JobResult<Tensor> result = client.matmul(a, b)
            .precision(Precision.FP16)
            .processor(ProcessorType.GPU)
            .execute();

        if (result.isSuccess()) {
            System.out.println("Time: " + result.getExecutionTimeMs() + "ms");
            System.out.println("Cost: $" + result.getCost());
        }
    }
}

Tensor Operations

// Create tensors
Tensor zeros = Tensor.zeros(3, 3);
Tensor ones = Tensor.ones(2, 2);
Tensor random = Tensor.random(10, 10);
Tensor randn = Tensor.randn(100);
Tensor eye = Tensor.eye(3);

// From array
double[][] data = {{1, 2, 3}, {4, 5, 6}};
Tensor tensor = Tensor.fromArray(data);

// Operations
Tensor reshaped = tensor.reshape(3, 2);
Tensor transposed = tensor.transpose();

// Math
double mean = tensor.mean();
double sum = tensor.sum();
double std = tensor.std();

Builder Pattern API

// Matrix multiplication
JobResult<Tensor> result = client.matmul(a, b)
    .precision(Precision.FP16)
    .processor(ProcessorType.GPU)
    .priority(Priority.HIGH)
    .execute();

// 2D Convolution
JobResult<Tensor> conv = client.conv2d(input, kernel)
    .stride(1, 1)
    .padding(1, 1)
    .execute();

// Attention
JobResult<Tensor> attention = client.attention(query, key, value)
    .numHeads(8)
    .flash(true)
    .execute();

Async API with CompletableFuture

import java.util.concurrent.CompletableFuture;

CompletableFuture<JobResult<Tensor>> future = client.matmul(a, b)
    .precision(Precision.FP16)
    .executeAsync();

future.thenAccept(result -> {
    System.out.println("Completed: " + result.isSuccess());
});

LLM Inference

// Single response
InferenceResult response = client.inference("llama-3-70b", "Explain quantum computing")
    .maxTokens(512)
    .temperature(0.7)
    .execute();
System.out.println(response.getResult());

// Streaming with callback
client.inferenceStream("llama-3-70b", "Write a poem", chunk -> {
    System.out.print(chunk);
});

Configuration

SynorConfig config = SynorConfig.builder()
    .apiKey("your-api-key")
    .baseUrl("https://api.synor.io/compute/v1")
    .defaultProcessor(ProcessorType.GPU)
    .defaultPrecision(Precision.FP16)
    .timeout(Duration.ofSeconds(30))
    .debug(true)
    .build();

SynorCompute client = new SynorCompute(config);

Error Handling

try {
    JobResult<Tensor> result = client.matmul(a, b).execute();
} catch (SynorException e) {
    System.err.println("API Error: " + e.getMessage());
    System.err.println("Status: " + e.getStatusCode());
}

Enums

// Processor types
ProcessorType.CPU
ProcessorType.GPU
ProcessorType.TPU
ProcessorType.NPU
ProcessorType.LPU
ProcessorType.FPGA
ProcessorType.AUTO

// Precision
Precision.FP64
Precision.FP32
Precision.FP16
Precision.BF16
Precision.INT8
Precision.INT4

// Job status
JobStatus.PENDING
JobStatus.RUNNING
JobStatus.COMPLETED
JobStatus.FAILED

Requirements

  • Java 11 or higher
  • Gson for JSON serialization
  • OkHttp for HTTP client

Testing

mvn test
# or
./gradlew test

License

MIT