diff --git a/arc-0002/README.md b/arc-0002/README.md index 268e87c..0598a33 100644 --- a/arc-0002/README.md +++ b/arc-0002/README.md @@ -21,6 +21,11 @@ The following is a list of opcodes supported by the Aleo Virtual Machine (AVM). | [and](#and) | AND operation | | [assert.eq](#asserteq) | Assert equality | | [assert.neq](#assertneq) | Assert non-equality | +| [block.height](#blockheight) | Returns height of the block within the finalize scope | +| [branch.eq](#brancheq) | Branches to a position if the arguments are equal | +| [branch.neq](#branchneq) | Branches to a position if the arguments are not equal | +| [cast](#cast) | Cast between literals | +| [cast.lossy](#castlossy) | Cast between literals with lossy truncation | | [commit.bhp256](#commitbhp256) | 256-bit input BHP commitment | | [commit.bhp512](#commitbhp512) | 512-bit input BHP commitment | | [commit.bhp768](#commitbhp768) | 768-bit input BHP commitment | @@ -36,11 +41,17 @@ The following is a list of opcodes supported by the Aleo Virtual Machine (AVM). | [hash.bhp512](#hashbhp512) | 512-bit input BHP hash | | [hash.bhp768](#hashbhp768) | 768-bit input BHP hash | | [hash.bhp1024](#hashbhp1024) | 1024-bit input BHP hash | +| [hash.keccak256](#hashkeccak256) | 256-bit input Keccak hash | +| [hash.keccak384](#hashkeccak384) | 384-bit input Keccak hash | +| [hash.keccak512](#hashkeccak512) | 512-bit input Keccak hash | | [hash.ped64](#hashped64) | 64-bit input Pedersen hash | | [hash.ped128](#hashped128) | 128-bit input Pedersen hash | | [hash.psd2](#hashpsd2) | Poseidon hash with input rate 2 | | [hash.psd4](#hashpsd4) | Poseidon hash with input rate 4 | | [hash.psd8](#hashpsd8) | Poseidon hash with input rate 8 | +| [hash.sha3_256](#hashsha3_256) | 256-bit input SHA3 hash | +| [hash.sha3_384](#hashsha3_384) | 384-bit input SHA3 hash | +| [hash.sha3_512](#hashsha3_512) | 512-bit input SHA3 hash | | [inv](#inv) | Multiplicative inverse operation | | [is.eq](#iseq) | Equality comparison | | [is.neq](#isneq) | Not equal comparison | @@ -54,14 +65,17 @@ The following is a list of opcodes supported by the Aleo Virtual Machine (AVM). | [nor](#nor) | `Boolean` NOR operation | | [not](#not) | NOT operation | | [or](#or) | OR Operation | +| [position](#position) | The position command | | [pow](#pow) | Exponentiation operation | | [pow.w](#poww) | Wrapping exponentiation operation | +| [rand.chacha](#randchacha) | Generates a random value within the `finalize` scope. | | [rem](#rem) | Remainder operation | | [rem.w](#remw) | Wrapping remainder operation | | [shl](#shl) | Shift left operation | | [shl.w](#shlw) | Wrapping Shift left operation | | [shr](#shr) | Shift right operation | | [shr.w](#shrw) | Wrapping Shift right operation | +| [sign.verify](#signverify) | Verify a Schnorr signature | | [sqrt](#sqrt) | Square root operation | | [square](#square) | Square operation | | [sub](#sub) | Subtraction operation | @@ -261,6 +275,163 @@ Checks whether `first` and `second` are not equal, halting if they are equal. *** +### `block.height` + +[Back to Top](#Instruction-Greensheet) + +#### Description + +Returns the height of the block within the finalize scope. +Currently, block height is the only supported property. + +#### Example Usage + +```aleo +assert.eq block.height 1337; +``` + +*** + +### `branch.eq` + +[Back to Top](#Instruction-Greensheet) + +#### Description + +The command `branch.eq to ` branches execution to the [position](#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](#Instruction-Greensheet) + +#### Description + +The command `branch.neq to ` branches execution to the [position](#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](#Instruction-Greensheet) + +#### Description + +Enables casting between different literals. + +#### Example Usage + +```aleo +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](#Instruction-Greensheet) + +#### Description + +Perform casting with lossy truncation. + +#### Example Usage + +```aleo +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](#Instruction-Greensheet) @@ -457,7 +628,6 @@ Divides `first` by `second`, storing the outcome in `destination`. Halts on divi 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](#divw) instruction. #### Supported Types @@ -511,7 +681,6 @@ Divides `first` by `second`, wrapping around at the boundary of the type, and st Doubles the input, storing the outcome in `destination`. - #### Supported Types | Input | Destination | @@ -547,7 +716,6 @@ Checks if `first` is greater than `second`, storing the result in `destination`. | `Scalar` | `Scalar` | `Boolean` | - *** ### `gte` @@ -576,8 +744,6 @@ Checks if `first` is greater than or equal to `second`, storing the result in `d | `Scalar` | `Scalar` | `Boolean` | - - *** ### `hash.bhp256` @@ -712,6 +878,99 @@ The instruction will halt if the given input is smaller than 171 bits. *** +### `hash.keccak256` + +[Back to Top](#Instruction-Greensheet) + +#### 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](#Instruction-Greensheet) + +#### 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](#Instruction-Greensheet) + +#### 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](#Instruction-Greensheet) @@ -852,6 +1111,98 @@ Calculates a Poseidon hash with an input rate of 8, from an input in `first`, st *** +### `hash.sha3_256` + +[Back to Top](#Instruction-Greensheet) + +#### 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](#Instruction-Greensheet) + +#### 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](#Instruction-Greensheet) + +#### 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](#Instruction-Greensheet) @@ -958,7 +1309,6 @@ Checks if `first` is less than `second`, storing the outcome in `destination`. | `Scalar` | `Scalar` | `Boolean` | - *** ### `lte` @@ -1174,6 +1524,17 @@ Performs an OR operation on integer (bitwise) or boolean `first` and `second`, s *** +### position + +[Back to Top](#Instruction-Greensheet) + +#### Description + +The position declaration, e.g. `position `, which indicates a location `name` in the program to branch execution to. +Positions must be a lowercase alphanumeric string. + +*** + ### `pow` [Back to Top](#Instruction-Greensheet) @@ -1231,6 +1592,29 @@ Raises `first` to the power of `second`, wrapping around at the boundary of the *** +### `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 + +```aleo +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` @@ -1240,7 +1624,6 @@ Raises `first` to the power of `second`, wrapping around at the boundary of the 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](#div), underflows. For cases where wrapping semantics are needed for integer types, see the [rem.w](#remw) instruction. @@ -1394,6 +1777,22 @@ Shifts `first` right by `second` bits, wrapping around at the boundary of the ty *** +### `sign.verify` + +[Back to Top](#Instruction-Greensheet) + +#### Description + +Verifies the signature `first` against the address public key `second` and the message `third`, storing the outcome in `destination`. + +#### Example Usage + +```aleo +sign.verify r0 r1 r2 into r3; +``` + +*** + ### `square` [Back to Top](#Instruction-Greensheet) @@ -1487,7 +1886,9 @@ Computes `first - second`, wrapping around at the boundary of the type, and stor 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. +#### 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