Skip to main content

Aleo Opcodes Reference

The following is a list of opcodes supported by the Aleo Virtual Machine (AVM).

NameDescription
absAbsolute value operation
abs.wWrapping absolute value operation
addAddition operation
add.wWrapping addition operation
andAND operation
assert.eqAssert equality
assert.neqAssert non-equality
commit.bhp256256-bit input BHP commitment
commit.bhp512512-bit input BHP commitment
commit.bhp768768-bit input BHP commitment
commit.bhp10241024-bit input BHP commitment
commit.ped6464-bit input Pedersen commitment
commit.ped128128-bit input Pedersen commitment
divDivision operation
div.wWrapping division operation
doubleDouble operation
gtGreater than comparison
gteGreater than or equal to comparison
hash.bhp256256-bit input BHP hash
hash.bhp512512-bit input BHP hash
hash.bhp768768-bit input BHP hash
hash.bhp10241024-bit input BHP hash
hash.ped6464-bit input Pedersen hash
hash.ped128128-bit input Pedersen hash
hash.psd2Poseidon hash with input rate 2
hash.psd4Poseidon hash with input rate 4
hash.psd8Poseidon hash with input rate 8
invMultiplicative inverse operation
is.eqEquality comparison
is.neqNot equal comparison
ltLess than comparison
lteLess than or equal to comparison
modArithmetic modulo operation
mulMultiplication operation
mul.wWrapping multiplication operation
nandBoolean NAND operation
negAdditive inverse operation
norBoolean NOR operation
notNOT operation
orOR Operation
powExponentiation operation
pow.wWrapping exponentiation operation
remRemainder operation
rem.wWrapping remainder operation
shlShift left operation
shl.wWrapping shift left operation
shrShift right operation
shr.wWrapping shift right operation
sqrtSquare root operation
squareSquare operation
subSubtraction operation
sub.wWrapping subtraction operation
ternaryTernary select operation
xorXOR operation

Specification

The following is the specification for each opcode in the Aleo Virtual Machine (AVM).

abs

Back to Top

Description

Computes the absolute value of the input, checking for overflow, storing the result in the destination register.

For integer types, a constraint is added to check for underflow. For cases where wrapping semantics are needed, see the abs.w instruction. This underflow happens when the input is the minimum value of a signed integer type. For example, abs -128i8 would result in underflow, since 128 cannot be represented as an i8.

Supported Types

InputDestination
I8I8
I16I16
I32I32
I64I64
I128I128
<!--U8
<!--U16
<!--U32
<!--U64
<!--U128

abs.w

Back to Top

Description

Compute the absolute value of the input, wrapping around at the boundary of the type, and storing the result in the destination register.

Supported Types

InputDestination
I8I8
I16I16
I32I32
I64I64
I128I128
<!--U8
<!--U16
<!--U32
<!--U64
<!--U128

add

Back to Top

Description

Adds first with second, storing the outcome in destination.

For integer types, a constraint is added to check for overflow. For cases where wrapping semantics are needed for integer types, see the add.w instruction.

Supported Types

FirstSecondDestination
FieldFieldField
GroupGroupGroup
I8I8I8
I16I16I16
I32I32I32
I64I64I64
I128I128I128
U8U8U8
U16U16U16
U32U32U32
U64U64U64
U128U128U128
ScalarScalarScalar

add.w

Back to Top

Description

Adds first with second, wrapping around at the boundary of the type, and storing the outcome in destination.

Supported Types

FirstSecondDestination
I8I8I8
I16I16I16
I32I32I32
I64I64I64
I128I128I128
U8U8U8
U16U16U16
U32U32U32
U64U64U64
U128U128U128

and

Back to Top

Description

Performs an AND operation on integer (bitwise) or boolean first and second, storing the outcome in destination.

Supported Types

FirstSecondDestination
BooleanBooleanBoolean
I8I8I8
I16I16I16
I32I32I32
I64I64I64
I128I128I128
U8U8U8
U16U16U16
U32U32U32
U64U64U64
U128U128U128

assert.eq

Back to Top

Description

Checks whether first and second are equal, halting if they are not equal.

Supported Types

FirstSecond
AddressAddress
BooleanBoolean
FieldField
GroupGroup
I8I8
I16I16
I32I32
I64I64
I128I128
U8U8
U16U16
U32U32
U64U64
U128U128
ScalarScalar
InterfaceInterface
RecordRecord

assert.neq

Back to Top

Description

Checks whether first and second are not equal, halting if they are equal.

Supported Types

FirstSecond
AddressAddress
BooleanBoolean
FieldField
GroupGroup
I8I8
I16I16
I32I32
I64I64
I128I128
U8U8
U16U16
U32U32
U64U64
U128U128
ScalarScalar
InterfaceInterface
RecordRecord

commit.bhp256

Back to Top

Description

Computes a BHP commitment on inputs of 256-bit chunks in first, and some randomness in second, storing the commitment in destination. Randomness should always be a Scalar value, and the produced commitment will always be a Field value.

The instruction will halt if the given input is smaller than 129 bits.

Supported Types

FirstSecondDestination
AddressScalarField
BooleanScalarField
FieldScalarField
GroupScalarField
I8ScalarField
I16ScalarField
I32ScalarField
I64ScalarField
I128ScalarField
U8ScalarField
U16ScalarField
U32ScalarField
U64ScalarField
U128ScalarField
ScalarScalarField
StringScalarField
InterfaceScalarField

commit.bhp512

Back to Top

Description

Computes a BHP commitment on inputs of 512-bit chunks in first, and some randomness in second, storing the commitment in destination. Randomness should always be a Scalar value, and the produced commitment will always be a Field value.

The instruction will halt if the given input is smaller than 171 bits.

Supported Types

FirstSecondDestination
AddressScalarField
BooleanScalarField
FieldScalarField
GroupScalarField
I8ScalarField
I16ScalarField
I32ScalarField
I64ScalarField
I128ScalarField
U8ScalarField
U16ScalarField
U32ScalarField
U64ScalarField
U128ScalarField
ScalarScalarField
StringScalarField
InterfaceScalarField

commit.bhp768

Back to Top

Description

Computes a BHP commitment on inputs of 768-bit chunks in first, and some randomness in second, storing the commitment in destination. Randomness should always be a Scalar value, and the produced commitment will always be a Field value.

The instruction will halt if the given input is smaller than 129 bits.

Supported Types

FirstSecondDestination
AddressScalarField
BooleanScalarField
FieldScalarField
GroupScalarField
I8ScalarField
I16ScalarField
I32ScalarField
I64ScalarField
I128ScalarField
U8ScalarField
U16ScalarField
U32ScalarField
U64ScalarField
U128ScalarField
ScalarScalarField
StringScalarField
InterfaceScalarField

commit.bhp1024

Back to Top

Description

Computes a BHP commitment on inputs of 1024-bit chunks in first, and some randomness in second, storing the commitment in destination. Randomness should always be a Scalar value, and the produced commitment will always be a Field value.

The instruction will halt if the given input is smaller than 171 bits.

Supported Types

FirstSecondDestination
AddressScalarField
BooleanScalarField
FieldScalarField
GroupScalarField
I8ScalarField
I16ScalarField
I32ScalarField
I64ScalarField
I128ScalarField
U8ScalarField
U16ScalarField
U32ScalarField
U64ScalarField
U128ScalarField
ScalarScalarField
StringScalarField
InterfaceScalarField

commit.ped64

Back to Top

Description

Computes a Pedersen commitment up to a 64-bit input in first, and some randomness in second, storing the commitment in destination. Randomness should always be a Scalar value, and the produced commitment will always be a Group value.

The instruction will halt if the given String or Interface value exceeds the 64-bit limit.

Supported Types

FirstSecondDestination
BooleanScalarGroup
I8ScalarGroup
I16ScalarGroup
I32ScalarGroup
I64ScalarGroup
U8ScalarGroup
U16ScalarGroup
U32ScalarGroup
U64ScalarGroup
StringScalarGroup
InterfaceScalarGroup

commit.ped128

Back to Top

Description

Computes a Pedersen commitment up to a 128-bit input in first, and some randomness in second, storing the commitment in destination. Randomness should always be a Scalar value, and the produced commitment will always be a Group value.

The instruction will halt if the given String or Interface value exceeds the 128-bit limit.

Supported Types

FirstSecondDestination
BooleanScalarGroup
I8ScalarGroup
I16ScalarGroup
I32ScalarGroup
I64ScalarGroup
I128ScalarGroup
U8ScalarGroup
U16ScalarGroup
U32ScalarGroup
U64ScalarGroup
U128ScalarGroup
StringScalarGroup
InterfaceScalarGroup

div

Back to Top

Description

Divides first by second, storing the outcome in destination. Halts on division by zero.

For integer types, this operation performs truncated division. Furthermore, a constraint is added to check for underflow. This underflow happens when dividing the minimum value of a signed integer type by -1. For example, div -128i8 -1i8 would result in underflow, since 128 cannot be represented as an i8.

For cases where wrapping semantics are needed for integer types, see the div.w instruction.

Supported Types

FirstSecondDestination
FieldFieldField
I8I8I8
I16I16I16
I32I32I32
I64I64I64
I128I128I128
U8U8U8
U16U16U16
U32U32U32
U64U64U64
U128U128U128

div.w

Back to Top

Description

Divides first by second, wrapping around at the boundary of the type, and storing the outcome in destination.

Supported Types

FirstSecondDestination
I8I8I8
I16I16I16
I32I32I32
I64I64I64
I128I128I128
U8U8U8
U16U16U16
U32U32U32
U64U64U64
U128U128U128

double

Back to Top

Description

Doubles the input, storing the outcome in destination.

Supported Types

InputDestination
FieldField
GroupGroup

gt

Back to Top

Description

Checks if first is greater than second, storing the result in destination.

Supported Types

FirstSecondDestination
FieldFieldBoolean
I8I8Boolean
I16I16Boolean
I32I32Boolean
I64I64Boolean
I128I128Boolean
U8U8Boolean
U16U16Boolean
U32U32Boolean
U64U64Boolean
U128U128Boolean
ScalarScalarBoolean
<!--AddressAddress

gte

Back to Top

Description

Checks if first is greater than or equal to second, storing the result in destination.

Supported Types

FirstSecondDestination
FieldFieldBoolean
I8I8Boolean
I16I16Boolean
I32I32Boolean
I64I64Boolean
I128I128Boolean
U8U8Boolean
U16U16Boolean
U32U32Boolean
U64U64Boolean
U128U128Boolean
ScalarScalarBoolean
<!--AddressAddress

hash.bhp256

Back to Top

Description

Computes a BHP hash on inputs of 256-bit chunks in first, storing the hash in destination. The produced hash will always be a Field value.

The instruction will halt if the given input is smaller than 129 bits.

Supported Types

FirstDestination
AddressField
BooleanField
FieldField
GroupField
I8Field
I16Field
I32Field
I64Field
I128Field
U8Field
U16Field
U32Field
U64Field
U128Field
ScalarField
StringField
InterfaceField

hash.bhp512

Back to Top

Description

Computes a BHP hash on inputs of 512-bit chunks in first, storing the hash in destination. The produced hash will always be a Field value.

The instruction will halt if the given input is smaller than 171 bits.

Supported Types

FirstDestination
AddressField
BooleanField
FieldField
GroupField
I8Field
I16Field
I32Field
I64Field
I128Field
U8Field
U16Field
U32Field
U64Field
U128Field
ScalarField
StringField
InterfaceField

hash.bhp768

Back to Top

Description

Computes a BHP hash on inputs of 768-bit chunks in first, storing the hash in destination. The produced hash will always be a Field value.

The instruction will halt if the given input is smaller than 129 bits.

Supported Types

FirstDestination
AddressField
BooleanField
FieldField
GroupField
I8Field
I16Field
I32Field
I64Field
I128Field
U8Field
U16Field
U32Field
U64Field
U128Field
ScalarField
StringField
InterfaceField

hash.bhp1024

Back to Top

Description

Computes a BHP hash on inputs of 1024-bit chunks in first, storing the hash in destination. The produced hash will always be a Field value.

The instruction will halt if the given input is smaller than 171 bits.

Supported Types

FirstDestination
AddressField
BooleanField
FieldField
GroupField
I8Field
I16Field
I32Field
I64Field
I128Field
U8Field
U16Field
U32Field
U64Field
U128Field
ScalarField
StringField
InterfaceField

hash.ped64

Back to Top

Description

Computes a Pedersen hash up to a 64-bit input in first, storing the hash in destination. The produced hash will always be a Field value.

The instruction will halt if the given String or Interface value exceeds the 64-bit limit.

Supported Types

FirstDestination
BooleanField
I8Field
I16Field
I32Field
I64Field
U8Field
U16Field
U32Field
U64Field
StringField
InterfaceField

hash.ped128

Back to Top

Description

Computes a Pedersen hash up to a 128-bit input in first, storing the hash in destination. The produced hash will always be a Field value.

The instruction will halt if the given String or Interface value exceeds the 128-bit limit.

Supported Types

FirstDestination
BooleanField
I8Field
I16Field
I32Field
I64Field
I128Field
U8Field
U16Field
U32Field
U64Field
U128Field
StringField
InterfaceField

hash.psd2

Back to Top

Description

Calculates a Poseidon hash with an input rate of 2, from an input in first, storing the hash in destination. The produced hash will always be a Field value.

Supported Types

FirstDestination
FieldField
I8Field
I16Field
I32Field
I64Field
I128Field
U8Field
U16Field
U32Field
U64Field
U128Field
ScalarField
StringField
InterfaceField

hash.psd4

Back to Top

Description

Calculates a Poseidon hash with an input rate of 4, from an input in first, storing the hash in destination. The produced hash will always be a Field value.

Supported Types

FirstDestination
FieldField
I8Field
I16Field
I32Field
I64Field
I128Field
U8Field
U16Field
U32Field
U64Field
U128Field
ScalarField
StringField
InterfaceField

hash.psd8

Back to Top

Description

Calculates a Poseidon hash with an input rate of 8, from an input in first, storing the hash in destination. The produced hash will always be a Field value.

Supported Types

FirstDestination
FieldField
I8Field
I16Field
I32Field
I64Field
I128Field
U8Field
U16Field
U32Field
U64Field
U128Field
ScalarField
StringField
InterfaceField

inv

Back to Top

Description

Computes the multiplicative inverse of the input, storing the outcome in destination.

Supported Types

InputDestination
FieldField

is.eq

Back to Top

Description

Compares first and second, storing the result in destination.

Supported Types

FirstSecondDestination
AddressAddressAddress
BooleanBooleanBoolean
FieldFieldField
GroupGroupGroup
I8I8I8
I16I16I16
I32I32I32
I64I64I64
I128I128I128
U8U8U8
U16U16U16
U32U32U32
U64U64U64
U128U128U128
ScalarScalarScalar
InterfaceInterfaceInterface
RecordRecordRecord

is.neq

Back to Top

Description

Returns true if first is not equal to second, storing the result in destination.

Supported Types

FirstSecondDestination
AddressAddressAddress
BooleanBooleanBoolean
FieldFieldField
GroupGroupGroup
I8I8I8
I16I16I16
I32I32I32
I64I64I64
I128I128I128
U8U8U8
U16U16U16
U32U32U32
U64U64U64
U128U128U128
ScalarScalarScalar
InterfaceInterfaceInterface
RecordRecordRecord

lt

Back to Top

Description

Checks if first is less than second, storing the outcome in destination.

Supported Types

FirstSecondDestination
FieldFieldBoolean
I8I8Boolean
I16I16Boolean
I32I32Boolean
I64I64Boolean
I128I128Boolean
U8U8Boolean
U16U16Boolean
U32U32Boolean
U64U64Boolean
U128U128Boolean
ScalarScalarBoolean
<!--AddressAddress

lte

Back to Top

Description

Checks if first is less than or equal to second, storing the outcome in destination.

Supported Types

FirstSecondDestination
FieldFieldBoolean
I8I8Boolean
I16I16Boolean
I32I32Boolean
I64I64Boolean
I128I128Boolean
U8U8Boolean
U16U16Boolean
U32U32Boolean
U64U64Boolean
U128U128Boolean
ScalarScalarBoolean
<!--AddressAddress

mod

Back to Top

Description

Takes the modulus of first with respect to second, storing the outcome in destination. Halts if second is zero.

The semantics of this operation are consistent with the mathematical definition of modulo operation.

Supported Types

FirstSecondDestination
U8U8U8
U16U16U16
U32U32U32
U64U64U64
U128U128U128

mul

Back to Top

Description

Multiplies first with second, storing the outcome in destination.

For integer types, a constraint is added to check for overflow/underflow. For cases where wrapping semantics are needed for integer types, see the mul.w instruction.

Supported Types

FirstSecondDestination
FieldFieldField
GroupScalarGroup
ScalarGroupGroup
I8I8I8
I16I16I16
I32I32I32
I64I64I64
I128I128I128
U8U8U8
U16U16U16
U32U32U32
U64U64U64
U128U128U128

mul.w

Back to Top

Description

Multiplies first with second, wrapping around at the boundary of the type, and storing the outcome in destination.

Supported Types

FirstSecondDestination
I8I8I8
I16I16I16
I32I32I32
I64I64I64
I128I128I128
U8U8U8
U16U16U16
U32U32U32
U64U64U64
U128U128U128

nand

Back to Top

Description

Returns false only if first and second are true, storing the outcome in destination.

Supported Types

FirstSecondDestination
BooleanBooleanBoolean

neg

Back to Top

Description

Negates first, storing the outcome in destination.

For signed integer types, calling neg on the minimum value is an invalid operation. For example, the input -128i8 would not be valid since 128 cannot be represented as an i8.

Supported Types

InputDestination
FieldField
GroupGroup
I8I8
I16I16
I32I32
I64I64
I128I128

nor

Back to Top

Description

Returns true when neither first nor second is true, storing the outcome in destination.

Supported Type

FirstSecondDestination
BooleanBooleanBoolean

not

Back to Top

Description

Perform a NOT operation on an integer (bitwise) or boolean input, storing the outcome in destination.

Supported Types

InputDestination
BooleanBoolean
I8I8
I16I16
I32I32
I64I64
I128I128
U8U8
U16U16
U32U32
U64U64
U128U128

or

Back to Top

Description

Performs an OR operation on integer (bitwise) or boolean first and second, storing the outcome in destination.

Supported Types

FirstSecondDestination
BooleanBooleanBoolean
I8I8I8
I16I16I16
I32I32I32
I64I64I64
I128I128I128
U8U8U8
U16U16U16
U32U32U32
U64U64U64
U128U128U128

pow

Back to Top

Description

Raises first to the power of second, storing the outcome in destination.

For integer types, a constraint is added to check for overflow/underflow. For cases where wrapping semantics are needed for integer types, see the pow.w instruction.

Supported Types

Magnitude can be a U8, U16, or U32.

FirstSecondDestination
FieldFieldField
I8MagnitudeI8
I16MagnitudeI16
I32MagnitudeI32
I64MagnitudeI64
I128MagnitudeI128
U8MagnitudeU8
U16MagnitudeU16
U32MagnitudeU32
U64MagnitudeU64
U128MagnitudeU128

pow.w

Back to Top

Description

Raises first to the power of second, wrapping around at the boundary of the type, storing the outcome in destination.

Supported Types

Magnitude can be a U8, U16, or U32.

FirstSecondDestination
I8MagnitudeI8
I16MagnitudeI16
I32MagnitudeI32
I64MagnitudeI64
I128MagnitudeI128
U8MagnitudeU8
U16MagnitudeU16
U32MagnitudeU32
U64MagnitudeU64
U128MagnitudeU128

rem

Back to Top

Description

Computes the truncated remainder of first divided by second, storing the outcome in destination. Halts on division by zero.

A constraint is added to check for underflow. This underflow happens when the associated division operation, div, underflows.

For cases where wrapping semantics are needed for integer types, see the rem.w instruction.

Supported Types

FirstSecondDestination
I8I8I8
I16I16I16
I32I32I32
I64I64I64
I128I128I128
U8U8U8
U16U16U16
U32U32U32
U64U64U64
U128U128U128

rem.w

Back to Top

Description

Computes the truncated remainder of first divided by second, wrapping around at the boundary of the type, and storing the outcome in destination.

Supported Types

FirstSecondDestination
I8I8I8
I16I16I16
I32I32I32
I64I64I64
I128I128I128
U8U8U8
U16U16U16
U32U32U32
U64U64U64
U128U128U128

shl

Back to Top

Description

Shifts first left by second bits, storing the outcome in destination.

Supported Types

Magnitude can be a U8, U16, or U32.

FirstSecondDestination
I8MagnitudeI8
I16MagnitudeI16
I32MagnitudeI32
I64MagnitudeI64
I128MagnitudeI128
U8MagnitudeU8
U16MagnitudeU16
U32MagnitudeU32
U64MagnitudeU64
U128MagnitudeU128

shl.w

Back to Top

Description

Shifts first left by second bits, wrapping around at the boundary of the type, storing the outcome in destination.

Supported Types

Magnitude can be a U8, U16, or U32.

FirstSecondDestination
I8MagnitudeI8
I16MagnitudeI16
I32MagnitudeI32
I64MagnitudeI64
I128MagnitudeI128
U8MagnitudeU8
U16MagnitudeU16
U32MagnitudeU32
U64MagnitudeU64
U128MagnitudeU128

shr

Back to Top

Description

Shifts first right by second bits, storing the outcome in destination.

Supported Types

Magnitude can be a U8, U16, or U32.

FirstSecondDestination
I8MagnitudeI8
I16MagnitudeI16
I32MagnitudeI32
I64MagnitudeI64
I128MagnitudeI128
U8MagnitudeU8
U16MagnitudeU16
U32MagnitudeU32
U64MagnitudeU64
U128MagnitudeU128

shr.w

Back to Top

Description

Shifts first right by second bits, wrapping around at the boundary of the type, storing the outcome in destination.

Supported Types

Magnitude can be a U8, U16, or U32.

FirstSecondDestination
I8MagnitudeI8
I16MagnitudeI16
I32MagnitudeI32
I64MagnitudeI64
I128MagnitudeI128
U8MagnitudeU8
U16MagnitudeU16
U32MagnitudeU32
U64MagnitudeU64
U128MagnitudeU128

square

Back to Top

Description

Squares the input, storing the outcome in destination.

Supported Types

InputDestination
FieldField

sqrt

Back to Top

Description

Computes the square root of the input, storing the outcome in destination.

Supported Types

InputDestination
FieldField

sub

Back to Top

Description

Computes first - second, storing the outcome in destination.

Supported Types

FirstSecondDestination
FieldFieldField
GroupGroupGroup
I8I8I8
I16I16I16
I32I32I32
I64I64I64
I128I128I128
U8U8U8
U16U16U16
U32U32U32
U64U64U64
U128U128U128

sub.w

Back to Top

Description

Computes first - second, wrapping around at the boundary of the type, and storing the outcome in destination.

Supported Types

FirstSecondDestination
I8I8I8
I16I16I16
I32I32I32
I64I64I64
I128I128I128
U8U8U8
U16U16U16
U32U32U32
U64U64U64
U128U128U128

ternary

Back to Top

Description

Selects first, if condition is true, otherwise selects second, storing the result in destination.

Example: ternary r0 r1 r2 into r3, where r0 is the condition, r1 is first, r2 is second, and r3 is the destination.

Supported Types

ConditionFirstSecondDestination
BooleanBooleanBooleanBoolean
BooleanFieldFieldField
BooleanGroupGroupGroup
BooleanI8I8I8
BooleanI16I16I16
BooleanI32I32I32
BooleanI64I64I64
BooleanI128I128I128
BooleanU8U8U8
BooleanU16U16U16
BooleanU32U32U32
BooleanU64U64U64
BooleanU128U128U128
BooleanScalarScalarScalar

xor

Back to Top

Description

Performs a XOR operation on integer (bitwise) or boolean first and second, storing the outcome in destination.

Supported Types

FirstSecondDestination
BooleanBooleanBoolean
I8I8I8
I16I16I16
I32I32I32
I64I64I64
I128I128I128
U8U8U8
U16U16U16
U32U32U32
U64U64U64
U128U128U128