Skip to main content

Overview

Leo provides a rich set of built-in types designed for zero-knowledge circuit development. All types have explicit sizes and well-defined semantics.

Integer Types

Leo supports both unsigned and signed integer types.

Unsigned Integers

Signed Integers

Integer Literals

Integer literals must include a type suffix (e.g., 42u8, 100i32). Leo does not perform implicit type coercion.

Field Type

The field type represents a finite field element from the BLS12-377 scalar field.
Properties:
  • Size: ~253 bits
  • Modulus: 8444461749428370424248824938781546531375899335154063827935233455917409239041
  • Arithmetic is performed modulo the field prime
Field arithmetic wraps around the modulus. Values outside the range [0, p-1] are automatically reduced.

Group Type

The group type represents a point on an elliptic curve.
Properties:
  • Represents points on the Edwards BLS12 curve
  • Supports group operations (addition, scalar multiplication)
  • Used in cryptographic operations

Scalar Type

The scalar type represents a scalar value used for elliptic curve operations.
Properties:
  • Used with group operations
  • Scalar multiplication: scalar * group

Boolean Type

The bool type represents truth values.
Operations:
  • Logical: && (and), || (or), ! (not)
  • Comparison: ==, !=
  • Conditional: if condition { ... } else { ... }

Address Type

The address type represents an Aleo account address.
Properties:
  • 63-character string starting with aleo1
  • Represents a public key hash
  • Used for ownership and authorization

String Type

The string type represents text data.
Strings in Leo are primarily used for debugging and are not stored on-chain.

Signature Type

The signature type represents a cryptographic signature.

Composite Types

Struct

User-defined composite type with named fields.

Record

Private data structure that always includes an owner field.
Key Features:
  • Records are private by default
  • Always include an owner: address field
  • Used for private state management

Tuple

Anonymous composite type with ordered elements.

Array

Fixed-size collection of elements of the same type.
Properties:
  • Fixed size known at compile time
  • Zero-indexed access: numbers[0]
  • All elements must be the same type

Vector

Dynamic-size collection (compile-time size determined).

Mapping Type

On-chain key-value storage (only in program scope).
Properties:
  • Declared at program level
  • Publicly visible on-chain
  • Accessed in finalizer functions
  • Key and value types must be explicitly specified

Optional Type

Represents a value that may or may not be present.

Future Type

Represents deferred computation in finalizers.
Properties:
  • Used with the Final type
  • Represents on-chain computation that executes during finalization
  • Cannot be manipulated directly in Leo code

Unit Type

The unit type () represents the absence of a value.

Type Casting

Leo supports explicit type casting between compatible types.
Casting from a larger type to a smaller type may result in truncation. Always ensure the value fits in the target type.

Type Inference

While Leo requires type annotations for function signatures, local variables can use type inference:

Special Types

self.caller

Built-in value representing the caller’s address:

block.height

Built-in value representing the current block height (in finalizers):

Grammar Reference

Complete syntax specification

Examples

See types in action