What is Leo?
Leo is a statically-typed programming language built for writing private applications on the Aleo blockchain. It compiles to Aleo instructions and enables developers to write zero-knowledge proofs with a familiar, high-level syntax.Design Philosophy
Leo is designed with several core principles:Zero-Knowledge First
Leo is purpose-built for zero-knowledge applications. Every Leo program compiles to zero-knowledge proofs, allowing you to prove computation without revealing private data.Type Safety
Leo is statically typed with strong type checking. All types are checked at compile time, preventing runtime errors and ensuring program correctness.Privacy by Default
Leo distinguishes between private and public data using visibility modifiers. Data is private unless explicitly marked as public.On-Chain and Off-Chain Computation
Leo separates off-chain (private) computation from on-chain (public) state changes using the finalize pattern.Language Features
Primitive Types
Leo supports a rich set of primitive types:- Integers:
u8,u16,u32,u64,u128,i8,i16,i32,i64,i128 - Field Elements:
field(for cryptographic operations) - Group Elements:
group(elliptic curve points) - Scalars:
scalar(for cryptographic operations) - Addresses:
address(Aleo account addresses) - Booleans:
bool - Signatures:
signature(cryptographic signatures)
Composite Types
Leo supports structured data through records and structs:On-Chain Storage
Leo provides mappings for persistent on-chain storage:Control Flow
Leo supports standard control flow with conditionals and loops:Compilation Model
Leo programs follow a compilation pipeline:- Source Code - Written in
.leofiles - Lexer - Tokenizes source code
- Parser - Builds a parse tree using Rowan
- AST - Converts to typed Abstract Syntax Tree
- Compiler Passes - Type checking, optimization, and transformation
- Aleo Bytecode - Output as Aleo instructions
Program Structure
Every Leo program must declare a program scope:Next Steps
Programs
Learn about program structure and organization
Data Types
Explore Leo’s type system
Functions
Write functions and define interfaces
Records
Create private records for ownership