Astree Documentation

Welcome to Astree, the next-generation Zero-Knowledge Super dApps Engine built on Solana. Build trustless, private, and lightning-fast decentralized applications using ZK circuits.

Privacy First

Zero-knowledge proofs ensure complete privacy

Lightning Fast

Optimized circuits for maximum performance

Solana Native

Built for Solana's high-performance blockchain

Quick Start

Get up and running with Astree in less than 5 minutes.

1

Install Astree CLI

npm install -g @astree/cli
2

Create New Project

astree init my-dappcd my-dapp
3

Run Development Server

npm run dev

Installation

Prerequisites

  • Node.js 18+ or Bun 1.0+
  • Solana CLI tools installed
  • A Solana wallet (Phantom, Solflare, etc.)

Install via NPM

npm install @astree/sdk @astree/circuits

Install via Yarn

yarn add @astree/sdk @astree/circuits

Your First Circuit

Learn how to create your first zero-knowledge circuit with Astree.

Basic Circuit Example

import { Circuit, Field } from '@astree/circuits';

// Define a simple age verification circuit
const ageVerificationCircuit = new Circuit({
  name: 'AgeVerification',
  inputs: {
    age: Field,
    minimumAge: Field,
  },
  outputs: {
    isOldEnough: Field,
  },
  logic: ({ age, minimumAge }) => {
    return {
      isOldEnough: age.gte(minimumAge)
    };
  }
});

// Generate proof
const proof = await ageVerificationCircuit.prove({
  age: 25,
  minimumAge: 18,
});

// Verify proof
const isValid = await ageVerificationCircuit.verify(proof);
console.log('Proof valid:', isValid);

Zero-Knowledge Proofs

Understanding the core cryptographic primitive that powers Astree's privacy features.

What are Zero-Knowledge Proofs?

Zero-knowledge proofs (ZKPs) allow one party to prove to another that a statement is true without revealing any information beyond the validity of the statement itself. In Astree, this enables private computation and verification on-chain.

  • Completeness: If the statement is true, an honest prover can convince an honest verifier
  • Soundness: If the statement is false, no cheating prover can convince the verifier
  • Zero-Knowledge: The proof reveals nothing except the truth of the statement

Astree's ZK Implementation

Astree uses state-of-the-art PLONK-based proving systems optimized for Solana's architecture:

  • Optimized for low verification costs on Solana
  • Fast proof generation using GPU acceleration
  • Recursive proofs for scalability
  • Batched verification for efficiency

Circuit Architecture

Deep dive into how Astree circuits are structured and optimized.

Circuit Components

Inputs

Private and public inputs that define the computation

Constraints

Mathematical relations that must hold true

Witnesses

Intermediate values computed during execution

Outputs

Public results of the circuit computation

Circuit Example

const transferCircuit = new Circuit({
  name: 'PrivateTransfer',
  inputs: {
    // Private inputs (hidden from verifier)
    senderBalance: Field,
    receiverBalance: Field,
    amount: Field,
    
    // Public inputs (visible to verifier)
    senderCommitment: Field,
    receiverCommitment: Field,
  },
  outputs: {
    newSenderCommitment: Field,
    newReceiverCommitment: Field,
    isValid: Field,
  },
  logic: ({ senderBalance, receiverBalance, amount }) => {
    // Constraint: sender has sufficient balance
    const hasSufficientBalance = senderBalance.gte(amount);
    
    // Compute new balances
    const newSenderBalance = senderBalance.sub(amount);
    const newReceiverBalance = receiverBalance.add(amount);
    
    return {
      newSenderCommitment: hash(newSenderBalance),
      newReceiverCommitment: hash(newReceiverBalance),
      isValid: hasSufficientBalance,
    };
  }
});

Solana Integration

Learn how Astree seamlessly integrates with Solana's high-performance blockchain for on-chain ZK verification.

On-Chain Verification

Astree provides optimized Solana programs for verifying ZK proofs on-chain with minimal compute units.

import { AstreeClient } from '@astree/sdk';
import { Connection, PublicKey } from '@solana/web3.js';

const connection = new Connection('https://api.mainnet-beta.solana.com');
const astreeClient = new AstreeClient(connection);

// Submit proof for verification
const tx = await astreeClient.verifyProof({
  circuit: ageVerificationCircuit,
  proof: proof,
  programId: new PublicKey('Astree1111...'),
});

console.log('Proof verified on-chain:', tx);

Account Structure

Astree uses dedicated Solana accounts to store circuit definitions and verification keys:

  • Circuit Account: Stores circuit definition and metadata
  • Verification Key Account: Contains cryptographic keys for proof verification
  • Proof Account: Temporary storage for proof data during verification

Privacy Model

Understanding Astree's privacy guarantees and security model for building confidential dApps.

Privacy Guarantees

  • Input Privacy:

    Private inputs are never revealed on-chain or to any party

  • Computation Privacy:

    Intermediate computation steps remain confidential

  • State Privacy:

    Application state can be kept private using commitments

Use Cases

Private DeFi

Trade and transact without revealing balances or positions

Identity Verification

Prove credentials without revealing personal data

Private Voting

Cast votes that are verifiable but anonymous

Compliance

Meet regulatory requirements while preserving privacy

Circuit API

Complete API reference for creating and managing ZK circuits in Astree.

Circuit Class

class Circuit {
  constructor(config: CircuitConfig)
  prove(inputs: CircuitInputs): Promise<Proof>
  verify(proof: Proof): Promise<boolean>
  compile(): Promise<CompiledCircuit>
  deploy(connection: Connection): Promise<PublicKey>
}

The main class for defining and working with ZK circuits in Astree.

Field Types

import { Field, Bool, UInt64, Struct } from '@astree/circuits';

// Basic field element
const age = Field(25);

// Boolean
const isAdult = Bool(true);

// Unsigned 64-bit integer
const amount = UInt64(1000);

// Custom struct
class User extends Struct({
  id: Field,
  balance: UInt64,
  isActive: Bool,
}) {}

Proof Generation

Learn how to efficiently generate zero-knowledge proofs for your circuits.

Basic Proof Generation

// Generate a proof
const proof = await circuit.prove({
  privateInputs: {
    age: 25,
    secret: "my-secret-key"
  },
  publicInputs: {
    minimumAge: 18
  }
});

// Proof contains:
// - Proof data (serialized for on-chain verification)
// - Public outputs
// - Metadata
console.log(proof.data); // Uint8Array
console.log(proof.publicOutputs); // { isOldEnough: true }

Performance Optimization

  • Use GPU acceleration for faster proof generation
  • Cache compiled circuits to avoid recompilation
  • Use web workers for non-blocking proof generation in browsers

Verification

Verify zero-knowledge proofs both off-chain and on Solana blockchain.

State Management

Manage private state and commitments in your ZK applications.

Custom Circuits

Build advanced custom circuits for specialized use cases.

Optimization

Optimize your circuits for better performance and lower costs.

Testing

Test your ZK circuits and ensure correctness before deployment.

Deployment

Deploy your ZK dApps to Solana mainnet and devnet.

Examples

Explore real-world examples of Astree applications.

Best Practices

Follow recommended patterns for building secure ZK applications.

Circuit Design

  • Keep circuits small and focused on specific functionality
  • Minimize the number of constraints for faster proving
  • Use built-in optimized operations when possible

Security

  • Never expose private inputs in logs or error messages
  • Validate all public inputs before proof generation
  • Use secure random number generation for nonces and salts

Troubleshooting

Common issues and solutions when working with Astree.

CLI Reference

Complete reference for Astree command-line interface.

astree init

Initialize a new Astree project

astree init [project-name] [--template <template>]

astree compile

Compile circuits to optimized format

astree compile [circuit-file] [--output <dir>]

astree deploy

Deploy circuit to Solana blockchain

astree deploy [circuit-file] [--network <mainnet|devnet>]

Need Help?

Join our community and get support from the Astree team and developers