Leo Operators Reference
The following lists show the standard and cryptographic operators supported by Leo. The Leo operators compile down to Aleo instructions opcodes executable by the Aleo Virtual Machine (AVM).
Table of Standard Operatorsβ
Name | Description |
---|---|
abs | Absolute value |
abs_wrapped | Wrapping absolute value |
add | Addition |
add_wrapped | Wrapping addition |
and | Conjunction |
assert | Assert boolean true |
assert_eq | Assert equality |
assert_neq | Assert non-equality |
div | Division |
div_wrapped | Wrapping division operation |
double | Double |
group::GEN | group generator |
gt | Greater than comparison |
gte | Greater than or equal to comparison |
inv | Multiplicative inverse |
eq | Equality comparison |
neq | Non-equality comparison |
lt | Less than comparison |
lte | Less than or equal to comparison |
mod | Modulo |
mul | Multiplication |
mul_wrapped | Wrapping multiplication |
nand | Negated conjunction |
neg | Additive inverse |
nor | Negated disjunction |
not | Logical negation |
or | (Inclusive) disjunction |
pow | Exponentiation |
pow_wrapped | Wrapping exponentiation |
rem | Remainder |
rem_wrapped | Wrapping remainder |
shl | Shift left |
shl_wrapped | Wrapping shift left |
shr | Shift right |
shr_wrapped | Wrapping shift right |
square_root | Square root |
square | Square |
sub | Subtraction |
sub_wrapped | Wrapping subtraction |
ternary | Ternary select |
xor | Exclusive conjunction |
Table of Cryptographic Operatorsβ
Specificationβ
The following is the specification for each operator in the Leo compiler.
abs
β
let a: i8 = -1i8;
let b: i8 = a.abs(); // 1i8
Descriptionβ
Computes the absolute value of the input, checking for overflow, storing the result in the destination.
Note that execution will halt if the operation overflows/underflows. For cases where wrapping semantics are needed, see the abs_wrapped 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_wrapped
β
let a: i8 = -128i8;
let b: i8 = a.abs_wrapped(); // -128i8
Descriptionβ
Compute the absolute value of the input, wrapping around at the boundary of the type, and storing the result in the destination.
Supported Typesβ
Input | Destination |
---|---|
i8 | i8 |
i16 | i16 |
i32 | i32 |
i64 | i64 |
i128 | i128 |
add
β
let a: u8 = 1u8;
let b: u8 = a + 1u8; // 2u8
let c: u8 = b.add(1u8); // 3u8
Descriptionβ
Adds first
with second
, storing the result in destination
.
Note that execution will halt if the operation overflows. For cases where wrapping semantics are needed for integer types, see the add_wrapped 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_wrapped
β
let a: u8 = 255u8;
let b: u8 = a.add_wrapped(1u8); // 0u8
Descriptionβ
Adds first
with second
, wrapping around at the boundary of the type, and storing the result 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
β
let a: i8 = 1i8 & 1i8; // 1i8
let b: i8 = 1i8.and(2i8); // 0i8
Descriptionβ
Performs an AND operation on integer (bitwise) or boolean first
and second
,
storing the result in destination
.
Supported Typesβ
First | Second | Destination |
---|---|---|
bool | bool | bool |
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
β
let a: bool = true;
let b: bool = false;
assert(a); // will not halt
assert(b); // program halts
Descriptionβ
Checks whether the expression evaluates to a true
boolean value, halting if evaluates to false
.
Supported Typesβ
Expression |
---|
bool |
assert_eq
β
let a: u8 = 1u8;
let b: u8 = 2u8;
assert_eq(a, a); // will not halt
assert_eq(a, b); // program halts
Descriptionβ
Checks whether first
and second
are equal, halting if they are not equal.
Supported Typesβ
First | Second |
---|---|
address | address |
bool | bool |
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 |
Signature | Signature |
struct | struct |
Record | Record |
assert_neq
β
let a: u8 = 1u8;
let b: u8 = 2u8;
assert_neq(a, b); // will not halt
assert_neq(a, a); // program halts
Descriptionβ
Checks whether first
and second
are not equal, halting if they are equal.
Supported Typesβ
First | Second |
---|---|
address | address |
bool | bool |
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 |
Signature | Signature |
struct | struct |
Record | Record |
block.height
β
async transition matches(height: u32) -> Future {
return check_block_height(height);
}
async function check_block_height(height: u32) {
assert_eq(height, block.height);
}
Descriptionβ
The block.height
operator is used to fetch the latest block height in a Leo program. It represents the number of
blocks in the chain. In the above example, block.height
is used in an async function to fetch the latest block
height in a program.
Note:β
- The
block.height
operator can only be used in an async function. Using it outside an async function will result in a compilation error. - The
block.height
operator doesn't take any parameters.
div
β
let a: u8 = 4u8;
let b: u8 = a / 2u8; // 2u8
let c: u8 = b.div(2u8); // 1u8
Descriptionβ
Performs division of the first operand by the second, storing the result in the destination. The operation halts if division by zero is attempted.
For integer types, this operation performs truncated division. Truncated division rounds towards zero, regardless of the sign of the operands. This means it cuts off any digits after the decimal, leaving the whole number whose absolute value is less than or equal to the result.
For example:
7 / 3
yields2
, not2.3333
.-7 / 3
yields-2
, not-2.3333
.
The operation halts if there is an underflow. Underflow occurs when dividing the minimum value of a signed integer type by -1. For example, -128i8 / -1i8
would result in underflow, since 128 cannot be represented as an i8
.
For field types, division a / b
is well-defined for any field values a
and b
except when b = 0field
.
For cases where wrapping semantics are needed for integer types, see the div_wrapped 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_wrapped
β
let a: i8 = -128i8;
let b: i8 = a.div_wrapped(-1i8); // -128i8
Descriptionβ
Divides first
by second
, wrapping around at the boundary of the type, and storing the result 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
β
let a: group = (0, 4)group;
let b: group = a.double();
Descriptionβ
Doubles the input, storing the result in destination
.
Supported Typesβ
Input | Destination |
---|---|
field | field |
group | group |
gt
β
let a: bool = 2u8 > 1u8; // true
let b: bool = 1u8.gt(1u8); // false
Descriptionβ
Checks if first
is greater than second
, storing the result in destination
.
Supported Typesβ
First | Second | Destination |
---|---|---|
field | field | bool |
i8 | i8 | bool |
i16 | i16 | bool |
i32 | i32 | bool |
i64 | i64 | bool |
i128 | i128 | bool |
u8 | u8 | bool |
u16 | u16 | bool |
u32 | u32 | bool |
u64 | u64 | bool |
u128 | u128 | bool |
scalar | scalar | bool |
gte
β
let a: bool = 2u8 >= 1u8; // true
let b: bool = 1u8.gte(1u8); // true
Descriptionβ
Checks if first
is greater than or equal to second
, storing the result in destination
.
Supported Typesβ
First | Second | Destination |
---|---|---|
field | field | bool |
i8 | i8 | bool |
i16 | i16 | bool |
i32 | i32 | bool |
i64 | i64 | bool |
i128 | i128 | bool |
u8 | u8 | bool |
u16 | u16 | bool |
u32 | u32 | bool |
u64 | u64 | bool |
u128 | u128 | bool |
scalar | scalar | bool |
inv
β
let a: field = 1field.inv();
Descriptionβ
Computes the multiplicative inverse of the input, storing the result in destination
.
Supported Typesβ
Input | Destination |
---|---|
field | field |
eq
β
let a: bool = 1u8 == 1u8; // true
let b: bool = 1u8.eq(2u8); // false
Descriptionβ
Compares first
and second
for equality, storing the result in destination
.
Supported Typesβ
First | Second | Destination |
---|---|---|
address | address | bool |
bool | bool | bool |
field | field | bool |
group | group | bool |
i8 | i8 | bool |
i16 | i16 | bool |
i32 | i32 | bool |
i64 | i64 | bool |
i128 | i128 | bool |
u8 | u8 | bool |
u16 | u16 | bool |
u32 | u32 | bool |
u64 | u64 | bool |
u128 | u128 | bool |
scalar | scalar | bool |
Signature | Signature | bool |
struct | struct | bool |
Record | Record | bool |
neq
β
let a: bool = 1u8 != 1u8; // false
let b: bool = 1u8.neq(2u8); // true
Descriptionβ
Compares first
and second
for non-equality, storing the result in destination
.
Supported Typesβ
First | Second | Destination |
---|---|---|
address | address | bool |
bool | bool | bool |
field | field | bool |
group | group | bool |
i8 | i8 | bool |
i16 | i16 | bool |
i32 | i32 | bool |
i64 | i64 | bool |
i128 | i128 | bool |
u8 | u8 | bool |
u16 | u16 | bool |
u32 | u32 | bool |
u64 | u64 | bool |
u128 | u128 | bool |
scalar | scalar | bool |
Signature | Signature | bool |
struct | struct | bool |
Record | Record | bool |
lt
β
let a: bool = 1u8 < 2u8; // true
let b: bool = 1u8.lt(1u8); // false
Descriptionβ
Checks if first
is less than second
, storing the result in destination
.
Supported Typesβ
First | Second | Destination |
---|---|---|
field | field | bool |
i8 | i8 | bool |
i16 | i16 | bool |
i32 | i32 | bool |
i64 | i64 | bool |
i128 | i128 | bool |
u8 | u8 | bool |
u16 | u16 | bool |
u32 | u32 | bool |
u64 | u64 | bool |
u128 | u128 | bool |
scalar | scalar | bool |
lte
β
let a: bool = 1u8 <= 2u8; // true
let b: bool = 1u8.lte(1u8); // true
Descriptionβ
Checks if first
is less than or equal to second
, storing the result in destination
.
Supported Typesβ
First | Second | Destination |
---|---|---|
field | field | bool |
i8 | i8 | bool |
i16 | i16 | bool |
i32 | i32 | bool |
i64 | i64 | bool |
i128 | i128 | bool |
u8 | u8 | bool |
u16 | u16 | bool |
u32 | u32 | bool |
u64 | u64 | bool |
u128 | u128 | bool |
scalar | scalar | bool |
mod
β
let a: u8 = 3u8.mod(2u8); // 1u8
Descriptionβ
Takes the modulo of first
with respect to second
, storing the result 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
β
let a: u8 = 2u8 * 2u8; // 4u8
let b: u8 = a.mul(2u8); // 8u8
Descriptionβ
Multiplies first
with second
, storing the result in destination
.
Note that execution will halt if the operation overflows/underflows. For cases where wrapping semantics are needed for integer types, see the mul_wrapped 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_wrapped
β
let a: u8 = 128u8.mul_wrapped(2u8); // 0u8
Descriptionβ
Multiplies first
with second
, wrapping around at the boundary of the type, and storing the result 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
β
let a: bool = true.nand(false); // true
Descriptionβ
Calculates the negated conjunction of first
and second
, storing the result in destination
.
The result is false if and only if both first and second are true.
Supported Typesβ
First | Second | Destination |
---|---|---|
bool | bool | bool |
neg
β
let a: i8 = -1i8.neg(); // 1i8
Descriptionβ
Negates first
, storing the result 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
β
let a: bool = false.nor(false); // true
Descriptionβ
Returns true when neither first
nor second
is true, storing the result in destination
.
Supported Typeβ
First | Second | Destination |
---|---|---|
bool | bool | bool |
not
β
let a: bool = true.not(); // false
Descriptionβ
Perform a NOT operation on an integer (bitwise) or boolean input, storing the result in destination
.
Supported Typesβ
Input | Destination |
---|---|
bool | bool |
i8 | i8 |
i16 | i16 |
i32 | i32 |
i64 | i64 |
i128 | i128 |
u8 | u8 |
u16 | u16 |
u32 | u32 |
u64 | u64 |
u128 | u128 |
orβ
let a: bool = true || false; // true
let b: bool = false.or(false); // false
Descriptionβ
Performs an OR operation on integer (bitwise) or boolean first
and second
, storing the result in destination
.
Supported Typesβ
First | Second | Destination |
---|---|---|
bool | bool | bool |
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 |
pow
β
let a: u8 = 2u8 ** 2u8; // 4u8
let b: u8 = a.pow(2u8); // 16u8
Descriptionβ
Raises first
to the power of second
, storing the result in destination
.
Note that execution will halt if the operation overflows/underflows. For cases where wrapping semantics are needed for integer types, see the pow_wrapped 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_wrapped
β
let a: u8 = 16u8.pow_wrapped(2u8); // 0u8
Descriptionβ
Raises first
to the power of second
, wrapping around at the boundary of the type, storing the result 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 |
rem
β
let a: u8 = 3u8 % 2u8; // 1u8
let b: u8 = 4u8.rem(2u8); // 0u8
Descriptionβ
Computes the truncated remainder of first
divided by second
, storing the result in destination
. Halts on division by zero.
Note that execution will halt if the operation underflows. This underflow happens when the associated division operation, div, underflows.
For cases where wrapping semantics are needed for integer types, see the rem_wrapped 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_wrapped
β
let a: i8 = -128i8;
let b: i8 = a.rem_wrapped(-1i8); // 0i8
Descriptionβ
Computes the truncated remainder of first
divided by second
, wrapping around at the boundary of the type, and storing the result 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 |
signature::verify
β
transition verify_field(s: signature, a: address, v: field) {
let first: bool = signature::verify(s, a, v);
let second: bool = s.verify(a, v);
assert_eq(first, second);
}
Descriptionβ
Verifies that the signature first
was signed by the address second
with respect to the field third
, storing the result in destination
.
Supported Typesβ
A Message
is any literal or struct
type.
First | Second | Third | Destination |
---|---|---|---|
signature | address | Message | bool |
shl
β
let a: u8 = 1u8 << 1u8; // 2u8
let b: u8 = a.shl(1u8); // 4u8
Descriptionβ
Shifts first
left by second
bits, storing the result 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_wrapped
β
let a: u8 = 128u8.shl_wrapped(1u8); // 0u8
Descriptionβ
Shifts first
left by second
bits, wrapping around at the boundary of the type, storing the result 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
β
let a: u8 = 4u8 >> 1u8; // 2u8
let b: u8 = a.shr(1u8); // 1u8
Descriptionβ
Shifts first
right by second
bits, storing the result 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_wrapped
β
let a: u8 = 128u8.shr_wrapped(7u8); // 1u8
Descriptionβ
Shifts first
right by second
bits, wrapping around at the boundary of the type, storing the result 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 |
square
β
let a: field = 1field.square(); // 1field
Descriptionβ
Squares the input, storing the result in destination
.
Supported Typesβ
Input | Destination |
---|---|
field | field |
square_root
β
let a: field = 1field.square_root(); // 1field
Descriptionβ
Computes the square root of the input, storing the result in destination
.
Supported Typesβ
Input | Destination |
---|---|
field | field |
sub
β
let a: u8 = 2u8 - 1u8; // 1u8
let b: u8 = a.sub(1u8); // 0u8
Descriptionβ
Computes first - second
, storing the result 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_wrapped
β
let a: u8 = 0u8.sub_wrapped(1u8); // 255u8
Descriptionβ
Computes first - second
, wrapping around at the boundary of the type, and storing the result 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
β
let a: u8 = true ? 1u8 : 2u8; // 1u8
Descriptionβ
Selects first
, if condition
is true, otherwise selects second
, storing the result in destination
.
Supported Typesβ
Condition | First | Second | Destination |
---|---|---|---|
bool | bool | bool | bool |
bool | field | field | field |
bool | group | group | group |
bool | i8 | i8 | i8 |
bool | i16 | i16 | i16 |
bool | i32 | i32 | i32 |
bool | i64 | i64 | i64 |
bool | i128 | i128 | i128 |
bool | u8 | u8 | u8 |
bool | u16 | u16 | u16 |
bool | u32 | u32 | u32 |
bool | u64 | u64 | u64 |
bool | u128 | u128 | u128 |
bool | scalar | scalar | scalar |
bool | Signature | Signature | Signature |
xor
β
let a: bool = true.xor(false); // true
Descriptionβ
Performs a XOR operation on integer (bitwise) or boolean first
and second
, storing the result in destination
.
Supported Typesβ
First | Second | Destination |
---|---|---|
bool | bool | bool |
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 |
group::GEN
β
let g: group = group::GEN; // the group generator
Descriptionβ
Returns the generator of the algebraic group that the group
type consists of.
The compilation of Leo is based on an elliptic curve, whose points form a group,
and on a specified point on that curve, which generates a subgroup, whose elements form the type group
.
This is a constant, not a function. Thus, it takes no inputs, and just returns an output.
It is an associated constant, whose name is GEN
and whose associated type is group
.
Supported Typesβ
Destination |
---|
group |
ChaCha::rand_DESTINATION
β
let result: address = ChaCha::rand_address();
let result: bool = ChaCha::rand_bool();
let result: field = ChaCha::rand_field();
let result: group = ChaCha::rand_group();
let result: i8 = ChaCha::rand_i8();
let result: i16 = ChaCha::rand_i16();
let result: i32 = ChaCha::rand_i32();
let result: i64 = ChaCha::rand_i64();
let result: i128 = ChaCha::rand_i128();
let result: u8 = ChaCha::rand_u8();
let result: u16 = ChaCha::rand_u16();
let result: u32 = ChaCha::rand_u32();
let result: u64 = ChaCha::rand_u64();
let result: u128 = ChaCha::rand_u128();
let result: scalar = ChaCha::rand_scalar();
Descriptionβ
Returns a random value with the destination type. This operation can only be used in an async function.
Supported Typesβ
Destination |
---|
address |
bool |
field |
group |
i8 |
i16 |
i32 |
i64 |
i128 |
u8 |
u16 |
u32 |
u64 |
u128 |
scalar |
BHP256::commit_to_DESTINATION
β
let salt: scalar = ChaCha::rand_scalar();
let a: address = BHP256::commit_to_address(1u8, salt);
let b: field = BHP256::commit_to_field(2i64, salt);
let c: group = BHP256::commit_to_group(1field, salt);
Descriptionβ
Computes a Bowe-Hopwood-Pedersen 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 can be an address
, field
or, group
value.
The instruction will halt if the given input is smaller than 129 bits.
Supported Typesβ
First | Second | Destination |
---|---|---|
address | scalar | address , field , group |
bool | 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 |
BHP512::commit_to_DESTINATION
β
let salt: scalar = ChaCha::rand_scalar();
let a: address = BHP512::commit_to_address(1u8, salt);
let b: field = BHP512::commit_to_field(2i64, salt);
let c: group = BHP512::commit_to_group(1field, salt);
Descriptionβ
Computes a Bowe-Hopwood-Pedersen 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 group
value.
The instruction will halt if the given input is smaller than 171 bits.
Supported Typesβ
First | Second | Destination |
---|---|---|
address | scalar | address , field , group |
bool | 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 |
BHP768::commit_to_DESTINATION
β
let salt: scalar = ChaCha::rand_scalar();
let a: address = BHP768::commit_to_address(1u8, salt);
let b: field = BHP768::commit_to_field(2i64, salt);
let c: group = BHP768::commit_to_group(1field, salt);
Descriptionβ
Computes a Bowe-Hopwood-Pedersen 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 group
value.
The instruction will halt if the given input is smaller than 129 bits.
Supported Typesβ
First | Second | Destination |
---|---|---|
address | scalar | address , field , group |
bool | 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 |
BHP1024::commit_to_DESTINATION
β
let salt: scalar = ChaCha::rand_scalar();
let a: address = BHP1024::commit_to_address(1u8, salt);
let b: field = BHP1024::commit_to_field(2i64, salt);
let c: group = BHP1024::commit_to_group(1field, salt);
Descriptionβ
Computes a Bowe-Hopwood-Pedersen 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 group
value.
The instruction will halt if the given input is smaller than 171 bits.
Supported Typesβ
First | Second | Destination |
---|---|---|
address | scalar | address , field , group |
bool | 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 |
Pedersen64::commit_to_DESTINATION
β
let salt: scalar = ChaCha::rand_scalar();
let a: address = Pedersen64::commit_to_address(1u8, salt);
let b: field = Pedersen64::commit_to_field(2i64, salt);
let c: group = Pedersen64::commit_to_group(1field, salt);
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 struct
value exceeds the 64-bit limit.
Supported Typesβ
First | Second | Destination |
---|---|---|
bool | scalar | address , field , group |
i8 | scalar | address , field , group |
i16 | scalar | address , field , group |
i32 | scalar | address , field , group |
u8 | scalar | address , field , group |
u16 | scalar | address , field , group |
u32 | scalar | address , field , group |
struct | scalar | address , field , group |
Pedersen128::commit_to_DESTINATION
β
let salt: scalar = ChaCha::rand_scalar();
let a: address = Pedersen64::commit_to_address(1u8, salt);
let b: field = Pedersen64::commit_to_field(2i64, salt);
let c: group = Pedersen64::commit_to_group(1field, salt);
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 struct
value exceeds the 128-bit limit.
Supported Typesβ
First | Second | Destination |
---|---|---|
bool | 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 |
BHP256::hash_to_DESTINATION
β
let result: address = BHP256::hash_to_address(1u8);
let result: field = BHP256::hash_to_field(2i64);
let result: group = BHP256::hash_to_group(1field);
let result: scalar = BHP256::hash_to_scalar(1field);
let result: i8 = BHP256::hash_to_i8(1field);
let result: i16 = BHP256::hash_to_i16(1field);
let result: i32 = BHP256::hash_to_i32(1field);
let result: i64 = BHP256::hash_to_i64(1field);
let result: i128 = BHP256::hash_to_i128(1field);
let result: u8 = BHP256::hash_to_u8(1field);
let result: u16 = BHP256::hash_to_u16(1field);
let result: u32 = BHP256::hash_to_u32(1field);
let result: u64 = BHP256::hash_to_u64(1field);
let result: u128 = BHP256::hash_to_u128(1field);
Descriptionβ
Computes a Bowe-Hopwood-Pedersen 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 hash_to_DESTINATION
at the end of the function.
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 |
bool | 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 |
BHP512::hash_to_DESTINATION
β
let result: address = BHP512::hash_to_address(1u8);
let result: field = BHP512::hash_to_field(2i64);
let result: group = BHP512::hash_to_group(1field);
let result: scalar = BHP512::hash_to_scalar(1field);
let result: i8 = BHP512::hash_to_i8(1field);
let result: i16 = BHP512::hash_to_i16(1field);
let result: i32 = BHP512::hash_to_i32(1field);
let result: i64 = BHP512::hash_to_i64(1field);
let result: i128 = BHP512::hash_to_i128(1field);
let result: u8 = BHP512::hash_to_u8(1field);
let result: u16 = BHP512::hash_to_u16(1field);
let result: u32 = BHP512::hash_to_u32(1field);
let result: u64 = BHP512::hash_to_u64(1field);
let result: u128 = BHP512::hash_to_u128(1field);
Descriptionβ
Computes a Bowe-Hopwood-Pedersen 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 hash_to_DESTINATION
at the end of the function.
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 |
bool | 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 |
BHP768::hash_to_DESTINATION
β
let result: address = BHP768::hash_to_address(1u8);
let result: field = BHP768::hash_to_field(2i64);
let result: group = BHP768::hash_to_group(1field);
let result: scalar = BHP768::hash_to_scalar(1field);
let result: i8 = BHP768::hash_to_i8(1field);
let result: i16 = BHP768::hash_to_i16(1field);
let result: i32 = BHP768::hash_to_i32(1field);
let result: i64 = BHP768::hash_to_i64(1field);
let result: i128 = BHP768::hash_to_i128(1field);
let result: u8 = BHP768::hash_to_u8(1field);
let result: u16 = BHP768::hash_to_u16(1field);
let result: u32 = BHP768::hash_to_u32(1field);
let result: u64 = BHP768::hash_to_u64(1field);
let result: u128 = BHP768::hash_to_u128(1field);
Descriptionβ
Computes a Bowe-Hopwood-Pedersen 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 hash_to_DESTINATION
at the end of the function.
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 |
bool | 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 |
BHP1024::hash_to_DESTINATION
β
let result: address = BHP1024::hash_to_address(1u8);
let result: field = BHP1024::hash_to_field(2i64);
let result: group = BHP1024::hash_to_group(1field);
let result: scalar = BHP1024::hash_to_scalar(1field);
let result: i8 = BHP1024::hash_to_i8(1field);
let result: i16 = BHP1024::hash_to_i16(1field);
let result: i32 = BHP1024::hash_to_i32(1field);
let result: i64 = BHP1024::hash_to_i64(1field);
let result: i128 = BHP1024::hash_to_i128(1field);
let result: u8 = BHP1024::hash_to_u8(1field);
let result: u16 = BHP1024::hash_to_u16(1field);
let result: u32 = BHP1024::hash_to_u32(1field);
let result: u64 = BHP1024::hash_to_u64(1field);
let result: u128 = BHP1024::hash_to_u128(1field);
Descriptionβ
Computes a Bowe-Hopwood-Pedersen 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 hash_to_DESTINATION
at the end of the function.
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 |
bool | 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 |
Keccak256::hash_to_DESTINATION
β
let result: address = Keccak256::hash_to_address(1u8);
let result: field = Keccak256::hash_to_field(2i64);
let result: group = Keccak256::hash_to_group(1field);
let result: scalar = Keccak256::hash_to_scalar(1field);
let result: i8 = Keccak256::hash_to_i8(1field);
let result: i16 = Keccak256::hash_to_i16(1field);
let result: i32 = Keccak256::hash_to_i32(1field);
let result: i64 = Keccak256::hash_to_i64(1field);
let result: i128 = Keccak256::hash_to_i128(1field);
let result: u8 = Keccak256::hash_to_u8(1field);
let result: u16 = Keccak256::hash_to_u16(1field);
let result: u32 = Keccak256::hash_to_u32(1field);
let result: u64 = Keccak256::hash_to_u64(1field);
let result: u128 = Keccak256::hash_to_u128(1field);
Descriptionβ
Computes a Keccak256 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 hash_to_DESTINATION
at the end of the function.
Supported Typesβ
First | Destination |
---|---|
address | address , field , group , scalar , i8 , i16 , i32 ,i64 ,i128 , u8 , u16 , u32 , u64 , u128 |
bool | 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 |
Keccak384::hash_to_DESTINATION
β
let result: address = Keccak384::hash_to_address(1u8);
let result: field = Keccak384::hash_to_field(2i64);
let result: group = Keccak384::hash_to_group(1field);
let result: scalar = Keccak384::hash_to_scalar(1field);
let result: i8 = Keccak384::hash_to_i8(1field);
let result: i16 = Keccak384::hash_to_i16(1field);
let result: i32 = Keccak384::hash_to_i32(1field);
let result: i64 = Keccak384::hash_to_i64(1field);
let result: i128 = Keccak384::hash_to_i128(1field);
let result: u8 = Keccak384::hash_to_u8(1field);
let result: u16 = Keccak384::hash_to_u16(1field);
let result: u32 = Keccak384::hash_to_u32(1field);
let result: u64 = Keccak384::hash_to_u64(1field);
let result: u128 = Keccak384::hash_to_u128(1field);
Descriptionβ
Computes a Keccak384 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 hash_to_DESTINATION
at the end of the function.
Supported Typesβ
First | Destination |
---|---|
address | address , field , group , scalar , i8 , i16 , i32 ,i64 ,i128 , u8 , u16 , u32 , u64 , u128 |
bool | 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 |
Keccak512::hash_to_DESTINATION
β
let result: address = Keccak512::hash_to_address(1u8);
let result: field = Keccak512::hash_to_field(2i64);
let result: group = Keccak512::hash_to_group(1field);
let result: scalar = Keccak512::hash_to_scalar(1field);
let result: i8 = Keccak512::hash_to_i8(1field);
let result: i16 = Keccak512::hash_to_i16(1field);
let result: i32 = Keccak512::hash_to_i32(1field);
let result: i64 = Keccak512::hash_to_i64(1field);
let result: i128 = Keccak512::hash_to_i128(1field);
let result: u8 = Keccak512::hash_to_u8(1field);
let result: u16 = Keccak512::hash_to_u16(1field);
let result: u32 = Keccak512::hash_to_u32(1field);
let result: u64 = Keccak512::hash_to_u64(1field);
let result: u128 = Keccak512::hash_to_u128(1field);
Descriptionβ
Computes a Keccak512 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 hash_to_DESTINATION
at the end of the function.
Supported Typesβ
First | Destination |
---|---|
address | address , field , group , scalar , i8 , i16 , i32 ,i64 ,i128 , u8 , u16 , u32 , u64 , u128 |
bool | 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 |
Pedersen64::hash_to_DESTINATION
β
let result: address = Pedersen64::hash_to_address(1u8);
let result: field = Pedersen64::hash_to_field(2i64);
let result: group = Pedersen64::hash_to_group(1field);
let result: scalar = Pedersen64::hash_to_scalar(1field);
let result: i8 = Pedersen64::hash_to_i8(1field);
let result: i16 = Pedersen64::hash_to_i16(1field);
let result: i32 = Pedersen64::hash_to_i32(1field);
let result: i64 = Pedersen64::hash_to_i64(1field);
let result: i128 = Pedersen64::hash_to_i128(1field);
let result: u8 = Pedersen64::hash_to_u8(1field);
let result: u16 = Pedersen64::hash_to_u16(1field);
let result: u32 = Pedersen64::hash_to_u32(1field);
let result: u64 = Pedersen64::hash_to_u64(1field);
let result: u128 = Pedersen64::hash_to_u128(1field);
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 hash_to_DESTINATION
at the end of the function.
The instruction will halt if the given struct
value exceeds the 64-bit limit.
Supported Typesβ
First | Destination |
---|---|
bool | 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 |
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 |
struct | address , field , group , scalar , i8 , i16 , i32 ,i64 ,i128 , u8 , u16 , u32 , u64 , u128 |
Pedersen128::hash_to_DESTINATION
β
let result: address = Pedersen128::hash_to_address(1u8);
let result: field = Pedersen128::hash_to_field(2i64);
let result: group = Pedersen128::hash_to_group(1field);
let result: scalar = Pedersen128::hash_to_scalar(1field);
let result: i8 = Pedersen128::hash_to_i8(1field);
let result: i16 = Pedersen128::hash_to_i16(1field);
let result: i32 = Pedersen128::hash_to_i32(1field);
let result: i64 = Pedersen128::hash_to_i64(1field);
let result: i128 = Pedersen128::hash_to_i128(1field);
let result: u8 = Pedersen128::hash_to_u8(1field);
let result: u16 = Pedersen128::hash_to_u16(1field);
let result: u32 = Pedersen128::hash_to_u32(1field);
let result: u64 = Pedersen128::hash_to_u64(1field);
let result: u128 = Pedersen128::hash_to_u128(1field);
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 hash_to_DESTINATION
at the end of the function.
The instruction will halt if the given struct
value exceeds the 64-bit limit.
Supported Typesβ
First | Destination |
---|---|
bool | 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 |
Poseidon2::hash_to_DESTINATION
β
let result: address = Poseidon2::hash_to_address(1u8);
let result: field = Poseidon2::hash_to_field(2i64);
let result: group = Poseidon2::hash_to_group(1field);
let result: scalar = Poseidon2::hash_to_scalar(1field);
let result: i8 = Poseidon2::hash_to_i8(1field);
let result: i16 = Poseidon2::hash_to_i16(1field);
let result: i32 = Poseidon2::hash_to_i32(1field);
let result: i64 = Poseidon2::hash_to_i64(1field);
let result: i128 = Poseidon2::hash_to_i128(1field);
let result: u8 = Poseidon2::hash_to_u8(1field);
let result: u16 = Poseidon2::hash_to_u16(1field);
let result: u32 = Poseidon2::hash_to_u32(1field);
let result: u64 = Poseidon2::hash_to_u64(1field);
let result: u128 = Poseidon2::hash_to_u128(1field);
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 hash_to_DESTINATION
at the end of the function.
Supported Typesβ
First | Destination |
---|---|
address | address , field , group , scalar , i8 , i16 , i32 ,i64 ,i128 , u8 , u16 , u32 , u64 , u128 |
bool | 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 |
Poseidon4::hash_to_DESTINATION
β
let result: address = Poseidon4::hash_to_address(1u8);
let result: field = Poseidon4::hash_to_field(2i64);
let result: group = Poseidon4::hash_to_group(1field);
let result: scalar = Poseidon4::hash_to_scalar(1field);
let result: i8 = Poseidon4::hash_to_i8(1field);
let result: i16 = Poseidon4::hash_to_i16(1field);
let result: i32 = Poseidon4::hash_to_i32(1field);
let result: i64 = Poseidon4::hash_to_i64(1field);
let result: i128 = Poseidon4::hash_to_i128(1field);
let result: u8 = Poseidon4::hash_to_u8(1field);
let result: u16 = Poseidon4::hash_to_u16(1field);
let result: u32 = Poseidon4::hash_to_u32(1field);
let result: u64 = Poseidon4::hash_to_u64(1field);
let result: u128 = Poseidon4::hash_to_u128(1field);
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 hash_to_DESTINATION
at the end of the function.
Supported Typesβ
First | Destination |
---|---|
address | address , field , group , scalar , i8 , i16 , i32 ,i64 ,i128 , u8 , u16 , u32 , u64 , u128 |
bool | 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 |
Poseidon8::hash_to_DESTINATION
β
let result: address = Poseidon8::hash_to_address(1u8);
let result: field = Poseidon8::hash_to_field(2i64);
let result: group = Poseidon8::hash_to_group(1field);
let result: scalar = Poseidon8::hash_to_scalar(1field);
let result: i8 = Poseidon8::hash_to_i8(1field);
let result: i16 = Poseidon8::hash_to_i16(1field);
let result: i32 = Poseidon8::hash_to_i32(1field);
let result: i64 = Poseidon8::hash_to_i64(1field);
let result: i128 = Poseidon8::hash_to_i128(1field);
let result: u8 = Poseidon8::hash_to_u8(1field);
let result: u16 = Poseidon8::hash_to_u16(1field);
let result: u32 = Poseidon8::hash_to_u32(1field);
let result: u64 = Poseidon8::hash_to_u64(1field);
let result: u128 = Poseidon8::hash_to_u128(1field);
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 hash_to_DESTINATION
at the end of the function.
Supported Typesβ
First | Destination |
---|---|
address | address , field , group , scalar , i8 , i16 , i32 ,i64 ,i128 , u8 , u16 , u32 , u64 , u128 |
bool | 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 |
SHA3_256::hash_to_DESTINATION
β
let result: address = SHA3_256::hash_to_address(1u8);
let result: field = SHA3_256::hash_to_field(2i64);
let result: group = SHA3_256::hash_to_group(1field);
let result: scalar = SHA3_256::hash_to_scalar(1field);
let result: i8 = SHA3_256::hash_to_i8(1field);
let result: i16 = SHA3_256::hash_to_i16(1field);
let result: i32 = SHA3_256::hash_to_i32(1field);
let result: i64 = SHA3_256::hash_to_i64(1field);
let result: i128 = SHA3_256::hash_to_i128(1field);
let result: u8 = SHA3_256::hash_to_u8(1field);
let result: u16 = SHA3_256::hash_to_u16(1field);
let result: u32 = SHA3_256::hash_to_u32(1field);
let result: u64 = SHA3_256::hash_to_u64(1field);
let result: u128 = SHA3_256::hash_to_u128(1field);
Descriptionβ
Calculates a SHA3_256 hash 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 hash_to_DESTINATION
at the end of the function.
Supported Typesβ
First | Destination |
---|---|
address | address , field , group , scalar , i8 , i16 , i32 ,i64 ,i128 , u8 , u16 , u32 , u64 , u128 |
bool | 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 |
SHA3_384::hash_to_DESTINATION
β
let result: address = SHA3_384::hash_to_address(1u8);
let result: field = SHA3_384::hash_to_field(2i64);
let result: group = SHA3_384::hash_to_group(1field);
let result: scalar = SHA3_384::hash_to_scalar(1field);
let result: i8 = SHA3_384::hash_to_i8(1field);
let result: i16 = SHA3_384::hash_to_i16(1field);
let result: i32 = SHA3_384::hash_to_i32(1field);
let result: i64 = SHA3_384::hash_to_i64(1field);
let result: i128 = SHA3_384::hash_to_i128(1field);
let result: u8 = SHA3_384::hash_to_u8(1field);
let result: u16 = SHA3_384::hash_to_u16(1field);
let result: u32 = SHA3_384::hash_to_u32(1field);
let result: u64 = SHA3_384::hash_to_u64(1field);
let result: u128 = SHA3_384::hash_to_u128(1field);
Descriptionβ
Calculates a SHA3_384 hash 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 hash_to_DESTINATION
at the end of the function.
Supported Typesβ
First | Destination |
---|---|
address | address , field , group , scalar , i8 , i16 , i32 ,i64 ,i128 , u8 , u16 , u32 , u64 , u128 |
bool | 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 |
SHA3_512::hash_to_DESTINATION
β
let result: address = SHA3_512::hash_to_address(1u8);
let result: field = SHA3_512::hash_to_field(2i64);
let result: group = SHA3_512::hash_to_group(1field);
let result: scalar = SHA3_512::hash_to_scalar(1field);
let result: i8 = SHA3_512::hash_to_i8(1field);
let result: i16 = SHA3_512::hash_to_i16(1field);
let result: i32 = SHA3_512::hash_to_i32(1field);
let result: i64 = SHA3_512::hash_to_i64(1field);
let result: i128 = SHA3_512::hash_to_i128(1field);
let result: u8 = SHA3_512::hash_to_u8(1field);
let result: u16 = SHA3_512::hash_to_u16(1field);
let result: u32 = SHA3_512::hash_to_u32(1field);
let result: u64 = SHA3_512::hash_to_u64(1field);
let result: u128 = SHA3_512::hash_to_u128(1field);
Descriptionβ
Calculates a SHA3_512 hash 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 hash_to_DESTINATION
at the end of the function.
Supported Typesβ
First | Destination |
---|---|
address | address , field , group , scalar , i8 , i16 , i32 ,i64 ,i128 , u8 , u16 , u32 , u64 , u128 |
bool | 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 |