The program
We’ll create a simple program that performs basic arithmetic with private values:Complete example
Step by step
1
Write the program
- Declares inputs with types and visibility (
.privateor.public) - Performs operations using registers (
r0,r1, etc.) - Returns outputs with types and visibility
2
Parse the program
Program object. This validates the syntax and generates the program ID.3
Deploy the program
4
Execute functions
Program features
Data types
Aleo supports these primitive types:- Integers:
u8,u16,u32,u64,u128,i8,i16,i32,i64,i128 - Field elements:
field,group,scalar - Boolean:
boolean - Address:
address - Signature:
signature
Visibility modifiers
.private- Hidden from public view, proven in zero-knowledge.public- Visible on the blockchain.record- Private state with ownership
Operations
Common operations available:- Arithmetic:
add,sub,mul,div,rem - Bitwise:
and,or,xor,shl,shr - Comparison:
lt,lte,gt,gte - Logical:
and,or,not - Cryptographic:
hash.bhp256,commit.bhp256,sign.verify
Advanced example: Working with structs
All computation is performed privately. The inputs, outputs, and intermediate values are hidden using zero-knowledge proofs.
Next steps
Proof verification
Learn about zero-knowledge proof generation
Creating programs
Deep dive into Aleo program development