Skip to content

Latest commit

 

History

History

arc-0002

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
arc title authors discussion topic status created
2
Aleo Virtual Machine (AVM)
howardwu, acoglio, collinc97, d0cd
Protocol
Draft
2020-02-07

Abstract

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

Name Description
abs Absolute value operation
abs.w Wrapping absolute value operation
add Addition operation
add.w Wrapping add operation
and AND operation
assert.eq Assert equality
assert.neq Assert non-equality
block.height Returns height of the block within the finalize scope
branch.eq Branches to a position if the arguments are equal
branch.neq Branches to a position if the arguments are not equal
cast Cast between literals
cast.lossy Cast between literals with lossy truncation
commit.bhp256 256-bit input BHP commitment
commit.bhp512 512-bit input BHP commitment
commit.bhp768 768-bit input BHP commitment
commit.bhp1024 1024-bit input BHP commitment
commit.ped64 64-bit input Pedersen commitment
commit.ped128 128-bit input Pedersen commitment
div Division operation
div.w Wrapping division operation
double Double operation
gt Greater than comparison
gte Greater than or equal to comparison
hash.bhp256 256-bit input BHP hash
hash.bhp512 512-bit input BHP hash
hash.bhp768 768-bit input BHP hash
hash.bhp1024 1024-bit input BHP hash
hash.keccak256 256-bit input Keccak hash
hash.keccak384 384-bit input Keccak hash
hash.keccak512 512-bit input Keccak hash
hash.ped64 64-bit input Pedersen hash
hash.ped128 128-bit input Pedersen hash
hash.psd2 Poseidon hash with input rate 2
hash.psd4 Poseidon hash with input rate 4
hash.psd8 Poseidon hash with input rate 8
hash.sha3_256 256-bit input SHA3 hash
hash.sha3_384 384-bit input SHA3 hash
hash.sha3_512 512-bit input SHA3 hash
inv Multiplicative inverse operation
is.eq Equality comparison
is.neq Not equal comparison
lt Less than comparison
lte Less than or equal to comparison
mod Arithmetic modulo operation
mul Multiplication operation
mul.w Wrapping multiplication operation
nand Boolean NAND operation
neg Additive inverse operation
nor Boolean NOR operation
not NOT operation
or OR Operation
position The position command
pow Exponentiation operation
pow.w Wrapping exponentiation operation
rand.chacha Generates a random value within the finalize scope.
rem Remainder operation
rem.w Wrapping remainder operation
shl Shift left operation
shl.w Wrapping Shift left operation
shr Shift right operation
shr.w Wrapping Shift right operation
sign.verify Verify a Schnorr signature
sqrt Square root operation
square Square operation
sub Subtraction operation
sub.w Wrapping Subtraction operation
ternary Ternary select operation
xor XOR 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

Input Destination
I8 I8
I16 I16
I32 I32
I64 I64
I128 I128

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

Input Destination
I8 I8
I16 I16
I32 I32
I64 I64
I128 I128

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

First Second Destination
Field Field Field
Group Group Group
I8 I8 I8
I16 I16 I16
I32 I32 I32
I64 I64 I64
I128 I128 I128
U8 U8 U8
U16 U16 U16
U32 U32 U32
U64 U64 U64
U128 U128 U128
Scalar Scalar Scalar

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

First Second Destination
I8 I8 I8
I16 I16 I16
I32 I32 I32
I64 I64 I64
I128 I128 I128
U8 U8 U8
U16 U16 U16
U32 U32 U32
U64 U64 U64
U128 U128 U128

and

Back to Top

Description

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

Supported Types

First Second Destination
Boolean Boolean Boolean
I8 I8 I8
I16 I16 I16
I32 I32 I32
I64 I64 I64
I128 I128 I128
U8 U8 U8
U16 U16 U16
U32 U32 U32
U64 U64 U64
U128 U128 U128

assert.eq

Back to Top

Description

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

Supported Types

First Second
Address Address
Boolean Boolean
Field Field
Group Group
I8 I8
I16 I16
I32 I32
I64 I64
I128 I128
U8 U8
U16 U16
U32 U32
U64 U64
U128 U128
Scalar Scalar
Struct Struct
Record Record

assert.neq

Back to Top

Description

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

Supported Types

First Second
Address Address
Boolean Boolean
Field Field
Group Group
I8 I8
I16 I16
I32 I32
I64 I64
I128 I128
U8 U8
U16 U16
U32 U32
U64 U64
U128 U128
Scalar Scalar
Struct Struct
Record Record

block.height

Back to Top

Description

Returns the height of the block within the finalize scope. Currently, block height is the only supported property.

Example Usage

assert.eq block.height 1337;

branch.eq

Back to Top

Description

The command branch.eq <first> <second> to <destination> branches execution to the position indicated by destination if first and second are equal. This command is restricted to the finalize scope, and the destination must follow the command. Backward branches are not currently supported.

First Second Destination
Address Address Position
Boolean Boolean Position
Field Field Position
Group Group Position
I8 I8 Position
I16 I16 Position
I32 I32 Position
I64 I64 Position
I128 I128 Position
U8 U8 Position
U16 U16 Position
U32 U32 Position
U64 U64 Position
U128 U128 Position
Scalar Scalar Position
Struct Struct Position
Record Record Position

branch.neq

Back to Top

Description

The command branch.neq <first> <second> to <destination> branches execution to the position indicated by destination if first and second are not equal. This command is restricted to the finalize scope, and the destination must follow the command. Backward branches are not currently supported.

First Second Destination
Address Address Position
Boolean Boolean Position
Field Field Position
Group Group Position
I8 I8 Position
I16 I16 Position
I32 I32 Position
I64 I64 Position
I128 I128 Position
U8 U8 Position
U16 U16 Position
U32 U32 Position
U64 U64 Position
U128 U128 Position
Scalar Scalar Position
Struct Struct Position
Record Record Position

cast

Back to Top

Description

Enables casting between different literals.

Example Usage

input r0 as field.private;
cast r0 into r1 as group;
cast r0 into r2 as u8;
cast r3 r4 r5 r6 into r7 as [boolean; 4u32];
cast r7 into r8 as [[boolean; 4u32]; 1u32];

Supported Types

First Second
Address Address
Array Array
Boolean Boolean
Field Field
Group Group
I8 I8
I16 I16
I32 I32
I64 I64
I128 I128
U8 U8
U16 U16
U32 U32
U64 U64
U128 U128
Scalar Scalar

cast.lossy

Back to Top

Description

Perform casting with lossy truncation.

Example Usage

input r0 as field.private;
cast r0 into r1 as group;
cast r0 into r2 as u8;
cast.lossy r0 into r3 as u8; // The bottom 8 bits of the r0 are extracted into a u8 and placed into r3

Supported Types

First Second
Address Address
Boolean Boolean
Field Field
Group Group
I8 I8
I16 I16
I32 I32
I64 I64
I128 I128
U8 U8
U16 U16
U32 U32
U64 U64
U128 U128
Scalar Scalar

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 an Address, Field, or Group value, as specified via as at the end of the instruction.

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

Supported Types

First Second Destination
Address Scalar Address, Field, Group
Boolean Scalar Address, Field, Group
Field Scalar Address, Field, Group
Group Scalar Address, Field, Group
I8 Scalar Address, Field, Group
I16 Scalar Address, Field, Group
I32 Scalar Address, Field, Group
I64 Scalar Address, Field, Group
I128 Scalar Address, Field, Group
U8 Scalar Address, Field, Group
U16 Scalar Address, Field, Group
U32 Scalar Address, Field, Group
U64 Scalar Address, Field, Group
U128 Scalar Address, Field, Group
Scalar Scalar Address, Field, Group
Struct Scalar Address, Field, Group

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 an Address, Field, or Group value, as specified via as at the end of the instruction.

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

Supported Types

First Second Destination
Address Scalar Address, Field, Group
Boolean Scalar Address, Field, Group
Field Scalar Address, Field, Group
Group Scalar Address, Field, Group
I8 Scalar Address, Field, Group
I16 Scalar Address, Field, Group
I32 Scalar Address, Field, Group
I64 Scalar Address, Field, Group
I128 Scalar Address, Field, Group
U8 Scalar Address, Field, Group
U16 Scalar Address, Field, Group
U32 Scalar Address, Field, Group
U64 Scalar Address, Field, Group
U128 Scalar Address, Field, Group
Scalar Scalar Address, Field, Group
Struct Scalar Address, Field, Group

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 an Address, Field, or Group value, as specified via as at the end of the instruction.

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

Supported Types

First Second Destination
Address Scalar Address, Field, Group
Boolean Scalar Address, Field, Group
Field Scalar Address, Field, Group
Group Scalar Address, Field, Group
I8 Scalar Address, Field, Group
I16 Scalar Address, Field, Group
I32 Scalar Address, Field, Group
I64 Scalar Address, Field, Group
I128 Scalar Address, Field, Group
U8 Scalar Address, Field, Group
U16 Scalar Address, Field, Group
U32 Scalar Address, Field, Group
U64 Scalar Address, Field, Group
U128 Scalar Address, Field, Group
Scalar Scalar Address, Field, Group
Struct Scalar Address, Field, Group

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 an Address, Field, or Group value, as specified via as at the end of the instruction.

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

Supported Types

First Second Destination
Address Scalar Address, Field, Group
Boolean Scalar Address, Field, Group
Field Scalar Address, Field, Group
Group Scalar Address, Field, Group
I8 Scalar Address, Field, Group
I16 Scalar Address, Field, Group
I32 Scalar Address, Field, Group
I64 Scalar Address, Field, Group
I128 Scalar Address, Field, Group
U8 Scalar Address, Field, Group
U16 Scalar Address, Field, Group
U32 Scalar Address, Field, Group
U64 Scalar Address, Field, Group
U128 Scalar Address, Field, Group
Scalar Scalar Address, Field, Group
Struct Scalar Address, Field, Group

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 an Address, Field, or Group value, as specified via as at the end of the instruction.

The instruction will halt if the given Struct value exceeds the 64-bit limit.

Supported Types

First Second Destination
Boolean Scalar Address, Field, Group
I8 Scalar Address, Field, Group
I16 Scalar Address, Field, Group
I32 Scalar Address, Field, Group
I64 Scalar Address, Field, Group
U8 Scalar Address, Field, Group
U16 Scalar Address, Field, Group
U32 Scalar Address, Field, Group
U64 Scalar Address, Field, Group
Struct Scalar Address, Field, Group

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 an Address, Field, or Group value, as specified via as at the end of the instruction.

The instruction will halt if the given Struct value exceeds the 128-bit limit.

Supported Types

First Second Destination
Boolean Scalar Address, Field, Group
I8 Scalar Address, Field, Group
I16 Scalar Address, Field, Group
I32 Scalar Address, Field, Group
I64 Scalar Address, Field, Group
U8 Scalar Address, Field, Group
U16 Scalar Address, Field, Group
U32 Scalar Address, Field, Group
U64 Scalar Address, Field, Group
Struct Scalar Address, Field, Group

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

First Second Destination
Field Field Field
I8 I8 I8
I16 I16 I16
I32 I32 I32
I64 I64 I64
I128 I128 I128
U8 U8 U8
U16 U16 U16
U32 U32 U32
U64 U64 U64
U128 U128 U128

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

First Second Destination
I8 I8 I8
I16 I16 I16
I32 I32 I32
I64 I64 I64
I128 I128 I128
U8 U8 U8
U16 U16 U16
U32 U32 U32
U64 U64 U64
U128 U128 U128

double

Back to Top

Description

Doubles the input, storing the outcome in destination.

Supported Types

Input Destination
Field Field
Group Group

gt

Back to Top

Description

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

Supported Types

First Second Destination
Field Field Boolean
I8 I8 Boolean
I16 I16 Boolean
I32 I32 Boolean
I64 I64 Boolean
I128 I128 Boolean
U8 U8 Boolean
U16 U16 Boolean
U32 U32 Boolean
U64 U64 Boolean
U128 U128 Boolean
Scalar Scalar Boolean

gte

Back to Top

Description

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

Supported Types

First Second Destination
Field Field Boolean
I8 I8 Boolean
I16 I16 Boolean
I32 I32 Boolean
I64 I64 Boolean
I128 I128 Boolean
U8 U8 Boolean
U16 U16 Boolean
U32 U32 Boolean
U64 U64 Boolean
U128 U128 Boolean
Scalar Scalar Boolean

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 an arithmetic (U8, U16, U32, U64, U128, I8, I16, I32,I64,I128, Field, Group, or Scalar) or Address value, as specified via as at the end of the instruction.

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

Supported Types

First Destination
Address Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Boolean Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Field Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Group Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I8 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I16 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I32 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I64 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I128 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U8 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U16 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U32 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U64 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U128 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Scalar Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Struct Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128

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 an arithmetic (U8, U16, U32, U64, U128, I8, I16, I32,I64,I128, Field, Group, or Scalar) or Address value, as specified via as at the end of the instruction.

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

Supported Types

First Destination
Address Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Boolean Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Field Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Group Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I8 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I16 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I32 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I64 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I128 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U8 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U16 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U32 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U64 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U128 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Scalar Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Struct Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128

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 an arithmetic (U8, U16, U32, U64, U128, I8, I16, I32,I64,I128, Field, Group, or Scalar) or Address value, as specified via as at the end of the instruction.

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

Supported Types

First Destination
Address Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Boolean Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Field Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Group Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I8 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I16 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I32 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I64 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I128 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U8 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U16 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U32 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U64 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U128 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Scalar Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Struct Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128

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 an arithmetic (U8, U16, U32, U64, U128, I8, I16, I32,I64,I128, Field, Group, or Scalar) or Address value, as specified via as at the end of the instruction.

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

Supported Types

First Destination
Address Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Boolean Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Field Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Group Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I8 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I16 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I32 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I64 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I128 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U8 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U16 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U32 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U64 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U128 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Scalar Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Struct Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128

hash.keccak256

Back to Top

Description

Performs a Keccak hash on first, storing a 256-bit digest in destination. The produced hash will always be an arithmetic (U8, U16, U32, U64, U128, I8, I16, I32,I64,I128, Field, Group, or Scalar) or Address value, as specified via as at the end of the instruction.

Supported Types

First Destination
Address Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Boolean Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Field Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Group Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I8 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I16 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I32 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I64 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I128 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U8 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U16 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U32 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U64 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U128 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Scalar Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Struct Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128

hash.keccak384

Back to Top

Description

Performs a Keccak hash on first, storing a 384-bit digest in destination. The produced hash will always be an arithmetic (U8, U16, U32, U64, U128, I8, I16, I32,I64,I128, Field, Group, or Scalar) or Address value, as specified via as at the end of the instruction.

Supported Types

First Destination
Address Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Boolean Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Field Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Group Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I8 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I16 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I32 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I64 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I128 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U8 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U16 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U32 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U64 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U128 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Scalar Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Struct Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128

hash.keccak512

Back to Top

Description

Performs a Keccak hash on first, storing a 512-bit digest in destination. The produced hash will always be an arithmetic (U8, U16, U32, U64, U128, I8, I16, I32,I64,I128, Field, Group, or Scalar) or Address value, as specified via as at the end of the instruction.

Supported Types

First Destination
Address Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Boolean Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Field Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Group Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I8 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I16 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I32 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I64 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I128 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U8 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U16 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U32 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U64 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U128 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Scalar Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Struct Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128

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 an arithmetic (U8, U16, U32, U64, U128, I8, I16, I32,I64,I128, Field, Group, or Scalar) or Address value, as specified via as at the end of the instruction.

The instruction will halt if the given Struct value exceeds the 64-bit limit.

Supported Types

First Destination
Boolean Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I8 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I16 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I32 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I64 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U8 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U16 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U32 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U64 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Struct Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128

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 an arithmetic (U8, U16, U32, U64, U128, I8, I16, I32,I64,I128, Field, Group, or Scalar) or Address value, as specified via as at the end of the instruction.

The instruction will halt if the given Struct value exceeds the 128-bit limit.

Supported Types

First Destination
Boolean Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I8 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I16 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I32 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I64 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I128 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U8 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U16 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U32 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U64 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U128 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Struct Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128

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 an arithmetic (U8, U16, U32, U64, U128, I8, I16, I32,I64,I128, Field, Group, or Scalar) or Address value, as specified via as at the end of the instruction.

Supported Types

First Destination
Field Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I8 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I16 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I32 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I64 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I128 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U8 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U16 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U32 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U64 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U128 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Scalar Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Struct Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128

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 an arithmetic (U8, U16, U32, U64, U128, I8, I16, I32,I64,I128, Field, Group, or Scalar) or Address value, as specified via as at the end of the instruction.

Supported Types

First Destination
Field Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I8 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I16 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I32 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I64 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I128 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U8 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U16 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U32 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U64 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U128 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Scalar Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Struct Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128

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 an arithmetic (U8, U16, U32, U64, U128, I8, I16, I32,I64,I128, Field, Group, or Scalar) or Address value, as specified via as at the end of the instruction.

Supported Types

First Destination
Field Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I8 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I16 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I32 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I64 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I128 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U8 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U16 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U32 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U64 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U128 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Scalar Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Struct Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128

hash.sha3_256

Back to Top

Description

Calculates a SHA3-256 hash, from an input in first, storing the 256-bit digest in destination. The produced hash will always be an arithmetic (U8, U16, U32, U64, U128, I8, I16, I32,I64,I128, Field, Group, or Scalar) or Address value, as specified via as at the end of the instruction.

Supported Types

First Destination
Address Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Boolean Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Field Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Group Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I8 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I16 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I32 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I64 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I128 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U8 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U16 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U32 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U64 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U128 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Scalar Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Struct Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128

hash.sha3_384

Back to Top

Description

Calculates a SHA3-384 hash, from an input in first, storing the 384-bit digest in destination. The produced hash will always be an arithmetic (U8, U16, U32, U64, U128, I8, I16, I32,I64,I128, Field, Group, or Scalar) or Address value, as specified via as at the end of the instruction.

Supported Types

First Destination
Address Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Boolean Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Field Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Group Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I8 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I16 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I32 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I64 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I128 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U8 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U16 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U32 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U64 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U128 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Scalar Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Struct Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128

hash.sha3_512

Back to Top

Description

Calculates a SHA3-512 hash, from an input in first, storing the 512-bit digest in destination. The produced hash will always be an arithmetic (U8, U16, U32, U64, U128, I8, I16, I32,I64,I128, Field, Group, or Scalar) or Address value, as specified via as at the end of the instruction.

Supported Types

First Destination
Address Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Boolean Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Field Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Group Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I8 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I16 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I32 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I64 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
I128 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U8 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U16 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U32 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U64 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
U128 Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Scalar Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128
Struct Address, Field, Group, Scalar, I8, I16, I32,I64,I128, U8, U16, U32, U64, U128

inv

Back to Top

Description

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

Supported Types

Input Destination
Field Field

is.eq

Back to Top

Description

Compares first and second, storing the result in destination.

Supported Types

First Second Destination
Address Address Address
Boolean Boolean Boolean
Field Field Field
Group Group Group
I8 I8 I8
I16 I16 I16
I32 I32 I32
I64 I64 I64
I128 I128 I128
U8 U8 U8
U16 U16 U16
U32 U32 U32
U64 U64 U64
U128 U128 U128
Scalar Scalar Scalar
Struct Struct Struct
Record Record Record

is.neq

Back to Top

Description

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

Supported Types

First Second Destination
Address Address Address
Boolean Boolean Boolean
Field Field Field
Group Group Group
I8 I8 I8
I16 I16 I16
I32 I32 I32
I64 I64 I64
I128 I128 I128
U8 U8 U8
U16 U16 U16
U32 U32 U32
U64 U64 U64
U128 U128 U128
Scalar Scalar Scalar
Struct Struct Struct
Record Record Record

lt

Back to Top

Description

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

Supported Types

First Second Destination
Field Field Boolean
I8 I8 Boolean
I16 I16 Boolean
I32 I32 Boolean
I64 I64 Boolean
I128 I128 Boolean
U8 U8 Boolean
U16 U16 Boolean
U32 U32 Boolean
U64 U64 Boolean
U128 U128 Boolean
Scalar Scalar Boolean

lte

Back to Top

Description

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

Supported Types

First Second Destination
Field Field Boolean
I8 I8 Boolean
I16 I16 Boolean
I32 I32 Boolean
I64 I64 Boolean
I128 I128 Boolean
U8 U8 Boolean
U16 U16 Boolean
U32 U32 Boolean
U64 U64 Boolean
U128 U128 Boolean
Scalar Scalar Boolean

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

First Second Destination
U8 U8 U8
U16 U16 U16
U32 U32 U32
U64 U64 U64
U128 U128 U128

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

First Second Destination
Field Field Field
Group Scalar Group
Scalar Group Group
I8 I8 I8
I16 I16 I16
I32 I32 I32
I64 I64 I64
I128 I128 I128
U8 U8 U8
U16 U16 U16
U32 U32 U32
U64 U64 U64
U128 U128 U128

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

First Second Destination
I8 I8 I8
I16 I16 I16
I32 I32 I32
I64 I64 I64
I128 I128 I128
U8 U8 U8
U16 U16 U16
U32 U32 U32
U64 U64 U64
U128 U128 U128

nand

Back to Top

Description

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

Supported Types

First Second Destination
Boolean Boolean Boolean

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

Input Destination
Field Field
Group Group
I8 I8
I16 I16
I32 I32
I64 I64
I128 I128

nor

Back to Top

Description

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

Supported Type

First Second Destination
Boolean Boolean Boolean

not

Back to Top

Description

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

Supported Types

Input Destination
Boolean Boolean
I8 I8
I16 I16
I32 I32
I64 I64
I128 I128
U8 U8
U16 U16
U32 U32
U64 U64
U128 U128

or

Back to Top

Description

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

Supported Types

First Second Destination
Boolean Boolean Boolean
I8 I8 I8
I16 I16 I16
I32 I32 I32
I64 I64 I64
I128 I128 I128
U8 U8 U8
U16 U16 U16
U32 U32 U32
U64 U64 U64
U128 U128 U128

position

Back to Top

Description

The position declaration, e.g. position <name>, which indicates a location name in the program to branch execution to. Positions must be a lowercase alphanumeric string.


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.

First Second Destination
Field Field Field
I8 Magnitude I8
I16 Magnitude I16
I32 Magnitude I32
I64 Magnitude I64
I128 Magnitude I128
U8 Magnitude U8
U16 Magnitude U16
U32 Magnitude U32
U64 Magnitude U64
U128 Magnitude U128

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.

First Second Destination
I8 Magnitude I8
I16 Magnitude I16
I32 Magnitude I32
I64 Magnitude I64
I128 Magnitude I128
U8 Magnitude U8
U16 Magnitude U16
U32 Magnitude U32
U64 Magnitude U64
U128 Magnitude U128

rand.chacha

Description

The rand.chacha opcode is used to generate random values within the finalize scope. It supports a wide range of types for the random value.

Example Usage

rand.chacha into r0 as field;
rand.chacha r0 into r1 as field;
rand.chacha r0 r1 into r2 as field;
rand.chacha 1u8 2i16 into r27 as u32;

Supported Types

Single can be any of the following types Address, Boolean, Field, Group, I8, I16, I32, I64, I128, U8, U16, U32, U64, U128, or Scalar. Composite data types such as structs and mappings are not allowed.

First Second Destination
Single Single Single

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

First Second Destination
I8 I8 I8
I16 I16 I16
I32 I32 I32
I64 I64 I64
I128 I128 I128
U8 U8 U8
U16 U16 U16
U32 U32 U32
U64 U64 U64
U128 U128 U128

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

First Second Destination
I8 I8 I8
I16 I16 I16
I32 I32 I32
I64 I64 I64
I128 I128 I128
U8 U8 U8
U16 U16 U16
U32 U32 U32
U64 U64 U64
U128 U128 U128

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.

First Second Destination
I8 Magnitude I8
I16 Magnitude I16
I32 Magnitude I32
I64 Magnitude I64
I128 Magnitude I128
U8 Magnitude U8
U16 Magnitude U16
U32 Magnitude U32
U64 Magnitude U64
U128 Magnitude U128

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.

First Second Destination
I8 Magnitude I8
I16 Magnitude I16
I32 Magnitude I32
I64 Magnitude I64
I128 Magnitude I128
U8 Magnitude U8
U16 Magnitude U16
U32 Magnitude U32
U64 Magnitude U64
U128 Magnitude U128

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.

First Second Destination
I8 Magnitude I8
I16 Magnitude I16
I32 Magnitude I32
I64 Magnitude I64
I128 Magnitude I128
U8 Magnitude U8
U16 Magnitude U16
U32 Magnitude U32
U64 Magnitude U64
U128 Magnitude U128

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.

First Second Destination
I8 Magnitude I8
I16 Magnitude I16
I32 Magnitude I32
I64 Magnitude I64
I128 Magnitude I128
U8 Magnitude U8
U16 Magnitude U16
U32 Magnitude U32
U64 Magnitude U64
U128 Magnitude U128

sign.verify

Back to Top

Description

Verifies the signature first against the address public key second and the message third, storing the outcome in destination.

Example Usage

sign.verify r0 r1 r2 into r3;

square

Back to Top

Description

Squares the input, storing the outcome in destination.

Supported Types

Input Destination
Field Field

sqrt

Back to Top

Description

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

Supported Types

Input Destination
Field Field

sub

Back to Top

Description

Computes first - second, storing the outcome in destination.

Supported Types

First Second Destination
Field Field Field
Group Group Group
I8 I8 I8
I16 I16 I16
I32 I32 I32
I64 I64 I64
I128 I128 I128
U8 U8 U8
U16 U16 U16
U32 U32 U32
U64 U64 U64
U128 U128 U128

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

First Second Destination
I8 I8 I8
I16 I16 I16
I32 I32 I32
I64 I64 I64
I128 I128 I128
U8 U8 U8
U16 U16 U16
U32 U32 U32
U64 U64 U64
U128 U128 U128

ternary

Back to Top

Description

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

Example Usage

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

Supported Types

Condition First Second Destination
Boolean Boolean Boolean Boolean
Boolean Field Field Field
Boolean Group Group Group
Boolean I8 I8 I8
Boolean I16 I16 I16
Boolean I32 I32 I32
Boolean I64 I64 I64
Boolean I128 I128 I128
Boolean U8 U8 U8
Boolean U16 U16 U16
Boolean U32 U32 U32
Boolean U64 U64 U64
Boolean U128 U128 U128
Boolean Scalar Scalar Scalar

xor

Back to Top

Description

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

Supported Types

First Second Destination
Boolean Boolean Boolean
I8 I8 I8
I16 I16 I16
I32 I32 I32
I64 I64 I64
I128 I128 I128
U8 U8 U8
U16 U16 U16
U32 U32 U32
U64 U64 U64
U128 U128 U128